/* AudioBook Organizer - Main Styles */

/* Import Stripe payment styles */
@import 'stripe.css';

:root {
    /* Updated to match landing page purple theme */
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --accent-color: #667eea;
    
    /* Background gradients with purple theme */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(45deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    
    /* Text colors - Light Mode */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-light: rgba(255, 255, 255, 0.9);
    
    /* Background colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --background-light: #f8f9ff;
    --app-bg: linear-gradient(135deg, #f8f9ff 0%, #f3f4ff 100%);
    
    /* UI elements */
    --border-color: #e2e8f0;
    --shadow-color: rgba(102, 126, 234, 0.1);
    --shadow-sm: 0 2px 4px var(--shadow-color);
    --shadow-md: 0 4px 6px var(--shadow-color);
    --overlay-bg: rgba(102, 126, 234, 0.95);
    
    /* Radius and spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --primary-color-rgb: 102, 126, 234;

    /* Section Colors - Light Mode */
    --section-color-1: #fff3e0;  /* Soft Orange */
    --section-color-2: #e8f5e9;  /* Soft Green */
    --section-color-3: #e3f2fd;  /* Soft Blue */
    --section-color-4: #fce4ec;  /* Soft Pink */
    --section-color-5: #efebe9;  /* Soft Brown */
    --section-color-6: #e0f7fa;  /* Soft Cyan */
    --section-color-7: #f3e5f5;  /* Soft Purple */
    --section-color-8: #e8eaf6;  /* Soft Indigo */
    
    /* Animation */
    --animation-duration: 0.3s;
    --animation-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Variables - ENHANCED with higher specificity */
html[data-theme="dark"] {
    /* Text colors - Dark Mode */
    --text-primary: #e2e8f0 !important;
    --text-secondary: #cbd5e0 !important;
    --text-muted: #a0aec0 !important;
    --text-light: rgba(255, 255, 255, 0.9) !important;
    
    /* Background colors - Dark Mode */
    --bg-primary: #1a202c !important;
    --bg-secondary: #2d3748 !important;
    --background-light: #2d3748 !important;
    --app-bg: linear-gradient(135deg, #1a202c 0%, #2d3748 100%) !important;
    
    /* UI elements - Dark Mode */
    --border-color: #4a5568 !important;
    --shadow-color: rgba(0, 0, 0, 0.3) !important;
    --shadow-sm: 0 2px 4px var(--shadow-color) !important;
    --shadow-md: 0 4px 6px var(--shadow-color) !important;
    
    /* Section Colors - Dark Mode */
    --section-color-1: #2d1810 !important;  /* Dark Orange */
    --section-color-2: #1a2e1a !important;  /* Dark Green */
    --section-color-3: #1a2533 !important;  /* Dark Blue */
    --section-color-4: #2d1a25 !important;  /* Dark Pink */
    --section-color-5: #2d2521 !important;  /* Dark Brown */
    --section-color-6: #1a2d2e !important;  /* Dark Cyan */
    --section-color-7: #2a1a2d !important;  /* Dark Purple */
    --section-color-8: #1f202d !important;  /* Dark Indigo */
}


/* Force text colors for all common elements in dark mode */
html[data-theme="dark"] body,
html[data-theme="dark"] .app-body,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] p,
html[data-theme="dark"] span,
html[data-theme="dark"] div {
    color: var(--text-primary) !important;
}

/* Dark theme comprehensive overrides for app page */
html[data-theme="dark"] .book-content {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .app-nav {
    background: var(--bg-primary) !important;
    border-bottom-color: var(--border-color) !important;
}

html[data-theme="dark"] .column {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .column-header {
    background: var(--bg-primary) !important;
    border-bottom-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .column-header h2 {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .sections-list {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .brand-link {
    color: var(--text-primary) !important;
}

/* Fix chapter item hover in dark mode */
html[data-theme="dark"] .chapter-item:hover,
html[data-theme="dark"] .chapter-header:hover {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Fix save changes modal dark mode */
html[data-theme="dark"] .confirmation-dialog {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
}

html[data-theme="dark"] .dialog-header h3 {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .dialog-content p {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .confirmation-dialog-overlay {
    background: rgba(0, 0, 0, 0.8) !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--app-bg);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

/* App-specific body class */
body.app-body {
    padding: 0;
    overflow: hidden;
    height: 100vh;
    background: var(--app-bg);
}

/* Critical: Apply proper layout class immediately to prevent flash */
body.app-body.layout-ready .main-container {
    opacity: 1;
    transition: opacity 0.3s ease;
}

body.app-body:not(.layout-ready) .main-container {
    opacity: 0;
}

/* App Navigation */
.app-nav {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.app-nav .nav-container {
    max-width: 2000px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.app-nav .nav-brand .brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.6rem; 
    color: var(--text-primary);
    text-decoration: none;
}

.app-nav .brand-icon {
    font-size: 1.8rem;
}

.app-nav .nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* Responsive styles for app navigation */
@media (max-width: 768px) {
    .app-nav .nav-container {
        padding: 0 1rem;
    }
    
    .app-nav .brand-link {
        font-size: 1.1rem;
    }
    
    .app-nav .brand-icon {
        font-size: 1.3rem;
    }
    
    .app-nav .nav-links {
        gap: 1rem;
    }
    
    .theme-toggle-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .app-nav .nav-container {
        height: 50px;
    }
    
    .app-nav .brand-link {
        font-size: 1rem;
    }
    
    .theme-toggle-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .main-container {
        height: calc(100vh - 50px);
        margin: 50px auto 0;
        padding: 10px;
        gap: 10px;
    }
}

/* Main container with responsive layout */
.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    height: calc(100vh - 60px); /* Account for navigation height */
    max-width: 2000px;
    margin: 60px auto 0; /* Top margin for fixed navigation */
    padding: var(--spacing-md);
    box-sizing: border-box;
    overflow: hidden;
}

/* Mobile-first responsive layout - sections below chapters */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: var(--spacing-sm);
    }
    
    .main-container .column:first-child {
        grid-row: 1;
    }
    
    .main-container .column:last-child {
        grid-row: 2;
    }
}

/* Force single column layout for mobile or when explicitly requested */
body.mobile-layout .main-container {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
}

body.mobile-layout .main-container .column:first-child {
    grid-row: 1 !important;
}

body.mobile-layout .main-container .column:last-child {
    grid-row: 2 !important;
}

.column {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.column-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.column-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.column-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    position: relative;
}

/* Book Content Specific Styles */
.book-content {
    font-size: 1.1rem;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    white-space: pre-wrap;
    min-height: 100%;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Sections Panel Specific Styles */
.sections-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    min-height: 100%;
}

/* LAYOUT FIXES: Ensure chapter items are stacked vertically (override any grid layouts) */
.sections-list .chapter-item {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: var(--spacing-md);
    width: 100% !important;
}

/* LAYOUT FIXES: Ensure chapter sections appear below the chapter header (not beside) */
.sections-list .chapter-sections {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    width: 100% !important;
    grid-column: span 1 !important; /* Prevent grid from making this span multiple columns */
    clear: both !important; /* Clear any floats */
    float: none !important; /* Prevent floating */
}

/* Force all section items to stack vertically */
.sections-list .chapter-sections .section-item {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
}

/* LAYOUT FIXES: Ensure section items are properly contained vertically */
.sections-list .section-item {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    margin-bottom: var(--spacing-sm);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes flash-highlight {
    0% { background-color: rgba(255, 255, 0, 0.5); }
    100% { background-color: inherit; }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-light);
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Smart Select Controls */
.smart-select-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 8px;
}

.smart-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#smartSelectChars {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#smartSelectChars:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.smart-select-row label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

#smartSelectBtn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

#smartSelectBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, #45a049, #4CAF50);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

#smartSelectBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#positionIndicator {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--bg-primary);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.reset-btn {
    background: linear-gradient(135deg, #ff9800, #ff7043) !important;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #ff7043, #ff9800) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.4);
}

/* Edit Toggle Button */
.edit-toggle-btn {
    background: linear-gradient(135deg, #2196F3, #1976D2) !important;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.edit-toggle-btn:hover {
    background: linear-gradient(135deg, #1976D2, #2196F3) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

/* Edit Mode Active State */
.edit-toggle-btn.edit-active {
    background: linear-gradient(135deg, #FF5722, #E64A19) !important;
    box-shadow: 0 2px 4px rgba(255, 87, 34, 0.3);
}

.edit-toggle-btn.edit-active:hover {
    background: linear-gradient(135deg, #E64A19, #FF5722) !important;
    box-shadow: 0 4px 8px rgba(255, 87, 34, 0.4);
}

/* Smart Selection Highlight */
.smart-selected-text {
    background-color: rgba(76, 175, 80, 0.2) !important;
    border-left: 3px solid #4CAF50;
    padding-left: 8px;
    animation: smart-select-pulse 0.8s ease-in-out;
    display: inline;
    border-radius: 2px;
}

@keyframes smart-select-pulse {
    0% { background-color: rgba(76, 175, 80, 0.4); }
    50% { background-color: rgba(76, 175, 80, 0.6); }
    100% { background-color: rgba(76, 175, 80, 0.2); }
}

/* User Navigation Styles for App Page */
.app-nav .user-nav {
    position: relative;
    display: flex;
    align-items: center;
}

.app-nav .user-menu {
    position: relative;
}

.app-nav .user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 120px;
}

.app-nav .user-btn:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.app-nav .user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav .user-icon {
    font-size: 16px;
}

.app-nav .dropdown-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.app-nav .user-btn:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.app-nav .user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    min-width: 180px;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    margin-top: 8px;
}

.app-nav .user-dropdown.show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0);
}

.app-nav .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-nav .dropdown-item:hover {
    background-color: var(--bg-secondary);
}

.app-nav .dropdown-item:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.app-nav .dropdown-item:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.app-nav .dropdown-item.logout-btn {
    color: #dc3545;
    border-top: 1px solid #e9ecef;
}

.app-nav .dropdown-item.logout-btn:hover {
    background-color: #f8d7da;
}

.item-icon {
    font-size: 16px;
}

/* User Navigation Responsive */
@media (max-width: 768px) {
    .app-nav .user-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 100px;
    }
    
    .app-nav .user-name {
        max-width: 80px;
    }
}

@media (max-width: 480px) {
    .app-nav .user-dropdown {
        right: -10px;
        min-width: 160px;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.theme-toggle-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.theme-toggle-btn:hover .theme-icon {
    filter: brightness(0) invert(1);
}

.theme-icon {
    transition: transform 0.3s ease;
}

/* Theme toggle icon rotation on hover */
.theme-toggle-btn:hover .theme-icon {
    transform: rotate(180deg);
}

/* Add CSS at the end of the file for download preview styling */

/* Download Preview Section */
.download-preview {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: 6px;
    border-left: 3px solid var(--accent-color);
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.download-preview:hover {
    background-color: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.download-preview .preview-header {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    font-size: 0.95em;
}

.download-preview .preview-header span {
    margin-right: 8px;
    font-size: 1.1em;
}

.download-preview #previewContent {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 4px 0;
}

.download-preview #previewContent strong {
    color: var(--accent-color);
    font-weight: 600;
}

.download-preview #previewContent .error-color {
    color: var(--error-color);
}

/* Export Modal Improvements */
.export-options {
    max-height: none;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    width: 100%;
}

.export-options label {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.export-options > label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background-color: var(--bg-secondary);
    border-radius: 6px;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 0;
    position: relative;
    font-size: 0.875rem;
    width: 100%;
    box-sizing: border-box;
}

.export-options > label:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent-color);
}

.export-options > label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.export-options .option-icon {
    font-size: 16px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.export-options > label:hover .option-icon {
    transform: scale(1.1);
}

.export-options > label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    border-radius: 8px 0 0 8px;
    transition: background-color 0.2s ease;
}

/* Modern browsers with :has() support */
@supports (selector(:has(*))) {
    .export-options > label:has(input:checked)::before {
        background: var(--accent-color);
    }
    
    .export-options > label:has(input:checked) {
        background-color: var(--bg-tertiary);
        border-color: var(--accent-color);
    }
    
    .audio-format-selection > label:has(input:checked) {
        background-color: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
    }
    
    /* Ensure checked state is maintained on hover */
    .audio-format-selection > label:has(input:checked):hover {
        background-color: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
        opacity: 0.9;
    }
}

/* Fallback for browsers without :has() support */
@supports not (selector(:has(*))) {
    .export-options > label.checked::before {
        background: var(--accent-color);
    }
    
    .export-options > label.checked {
        background-color: var(--bg-tertiary);
        border-color: var(--accent-color);
    }
    
    .audio-format-selection > label.checked {
        background-color: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
    }
    
    /* Ensure checked state is maintained on hover for fallback */
    .audio-format-selection > label.checked:hover {
        background-color: var(--accent-color);
        color: white;
        border-color: var(--accent-color);
        opacity: 0.9;
    }
}

.audio-format-selection {
    background-color: var(--bg-tertiary);
    padding: 10px;
    border-radius: 6px;
    margin: 4px 0 8px 28px;
    border: 1.5px solid var(--border-color);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audio-format-selection:hover {
    border-color: var(--accent-color);
}

.audio-format-selection > label:first-of-type {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.audio-format-selection > label:not(:first-of-type) {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background-color: var(--bg-primary);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 0.85em;
}

.audio-format-selection > label:not(:first-of-type):hover:not(:has(input:checked)) {
    background-color: var(--bg-hover);
    border-color: var(--accent-color);
}

/* Fallback for browsers without :has() support */
.audio-format-selection > label:not(:first-of-type):hover:not(.checked) {
    background-color: var(--bg-hover);
    border-color: var(--accent-color);
}

.audio-format-selection input[type="radio"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: white;
}

.silence-duration {
    background-color: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
    margin: 6px 0 0 30px;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.silence-duration:hover {
    border-color: var(--accent-color);
}

.silence-duration label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9em;
}

.silence-duration input[type="number"] {
    width: 70px;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    transition: all 0.2s ease;
}

.silence-duration input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb), 0.1);
}

/* Export Modal Specific Optimizations */
#exportModal .modal {
    max-height: 85vh;
    min-width: 480px;
    max-width: 520px;
    padding: 24px;
}

#exportModal .modal-header {
    padding-bottom: 16px;
    margin-bottom: 20px;
}

#exportModal .modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

#exportModal .modal-body {
    margin-bottom: 20px;
    padding: 0;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

#exportModal .modal-body::-webkit-scrollbar {
    width: 6px;
}

#exportModal .modal-body::-webkit-scrollbar-track {
    background: transparent;
}

#exportModal .modal-body::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 3px;
    opacity: 0.6;
}

#exportModal .modal-body::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

#exportModal .modal-footer {
    padding-top: 16px;
    margin-top: 0;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

/* Export status message styling */
#status {
    color: var(--text-primary);
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-right: 12px;
    min-width: 200px;
    text-align: center;
}

