/**
 * BookShelf - Professional Ebook Reader Styles
 * Version 6.0 - Modern, Sophisticated Design
 * ORIGINAL MOBILE + DESKTOP ENHANCEMENTS ONLY
 */

/* ============================================================================
   IMPORTS & FONTS
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================================
   CSS VARIABLES - Professional Color System
   ============================================================================ */

:root {
    /* Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --bg-elevated: #ffffff;
    
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-tertiary: #a1a1aa;
    
    --border-subtle: #f4f4f5;
    --border-default: #e4e4e7;
    --border-strong: #d4d4d8;
    
    --accent-50: #faf5ff;
    --accent-100: #f3e8ff;
    --accent-500: #a855f7;
    --accent-600: #9333ea;
    --accent-700: #7e22ce;
    
    --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-default: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xlarge: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.dark {
    /* Dark Mode */
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-elevated: #18181b;
    
    --text-primary: #fafafa;
    --text-secondary: #d4d4d8;
    --text-tertiary: #71717a;
    
    --border-subtle: #27272a;
    --border-default: #3f3f46;
    --border-strong: #52525b;
    
    --accent-400: #c084fc;
    --accent-500: #a855f7;
    --accent-600: #9333ea;
    
    --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-default: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.5);
    --shadow-xlarge: 0 20px 25px -5px rgba(0, 0, 0, 0.7), 0 10px 10px -5px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   GLOBAL RESET & BASE STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    font-size: 16px;
}

/* ============================================================================
   HEADER - Professional Design
   ============================================================================ */

header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dark header {
    background: rgba(9, 9, 11, 0.8);
}

.header-container {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Logo Area */
.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
    box-shadow: var(--shadow-medium);
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.logo-text p {
    font-size: 0.813rem;
    color: var(--text-tertiary);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Theme Toggle */
#theme-toggle {
    width: 64px;
    height: 36px;
    border-radius: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

#theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--border-strong);
}

#theme-toggle .toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-default);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark #theme-toggle .toggle-slider {
    transform: translateX(28px);
    background: var(--accent-600);
}

/* Search Form */
.search-container {
    margin-bottom: 1.5rem;
}

.search-form-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper svg {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    height: 52px;
    padding: 0 1.25rem 0 3.5rem;
    border: 1px solid var(--border-default);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 400;
    transition: all 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 4px var(--accent-50);
}

.dark #searchInput:focus {
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.1);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

.search-controls {
    display: flex;
    gap: 1rem;
}

.search-select {
    flex: 1;
    height: 52px;
    padding: 0 1.25rem;
    border: 1px solid var(--border-default);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-select:hover {
    border-color: var(--border-strong);
}

.search-select:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 4px var(--accent-50);
}

.dark .search-select:focus {
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.1);
}

.search-button {
    height: 52px;
    padding: 0 2.5rem;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-default);
    white-space: nowrap;
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.search-button:active {
    transform: translateY(0);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.sort-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.sort-controls select {
    height: 44px;
    padding: 0 1.125rem;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.938rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-controls select:hover {
    border-color: var(--border-strong);
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px var(--accent-50);
}

.dark .sort-controls select:focus {
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.upload-button {
    height: 40px;
    padding: 0 1.25rem;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-default);
}

.upload-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.upload-button:active {
    transform: translateY(0);
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.content-wrapper {
    background: var(--bg-elevated);
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    padding: 3rem;
    box-shadow: var(--shadow-subtle);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.book-count {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    background: var(--accent-50);
    color: var(--accent-700);
    border-radius: 100px;
    font-size: 0.938rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.dark .book-count {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-400);
}

/* ============================================================================
   BOOK GRID - Professional Layout
   ============================================================================ */

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 2rem;
}

@media (min-width: 640px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 3rem;
    }
}

@media (min-width: 1280px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 3rem;
    }
}

@media (min-width: 1536px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        gap: 3.5rem;
    }
}

/* Book Card */
.book-card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.book-card:hover .book-cover-wrapper {
    transform: translateY(-12px);
}

