/* Modern Clean Web App Design System - V3.0 */
:root {
    /* Color Palette - Neutral & Professional */
    --bg-body: #f5f7fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    
    --text-primary: #1a1a1a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    
    --primary-color: #3b82f6; /* Blue 500 */
    --primary-hover: #2563eb; /* Blue 600 */
    --primary-light: #eff6ff; /* Blue 50 */
    
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    
    --border-color: #e2e8f0;
    
    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 64px;
    --container-max-width: 1400px;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
}

/* Dark Mode Support (Optional base) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0f172a;
        --bg-sidebar: #1e293b;
        --bg-card: #1e293b;
        --bg-header: #1e293b;
        
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --text-tertiary: #64748b;
        
        --border-color: #334155;
    }
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Layout Structure */
.app-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.brand i {
    margin-right: 10px;
    font-size: 24px;
}

.nav-menu {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.nav-category {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-sm);
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
}

.top-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-xl);
    flex-shrink: 0;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.search-wrapper {
    position: relative;
    width: 300px;
}

.search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition-fast);
}

.search-input:focus {
    border-color: var(--primary-color);
    background-color: var(--bg-header);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    font-size: 14px;
}

/* Scrollable Content */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
}

/* Cards & Grids */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.card-cover-wrapper {
    position: relative;
    width: 100%;
    padding-top: 140%; /* 1:1.4 aspect ratio */
    background-color: #f1f5f9;
    overflow: hidden;
}

.card-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.card:hover .card-cover {
    transform: scale(1.05);
}

.card-body {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Detail Page */
.detail-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.detail-cover {
    width: 100%;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.detail-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 var(--spacing-sm) 0;
    line-height: 1.3;
}

.detail-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 14px;
}

.detail-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--spacing-lg);
}

.tag {
    background-color: var(--bg-body);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.action-bar {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
    border-bottom: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--bg-body);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: #fee2e2;
    color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #fecaca;
}

/* Progress Bar */
.progress-wrapper {
    width: 100%;
    background-color: var(--bg-body);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: var(--spacing-sm);
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background-color: var(--bg-card);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    color: var(--text-tertiary);
}

/* Reader Specific Styles */
.reader-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #1a1a1a; /* Dark background for reading */
    color: #ffffff;
}

.reader-header {
    height: 50px;
    background-color: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #333;
    z-index: 100;
}

.reader-title {
    font-size: 14px;
    font-weight: 500;
    color: #e0e0e0;
}

.reader-viewport {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Start from top */
    padding: 20px;
    cursor: default;
    background-color: #121212;
}

.reader-image-container {
    max-width: 100%;
    transition: transform 0.2s ease;
}

.reader-image {
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.reader-controls {
    height: 60px;
    background-color: #2a2a2a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-top: 1px solid #333;
    padding: 0 20px;
    z-index: 100;
}

.reader-btn {
    background: transparent;
    border: 1px solid #444;
    color: #e0e0e0;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.reader-btn:hover {
    background-color: #333;
    border-color: #666;
}

.reader-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.page-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 300px;
}

.page-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: #444;
    border-radius: 2px;
    outline: none;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.chapter-select {
    background-color: #333;
    color: #e0e0e0;
    border: 1px solid #444;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .brand {
        justify-content: space-between;
        padding-right: var(--spacing-lg);
    }
    
    .nav-menu {
        display: none;
        background: var(--bg-sidebar);
        padding: var(--spacing-md);
        border-top: 1px solid var(--border-color);
        max-height: 60vh; /* Limit height */
        overflow-y: auto;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.mobile-open .nav-menu {
        display: block;
        animation: slideDown 0.2s ease-out;
    }
    
    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    
    .detail-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .detail-cover {
        max-width: 200px;
        margin: 0 auto;
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); /* Smaller cards for mobile */
        gap: var(--spacing-md);
    }
    
    .card-title {
        font-size: 14px;
    }
    
    .top-header {
        padding: 0 var(--spacing-md);
    }
    
    .search-wrapper {
        width: 100%;
        max-width: 200px;
    }
    
    /* Hide non-essential elements on mobile if needed */
    .header-actions .btn {
        padding: 0 8px;
    }

    /* Mobile Scrolling Fix: Enable natural document scroll */
    body {
        height: auto !important;
        overflow-y: auto !important;
        display: block !important;
    }

    .app-layout, .main-wrapper {
        height: auto !important;
        display: block !important;
        overflow: visible !important;
    }

    .content-area {
        height: auto !important;
        overflow: visible !important;
        padding: var(--spacing-md);
    }
}
/ *   M o b i l e   M e n u   B u t t o n   * / 
 
 . m o b i l e - m e n u - b t n   { 
 
         d i s p l a y :   n o n e ; 
 
         b a c k g r o u n d :   t r a n s p a r e n t ; 
 
         b o r d e r :   n o n e ; 
 
         c o l o r :   v a r ( - - t e x t - p r i m a r y ) ; 
 
         f o n t - s i z e :   2 0 p x ; 
 
         c u r s o r :   p o i n t e r ; 
 
         p a d d i n g :   8 p x ; 
 
 } 
 
 
 
 @ m e d i a   ( m a x - w i d t h :   7 6 8 p x )   { 
 
         . m o b i l e - m e n u - b t n   { 
 
                 d i s p l a y :   b l o c k ; 
 
         } 
 
 } 
 
 