/* Dark mode support for export status */
html[data-theme="dark"] #status {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Force vertical layout for export options */
#exportModal .export-options {
    display: flex !important;
    flex-direction: column !important;
}

#exportModal .export-options > label {
    display: flex !important;
    width: 100% !important;
    margin-bottom: 8px !important;
}

#exportModal .audio-format-selection {
    display: flex !important;
    flex-direction: column !important;
}

#exportModal .audio-format-selection > label:not(:first-of-type) {
    display: flex !important;
    width: 100% !important;
}

/* Export Modal Responsive Design */
@media (max-width: 768px) {
    .export-options > label {
        padding: 12px 14px;
        font-size: 0.9em;
    }
    
    .export-options .option-icon {
        font-size: 16px;
    }
    
    .audio-format-selection,
    .silence-duration {
        margin-left: 20px;
        padding: 12px;
    }
    
    .download-preview {
        padding: 14px;
        margin-top: 20px;
    }
    
    .download-preview .preview-header {
        font-size: 1em;
    }
    
    .download-preview #previewContent {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    .export-options > label {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .audio-format-selection,
    .silence-duration {
        margin-left: 10px;
        padding: 10px;
    }
    
    .audio-format-selection > label:not(:first-of-type) {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

/* Export Modal Specific Optimizations */
#exportModal .modal {
    max-height: 85vh;
    min-width: 480px;
    max-width: 520px;
    padding: 24px;
}

#exportModal .modal-header {
    padding-bottom: 16px;
    margin-bottom: 20px;
}