.book-card:hover .book-cover {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(168, 85, 247, 0.1);
}

.book-card:active .book-cover-wrapper {
    transform: translateY(-6px);
}

/* Book Cover */
.book-cover-wrapper {
    position: relative;
    margin-bottom: 1.25rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    box-shadow: 
        0 10px 25px -5px rgba(0, 0, 0, 0.15),
        0 8px 10px -6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.book-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.book-cover-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
}

.book-cover-loading svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Book Overlay */
.book-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
}

.book-card:hover .book-overlay {
    opacity: 1;
}

.book-overlay svg {
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* Book Info */
.book-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.book-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
    min-height: 2.8rem;
}

.book-author {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.book-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--accent-50);
    color: var(--accent-700);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: -0.01em;
}

.book-download:hover {
    background: var(--accent-100);
    transform: translateY(-2px);
    box-shadow: var(--shadow-default);
}

.dark .book-download {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-400);
}

.dark .book-download:hover {
    background: rgba(168, 85, 247, 0.15);
}

@media (min-width: 1024px) {
    .book-title {
        font-size: 1.063rem;
    }
    
    .book-author {
        font-size: 0.938rem;
    }
    
    .book-download {
        font-size: 0.938rem;
        padding: 0.75rem 1.125rem;
    }
}

/* ============================================================================
   EMPTY STATE - Professional Design
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 5rem 2rem;
}

.empty-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto 2rem;
    background: var(--accent-50);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark .empty-icon {
    background: rgba(168, 85, 247, 0.1);
}

.empty-icon svg {
    color: var(--accent-600);
}

.dark .empty-icon svg {
    color: var(--accent-400);
}

.empty-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.empty-description {
    font-size: 1.063rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.empty-action {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-medium);
}

.empty-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

/* ============================================================================
   PAGINATION - Modern Design
   ============================================================================ */

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.625rem;
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--border-subtle);
}

.pagination a,
.pagination span {
    min-width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border-radius: 10px;
    font-size: 0.938rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination a {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.pagination a:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-500);
    transform: translateY(-1px);
}

.pagination span {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white;
    border: none;
    box-shadow: var(--shadow-default);
}

/* ============================================================================
   AUTOCOMPLETE - Professional Overlay
   ============================================================================ */

#autocomplete-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#autocomplete-backdrop.active {
    opacity: 1;
}

#autocomplete-suggestions {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    box-shadow: var(--shadow-xlarge);
    z-index: 101;
    display: none;
}

@media (min-width: 768px) {
    #autocomplete-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        transform: none;
        margin-top: 0.5rem;
        max-height: 400px;
    }
}

#autocomplete-suggestions li {
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.938rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}

#autocomplete-suggestions li:last-child {
    border-bottom: none;
}

#autocomplete-suggestions li:hover {
    background: var(--bg-tertiary);
}

#autocomplete-suggestions li:active {
    background: var(--bg-secondary);
}

/* ============================================================================
   EPUB READER
   ============================================================================ */

#reader {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 100;
    display: none;
    flex-direction: column;
}

#epub-viewer {
    flex: 1;
    background: var(--bg-primary);
    overflow: hidden;
}

#epub-viewer iframe {
    border: none;
    width: 100%;
    height: 100%;
}

#reader-controls {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-default);
    padding: 1.25rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.reader-controls-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.reader-btn {
    height: 44px;
    padding: 0 1.5rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.reader-btn-primary {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
    color: white;
    box-shadow: var(--shadow-default);
}

.reader-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.reader-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.reader-btn-secondary:hover {
    background: var(--bg-secondary);
}

.reader-btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    box-shadow: var(--shadow-default);
}

.reader-btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.reader-btn:active {
    transform: translateY(0);
}

/* ============================================================================
   MOBILE OPTIMIZATIONS - COMPACT HEADER
   ============================================================================ */

