:root {
    --bg-dark: #0a0a0f;
    --bg-card: rgba(20, 20, 28, 0.7);
    --bg-card-hover: rgba(30, 30, 42, 0.9);
    --text-main: #f0f0f5;
    --text-muted: #9494a0;
    --accent-primary: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.5);
    --accent-secondary: #ec4899;
    
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Ambient Background Blobs */
.ambient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.4;
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 10%) scale(1.1); }
}

/* Typography */
h1, h2, h3, h4, .logo {
    font-family: var(--font-heading);
    font-weight: 700;
}

.logo {
    font-size: 1.8rem;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo span {
    color: var(--accent-primary);
}

.logo i {
    color: var(--accent-secondary);
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Navbar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.nav-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-main);
}

.search-bar {
    flex: 1;
    max-width: 600px;
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.mobile-nav-toggles {
    display: none;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.menu-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.mobile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    min-width: 180px;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 200;
}

.mobile-dropdown.show {
    display: flex;
    animation: fadeIn 0.2s ease-out forwards;
}

.mobile-dropdown a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.1rem;
}

.search-bar input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 0.8rem 1.2rem 0.8rem 3rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition);
}

.search-bar input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* Hero */
.hero {
    text-align: center;
    padding: 5rem 0 3rem;
}

.hero h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, #a5a5b4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Filters */
.filters-section {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}

.filter-group {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-group select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239494a0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.filter-group select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

/* Stats */
.stats-bar {
    margin-bottom: 2rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 5rem;
}

.book-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    text-decoration: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    backdrop-filter: blur(10px);
}

.book-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-glow);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(99, 102, 241, 0.2);
    background: var(--bg-card-hover);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.5);
}

.book-cover-fallback {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0,0,0,0.8) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--glass-border);
    font-size: 3rem;
    color: var(--glass-border);
}

.book-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.tag.class {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.tag.subject {
    background: rgba(236, 72, 153, 0.15);
    color: #f9a8d4;
    border: 1px solid rgba(236, 72, 153, 0.3);
}

.book-title {
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    flex: 1;
}

.download-btn {
    width: 100%;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--text-main);
    color: var(--bg-dark);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.book-card:hover .download-btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 2rem;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-dark);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow-y: auto;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-backdrop.active .modal-content {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .modal-body {
        flex-direction: row;
    }
}

.modal-cover {
    width: 100%;
    max-width: 350px;
    object-fit: cover;
    background: rgba(0,0,0,0.5);
}

.modal-info {
    padding: 3rem 2rem;
    flex: 1;
}

.modal-info h2 {
    font-size: 2rem;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.modal-info p.desc {
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.8;
}

.meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.meta-item span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.meta-item strong {
    font-weight: 500;
    color: var(--text-main);
}

.modal-info .download-btn {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: 50px;
}

.modal-info .download-btn:hover {
    box-shadow: 0 8px 25px var(--accent-glow);
    transform: translateY(-2px);
}

/* Loading */
.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 0;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 1rem;
        padding: 0 1rem;
        align-items: center;
    }
    
    .mobile-nav-toggles {
        display: flex;
        gap: 1.5rem;
        align-items: center;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .nav-right {
        display: none;
    }
    
    .nav-right.show-search {
        display: block;
        width: 100%;
        flex: 1 1 100%;
        margin-top: 0.5rem;
    }
    
    .nav-right .nav-link {
        display: none; /* Never show the About link in the dropdown area on mobile */
    }
    
    .search-bar {
        width: 100%;
        max-width: none;
        display: block;
    }
    
    .search-bar input {
        width: 100%;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .modal-cover {
        max-width: 100%;
        height: 300px;
    }
    
    .meta-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Detail Page Specific Styles --- */
.back-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.back-btn:hover {
    color: var(--text-main);
    transform: translateX(-3px);
}

.book-page-container {
    padding-top: 3rem;
    padding-bottom: 5rem;
}

.book-detail-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
}

@media (min-width: 900px) {
    .book-detail-layout {
        grid-template-columns: 350px 1fr;
        padding: 3rem;
    }
}

.book-detail-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    border: 1px solid var(--glass-border);
}

.action-card {
    margin-top: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.cta-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    transition: var(--transition);
}

.cta-btn:hover {
    box-shadow: 0 8px 25px var(--accent-glow);
    transform: translateY(-2px);
}

.disclaimer {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    text-align: center;
}

.book-detail-main h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fff 0%, #a5a5b4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.book-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.book-description h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.book-description p {
    color: var(--text-muted);
    line-height: 1.8;
    font-size: 1.05rem;
}

/* --- Community Popup Styles --- */
.community-modal {
    background: #151515;
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.community-modal .close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.community-modal .close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.modal-icon {
    font-size: 3.5rem;
    color: #22d3ee;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 15px rgba(34, 211, 238, 0.4));
}

.community-modal h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.modal-subtitle {
    color: #9ca3af;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.social-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 16px;
    text-decoration: none;
    margin-bottom: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.social-btn:hover {
    transform: translateY(-2px);
}

.social-icon {
    font-size: 1.8rem;
    color: white;
    margin-right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.social-text {
    text-align: left;
    flex-grow: 1;
}

.social-text strong {
    display: block;
    color: white;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    margin-bottom: 0.2rem;
}

.social-text span {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

.arrow-icon {
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
}

.whatsapp-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.3);
}

.telegram-btn {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    box-shadow: 0 10px 25px rgba(56, 189, 248, 0.3);
}

.modal-footer {
    margin-top: 2rem;
    color: #4b5563;
    font-size: 0.8rem;
    font-weight: 500;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
/* Viewer Modal Styles */
.viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 15, 0.98);
    z-index: 9999;
    display: none; /* Hidden by default */
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.viewer-modal.active {
    display: flex;
}

.viewer-header {
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.viewer-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.viewer-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.viewer-page-counter {
    color: var(--text-muted);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.viewer-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-close-btn:hover {
    color: #ef4444;
    transform: scale(1.1);
}

.viewer-body {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 2rem;
}

.viewer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

.viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: var(--transition);
    z-index: 10;
}

.viewer-nav-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.viewer-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
}

.viewer-prev-btn { left: 2rem; }
.viewer-next-btn { right: 2rem; }

.viewer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--accent-primary);
    font-size: 2rem;
    z-index: 5;
}

.viewer-loading p {
    font-size: 1rem;
    color: var(--text-muted);
    font-family: var(--font-body);
}