#exportModal .modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

#exportModal .modal-body {
    margin-bottom: 20px;
    padding: 0;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

#exportModal .modal-body::-webkit-scrollbar {
    width: 6px;
}

#exportModal .modal-body::-webkit-scrollbar-track {
    background: transparent;
}

#exportModal .modal-body::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 3px;
    opacity: 0.6;
}

#exportModal .modal-body::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

#exportModal .modal-footer {
    padding-top: 16px;
    margin-top: 0;
    justify-content: center;
    border-top: 1px solid var(--border-color);
}

/* Ensure modal content fits perfectly */
@media (max-height: 800px) {
    #exportModal .modal {
        max-height: 80vh;
    }
    
    .export-options {
        gap: 10px;
    }
    
    .export-options > label {
        padding: 10px 12px;
    }
    
    .download-preview {
        margin-top: 12px;
        padding: 12px;
    }
}

@media (max-height: 700px) {
    #exportModal .modal {
        max-height: 75vh;
    }
    
    .export-options {
        gap: 8px;
    }
    
    .export-options > label {
        padding: 8px 10px;
        font-size: 0.85em;
    }
    
    .audio-format-selection,
    .silence-duration {
        padding: 10px;
        margin-left: 25px;
    }
    
    .download-preview {
        margin-top: 10px;
        padding: 10px;
    }
    
    .download-preview .preview-header {
        font-size: 0.9em;
        margin-bottom: 6px;
    }
    
    .download-preview #previewContent {
        font-size: 0.8em;
        line-height: 1.3;
    }
}