@media (max-width: 768px) {
    /* Ultra-compact header for mobile */
    .header-container {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .header-top {
        margin-bottom: 0.75rem;
    }
    
    /* Smaller logo on mobile */
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    .logo-text h1 {
        font-size: 1.125rem;
    }
    
    .logo-text p {
        display: none;
    }
    
    /* Compact theme toggle */
    #theme-toggle {
        width: 48px;
        height: 28px;
        border-radius: 14px;
    }
    
    #theme-toggle .toggle-slider {
        width: 20px;
        height: 20px;
        top: 3px;
        left: 3px;
    }
    
    .dark #theme-toggle .toggle-slider {
        transform: translateX(20px);
    }
    
    #theme-toggle svg {
        width: 0.875rem;
        height: 0.875rem;
    }
    
    /* Compact search form */
    .search-container {
        margin-bottom: 0.625rem;
    }
    
    .search-form-inner {
        gap: 0.5rem;
    }
    
    .search-input-wrapper svg {
        width: 1rem;
        height: 1rem;
        left: 0.875rem;
    }
    
    #searchInput {
        height: 40px;
        padding: 0 0.875rem 0 2.5rem;
        font-size: 0.875rem;
        border-radius: 10px;
    }
    
    .search-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .search-select {
        height: 40px;
        padding: 0 0.875rem;
        font-size: 0.875rem;
        border-radius: 10px;
    }
    
    .search-button {
        height: 40px;
        padding: 0 1.5rem;
        font-size: 0.875rem;
        border-radius: 10px;
    }
    
    /* Compact controls bar */
    .controls-bar {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .sort-controls {
        flex: 1;
        gap: 0.5rem;
        min-width: 0;
    }
    
    .sort-controls select {
        height: 36px;
        padding: 0 0.75rem;
        font-size: 0.813rem;
        border-radius: 8px;
        flex: 1;
        min-width: 0;
    }
    
    .upload-button {
        height: 36px;
        padding: 0 1rem;
        font-size: 0.813rem;
        border-radius: 8px;
        flex-shrink: 0;
    }
    
    .upload-button svg {
        width: 1rem;
        height: 1rem;
    }
    
    /* Hide thumbnail link text on mobile */
    .thumbnails-link-text {
        display: none;
    }
    
    /* Compact main content */
    main {
        padding: 1rem;
    }
    
    .content-wrapper {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .section-header {
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    
    .section-title {
        font-size: 1.125rem;
        flex: 1;
    }
    
    .book-count {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .book-grid {
        gap: 1rem;
    }
    
    .pagination {
        flex-wrap: wrap;
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
}

@media (max-width: 480px) {
    /* Even more compact on small phones */
    .header-container {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }
    
    .header-top {
        margin-bottom: 0.625rem;
    }
    
    .logo-container {
        gap: 0.5rem;
    }
    
    .logo-icon {
        width: 28px;
        height: 28px;
        font-size: 0.938rem;
    }
    
    .logo-text h1 {
        font-size: 1rem;
    }
    
    .search-container {
        margin-bottom: 0.5rem;
    }
    
    #searchInput {
        height: 38px;
        font-size: 0.813rem;
    }
    
    .search-select,
    .search-button {
        height: 38px;
        font-size: 0.813rem;
    }
    
    .controls-bar {
        gap: 0.5rem;
    }
    
    .sort-controls select {
        height: 34px;
        font-size: 0.75rem;
    }
    
    .upload-button {
        height: 34px;
        padding: 0 0.875rem;
        font-size: 0.75rem;
        width: 100%;
        justify-content: center;
    }
    
    main {
        padding: 0.75rem;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .section-header {
        margin-bottom: 1rem;
    }
    
    .section-title {
        font-size: 1rem;
    }
    
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.875rem;
    }
    
    .book-title {
        font-size: 0.875rem;
    }
    
    .book-author {
        font-size: 0.75rem;
    }
    
    .book-download {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .reader-controls-inner {
        gap: 0.5rem;
    }
    
    .reader-btn {
        height: 40px;
        padding: 0 1rem;
        font-size: 0.813rem;
    }
    
    .reader-btn svg {
        width: 1rem;
        height: 1rem;
    }
}

/* ============================================================================
   DESKTOP ENHANCEMENTS ONLY (1280px+)
   ============================================================================ */

@media (min-width: 1280px) {
    /* Centered Logo Layout */
    .header-top {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
    }
    
    .logo-container {
        grid-column: 2;
        justify-content: center;
    }
    
    #theme-toggle {
        grid-column: 3;
        justify-self: end;
        width: 72px;
        height: 40px;
        border-radius: 20px;
    }
    
    #theme-toggle .toggle-slider {
        width: 30px;
        height: 30px;
        top: 4px;
        left: 4px;
    }
    
    .dark #theme-toggle .toggle-slider {
        transform: translateX(32px);
    }
    
    .logo-icon {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
        border-radius: 14px;
        position: relative;
    }
    
    /* Glowing effect on logo */
    .logo-icon::after {
        content: '';
        position: absolute;
        inset: -3px;
        background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
        border-radius: 17px;
        opacity: 0.15;
        filter: blur(12px);
        z-index: -1;
    }
    
    .logo-text h1 {
        font-size: 2rem;
        font-weight: 800;
        letter-spacing: -0.04em;
    }
    
    /* Enhanced hover effects on cards */
    .book-card::before {
        content: '';
        position: absolute;
        inset: -1rem;
        background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
        border-radius: 24px;
        opacity: 0;
        filter: blur(30px);
        transition: opacity 0.4s ease;
        z-index: -1;
    }
    
    .book-card:hover::before {
        opacity: 0.15;
    }
    
    .book-card:hover {
        transform: translateY(-16px) scale(1.02);
    }
    
    .book-card:hover .book-cover-wrapper {
        transform: none;
    }
    
    .book-card:hover .book-cover {
        box-shadow: 
            0 32px 64px -12px rgba(0, 0, 0, 0.35),
            0 0 0 1px var(--accent-500);
    }
    
    /* Enhanced overlay effect */
    .book-overlay {
        background: linear-gradient(135deg, rgba(168, 85, 247, 0.9) 0%, rgba(126, 34, 206, 0.9) 100%);
    }
    
    .book-overlay svg {
        transform: scale(0.9);
        transition: transform 0.3s ease;
    }
    
    .book-card:hover .book-overlay svg {
        transform: scale(1);
    }
    
    /* Larger section titles */
    .section-title {
        font-size: 2.5rem;
        font-weight: 800;
    }
    
    .section-header {
        margin-bottom: 4rem;
        padding-bottom: 2rem;
    }
    
    .book-count {
        padding: 0.75rem 1.5rem;
        font-size: 1.063rem;
        font-weight: 700;
        border: 2px solid var(--accent-100);
    }
    
    .dark .book-count {
        border-color: rgba(168, 85, 247, 0.2);
    }
    
    /* Enhanced empty state */
    .empty-icon {
        width: 120px;
        height: 120px;
        border-radius: 30px;
        position: relative;
    }
    
    .empty-icon::after {
        content: '';
        position: absolute;
        inset: -4px;
        background: linear-gradient(135deg, var(--accent-600), var(--accent-700));
        border-radius: 34px;
        opacity: 0.15;
        filter: blur(20px);
        z-index: -1;
    }
    
    .empty-icon svg {
        width: 60px;
        height: 60px;
    }
    
    .empty-title {
        font-size: 2rem;
        font-weight: 800;
    }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-card {
    animation: fadeIn 0.4s ease-out backwards;
}

.book-card:nth-child(1) { animation-delay: 0.05s; }
.book-card:nth-child(2) { animation-delay: 0.1s; }
.book-card:nth-child(3) { animation-delay: 0.15s; }
.book-card:nth-child(4) { animation-delay: 0.2s; }
.book-card:nth-child(5) { animation-delay: 0.25s; }
.book-card:nth-child(6) { animation-delay: 0.3s; }

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

*:focus-visible {
    outline: 2px solid var(--accent-500);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

::selection {
    background-color: var(--accent-500);
    color: white;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
}