/* Testing Mode Styles - Apply immediately to prevent loading delays */
body.testing-mode .back-arrow.landing-nav-link,
body.testing-mode .auth-nav-link {
    display: none !important;
}

/* TOC Button - Show immediately with proper styling */
.toc-toggle-btn {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    background: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-left: auto !important;
}

.toc-toggle-btn:hover {
    background: var(--primary-hover) !important;
    color: white !important;
    transform: translateY(-1px) !important;
    box-shadow: var(--shadow-md) !important;
}

/* Exit Button - Show immediately in testing mode */
body.testing-mode .exit-testing-btn {
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-flex !important;
    background: rgba(220, 53, 69, 0.1) !important;
    border: 2px solid #dc3545 !important;
    color: #dc3545 !important;
    font-weight: bold !important;
    padding: 0.6rem 1.2rem !important;
    font-size: 1rem !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
    cursor: pointer;
}

body.testing-mode .exit-testing-btn:hover {
    background: #dc3545 !important;
    color: white !important;
}

/* Keep brand text visible but make it non-clickable */
body.testing-mode .nav-brand .brand-link {
    pointer-events: none;
    cursor: default;
    color: inherit;
    text-decoration: none;
}

body.testing-mode .nav-brand .brand-link:hover {
    text-decoration: none;
    color: inherit;
}

/* Show Early Access Mode badge next to the brand text */
body.testing-mode .app-nav::before {
    content: "⚡ Early Access Mode";
    position: fixed;
    top: 30px; /* Half of nav height (60px) */
    left: 400px; /* Position it after "AudioBook Organizer" text */
    transform: translateY(-50%);
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: bold;
    border: 1px solid rgba(255, 193, 7, 0.3);
    z-index: 1001;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    pointer-events: none; /* Don't interfere with navigation clicks */
}

/* Style for Exit button in testing mode */
body.testing-mode .exit-testing-btn {
    background: rgba(220, 53, 69, 0.1) !important; /* Light red background */
    border: 2px solid #dc3545 !important;
    color: #dc3545 !important;
    font-weight: bold !important;
    padding: 0.6rem 1.2rem !important; /* Larger padding */
    font-size: 1rem !important; /* Larger text */
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
    cursor: pointer;
}

body.testing-mode .exit-testing-btn:hover {
    background: #dc3545 !important;
    color: white !important;
}

/* Exit Testing Modal Styles */
.exit-testing-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.exit-testing-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    padding: 0;
    position: relative;
    animation: slideUp 0.3s ease-out;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.exit-modal-header {
    padding: 24px 24px 16px 24px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

.exit-modal-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.exit-modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #dc3545;
    text-align: center;
}

.exit-modal-body {
    padding: 20px 24px;
    text-align: center;
}

.exit-modal-body p {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
}

.exit-modal-subtitle {
    font-size: 0.95rem !important;
    color: #666 !important;
    font-weight: 400 !important;
    margin-top: 8px !important;
}

.exit-modal-footer {
    padding: 16px 24px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.exit-modal-cancel-btn,
.exit-modal-confirm-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    min-width: 120px;
}

.exit-modal-cancel-btn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e9ecef;
}

.exit-modal-cancel-btn:hover {
    background: #e9ecef;
    color: #333;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.exit-modal-confirm-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: 2px solid #dc3545;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.exit-modal-confirm-btn:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.4);
}

.exit-modal-confirm-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.2);
}

/* Modal animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive design for mobile */
@media (max-width: 480px) {
    .exit-testing-modal {
        width: 95%;
        margin: 20px;
    }
    
    .exit-modal-header {
        padding: 20px 16px 12px 16px;
    }
    
    .exit-modal-body {
        padding: 16px;
    }
    
    .exit-modal-footer {
        padding: 12px 16px 20px 16px;
        flex-direction: column;
    }
    
    .exit-modal-cancel-btn,
    .exit-modal-confirm-btn {
        width: 100%;
        min-width: auto;
    }
}

/* Header styles */
header {
    background-color: var(--background-color-light);
    color: var(--text-color);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1001; /* Ensure header is above content but below modals/sidebars */
}

/* Main content styles */
main {
    padding: 20px;
}

/* Credits Display Styles */
.credits-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    margin-right: 0; /* Remove any conflicting margins */
}

/* Ensure consistent spacing between credits and user nav */
.nav-links .credits-display + .user-nav,
.nav-links .credits-display + .user-menu {
    margin-left: 0.75rem;
}

/* User Navigation positioned after credits */
.nav-links .user-nav {
    margin-left: 0.75rem; /* Default spacing when following credits */
}

.credits-display:hover {
    background: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Ensure all text inside credits display is white on hover */
.credits-display:hover,
.credits-display:hover .credits-icon,
.credits-display:hover .credits-value,
.credits-display:hover .credits-label {
    color: white !important;
}

.credits-display.low-credits {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
    animation: pulse-warning 2s infinite;
}

.credits-display.low-credits:hover {
    background: #f39c12;
    color: white;
}

/* Dark mode support for low credits display */
html[data-theme="dark"] .credits-display.low-credits {
    background: rgba(255, 193, 7, 0.2) !important;
    border-color: #ffc107 !important;
    color: #ffc107 !important;
}

html[data-theme="dark"] .credits-display.low-credits:hover {
    background: rgba(255, 193, 7, 0.3) !important;
    color: #ffffff !important;
}

.credits-icon {
    font-size: 1.1rem;
}

.credits-value {
    font-weight: 700;
    min-width: 2rem;
    text-align: center;
}

.credits-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

.emoji {
    color: initial;
    font-style: normal;
  }

@keyframes pulse-warning {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Low Credits Modal Styles */
.low-credits-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: fixed;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-primary);
    padding: 1.25rem; /* Reduced padding to save space */
    padding-bottom: 1rem;
    border-radius: 16px;
    width: fit-content; /* Fit content width */
    max-width: 95vw; /* Prevent overflow on small screens */
    min-width: 750px; /* Increased minimum width for 2x2 grid */
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    position: relative;
    animation: modalFadeZoom 0.3s ease-out;
    display: flex;
    flex-direction: column;
    margin: 0; /* Remove margin since parent handles centering */
}

/* Center the modal description text */
.modal-content h2 {
    text-align: center;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(102, 126, 234, 0.1);
}

/* Center the description paragraph */
.modal-content p {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.modal-content ul {
    margin: 0.5rem 0 1rem 0; /* Reduced margins */
    padding-left: 0;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 0.6rem; /* Reduced gap */
    max-width: 100%;
    margin-left: 0; /* Align to left instead of center */
    margin-right: auto;
    justify-items: start; /* Align items to the left */
}

.modal-content li {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align content to the left */
    padding: 0.8rem 1rem; /* Reduced padding */
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    flex-shrink: 0;
    height: 45px; /* Reduced height for more compact design */
    text-align: left; /* Left align text */
}

.modal-content li:hover {
    background: rgba(102, 126, 234, 0.06);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.15);
}

/* Loading spinner for credit purchase content */
#creditPurchaseContent .loading-packages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

#creditPurchaseContent .loading-packages .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* Stripe UI elements in modal - Enhanced horizontal layout */
#creditPurchaseContent .credit-purchase-section {
    margin: 0;
    padding: 0; /* Remove padding to maximize space */
    background: transparent;
    box-shadow: none;
}

#creditPurchaseContent .credit-packages {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 0;
    padding: 0;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

#creditPurchaseContent .package-card {
    margin-bottom: 0;
    flex-direction: column;
    justify-content: space-between;
    max-width: 260px;
    margin: 0 auto;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    padding-top: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-height: 320px;
}

#creditPurchaseContent .package-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.15);
    border-color: var(--primary-color);
}

#creditPurchaseContent .package-card.popular {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(102, 126, 234, 0.03) 100%);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.1);
}

#creditPurchaseContent .package-card.popular:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(102, 126, 234, 0.2);
}

#creditPurchaseContent .package-card.enterprise {
    border-color: #6b7280;
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(107, 114, 128, 0.05) 100%);
}

#creditPurchaseContent .package-card.enterprise:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border-color: #4b5563;
}

#creditPurchaseContent .package-card .popular-badge {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    white-space: nowrap;
}

#creditPurchaseContent .package-card .best-value-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    white-space: nowrap;
}

#creditPurchaseContent .package-header {
    text-align: center;
    margin-bottom: 1rem;
}

#creditPurchaseContent .package-header h4 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

#creditPurchaseContent .package-price .price {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

#creditPurchaseContent .package-price .credits {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 500;
}

#creditPurchaseContent .package-value {
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 8px;
    padding: 0.6rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

#creditPurchaseContent .package-button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.25);
    margin-top: auto; /* Push button to bottom */
}

#creditPurchaseContent .package-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
}

#creditPurchaseContent .purchase-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03), rgba(118, 75, 162, 0.03));
    border: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    margin-top: 0.8rem;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

#creditPurchaseContent .info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

#creditPurchaseContent .info-item .icon {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Error and alert states in modal */
#creditPurchaseContent .stripe-unavailable {
    margin: 1rem 0;
}

#creditPurchaseContent .alert {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

#creditPurchaseContent .alert-info {
    background: rgba(103, 126, 234, 0.1);
    border: 1px solid rgba(103, 126, 234, 0.2);
    color: var(--text-primary);
}

#creditPurchaseContent .alert-warning {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.2);
    color: var(--text-primary);
}

#creditPurchaseContent .alert-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

#creditPurchaseContent .alert-content h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

#creditPurchaseContent .alert-content p {
    margin: 0;
    color: var(--text-secondary);
}

/* Modal button container for centered buttons */
.modal-button-container {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

@keyframes modalFadeZoom {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Modal content styles are defined above in the duplicate section */

/* Fix emoji colors in modal list items */
.modal-content li::before {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: initial !important;
    -webkit-text-fill-color: initial !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
}

/* Ensure emojis within list items maintain their natural colors */
.modal-content li span:first-child,
.modal-content li:first-child {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: initial !important;
    -webkit-text-fill-color: initial !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
}

/* Comprehensive emoji color fix for all emoji characters */
.modal-content li {
    /* Reset any gradient or color inheritance that affects emojis */
    background-image: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
}

.modal-content li::first-letter {
    color: initial !important;
    -webkit-text-fill-color: initial !important;
    background: none !important;
    -webkit-background-clip: initial !important;
    background-clip: initial !important;
}

.credits-purchase-preview {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.credits-purchase-preview h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.credit-package {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-secondary);
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--text-primary);
}

/* Responsive adjustments for enhanced modal */
@media (max-width: 1200px) {
    #creditPurchaseContent .credit-packages {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    #creditPurchaseContent .package-card {
        min-height: 280px;
        max-width: none;
    }
    
    .modal-content {
        padding: 1.25rem;
    }
    
    .modal-content ul {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .credits-display {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .modal-content,
    .low-credits-modal .modal-content {
        margin: 0;
        padding: 1.5rem;
        width: 95%;
        max-width: 100%;
        min-width: 350px;
    }
    
    .modal-content h2 {
        font-size: 1.4rem;
    }
    
    #creditPurchaseContent .credit-packages {
        grid-template-columns: 1fr;
        gap: 1rem;
        max-width: 350px;
    }
    
    #creditPurchaseContent .package-card {
        min-height: auto;
        max-width: none;
        padding: 1.25rem;
    }
    
    .modal-content ul {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
        gap: 0.75rem;
        justify-items: stretch;
    }
    
    .modal-content li {
        font-size: 0.9rem;
        padding: 0.8rem 1rem;
        white-space: normal;
        text-align: left; /* Keep left alignment on mobile too */
        justify-content: flex-start; /* Align content to the left */
        width: 100%;
        height: 50px; /* Consistent height on mobile */
    }
    
    .credits-purchase-preview {
        padding: 1rem;
    }
    
    .modal-button-container {
        margin-top: 1rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 0;
        padding: 1rem;
        width: 95%;
        max-height: 98vh;
        min-width: 300px;
    }
    
    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 0.75rem;
    }
    
    .modal-content ul {
        margin: 0.75rem 0 1.5rem 0;
        gap: 0.5rem;
    }
    
    .modal-content li {
        font-size: 0.85rem;
        padding: 0.7rem 0.9rem;
        border-radius: 10px;
    }
    
    #creditPurchaseContent .section-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    #creditPurchaseContent .section-header h3 {
        font-size: 1.3rem;
    }
}

/* Enhanced modal header section */
#creditPurchaseContent .section-header {
    text-align: center;
    margin-bottom: 0.8rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}

#creditPurchaseContent .section-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 1px;
}

#creditPurchaseContent .section-header h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

#creditPurchaseContent .section-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    font-weight: 500;
    line-height: 1.4;
}

/* Emoji styling fixes - prevent color inheritance */
#creditPurchaseContent .info-item .icon {
    font-size: 1rem;
    flex-shrink: 0;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    color: initial !important; /* Prevent color inheritance */
    -webkit-text-fill-color: initial !important; /* Reset webkit text fill */
    background: none !important; /* Remove any background */
    -webkit-background-clip: initial !important; /* Reset background clip */
    background-clip: initial !important;
}

#creditPurchaseContent .section-header .emoji {
    font-size: 1.5rem;         /* Make it big enough to match h3 */
    line-height: 1;          /* Avoid vertical misalignment */
    margin-right: 0.4rem;    /* Space between emoji and heading */
    vertical-align: middle;  /* Align better with text */
    transform: translateY(-8px);
  }

  #lowCreditsModal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6); /* optional backdrop */
    z-index: 9999;
  }
  
  #lowCreditsModal .modal-content {
    /* cancel out the translate centering */
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
  
    /* optional, to let auto-margins center it in a flex container */
    margin: auto;
  }


  /* force consistent emoji sizing in low-credits modal */
#lowCreditsModal .modal-content ul li .emoji {
    display: inline-block !important;
    font-size: 1.25rem !important;
    line-height: 1 !important;
    margin-right: 0.75rem !important;
    flex-shrink: 0 !important;
  }

/* Ensure all credit modal list items have consistent styling */
#lowCreditsModal .modal-content ul li {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    font-weight: 500 !important;
    opacity: 1 !important;
}

/* Dark mode support for credit modal list items */
html[data-theme="dark"] #lowCreditsModal .modal-content ul li {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Ensure hover states are consistent */
#lowCreditsModal .modal-content ul li:hover {
    background: rgba(102, 126, 234, 0.06) !important;
    border-color: var(--primary-color) !important;
    transform: translateY(-1px) !important;
}

/* ============================================================================
   APPLICATION INITIALIZATION STATES
   ============================================================================ */

/* Hide potential duplicate navigation during app initialization */
body.app-initializing .nav-links {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* Prevent interaction during initialization */
body.app-initializing .user-nav {
    pointer-events: none;
}

/* Show loading state during initialization */
body.app-initializing::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9998;
    pointer-events: all;
}



/* Fully ready state */
body.app-ready .nav-links {
    opacity: 1;
    transition: opacity 0.3s ease;
}

body.app-ready .user-nav {
    pointer-events: all;
}

/* Error state */
body.app-error .nav-links {
    opacity: 0.7;
}

/* Dark mode support for initialization states */
[data-theme="dark"] body.app-initializing::before {
    background: rgba(45, 55, 72, 0.8);
}