/* ============================================
   OmniReads — Library Page Styles
   ============================================ */

/* --- Language Switcher --- */
.lang-switcher {
    position: relative;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-toggle:hover,
.lang-toggle.active {
    background: var(--bg-glass-hover);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.lang-current {
    min-width: 20px;
    text-align: center;
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: rgba(15, 15, 28, 0.98);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 9999;
    animation: dropdownIn 0.2s ease;
}

.lang-switcher.open .lang-dropdown {
    display: block;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lang-option {
    display: block;
    width: 100%;
    padding: 11px 18px;
    text-align: left;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.lang-option.active {
    color: var(--accent-primary);
    background: rgba(255, 107, 53, 0.1);
}

/* RTL support */
[dir="rtl"] .lang-option {
    text-align: right;
}

[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

/* Compact version for reader */
.lang-switcher-compact .lang-toggle {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.lang-switcher-compact .lang-dropdown {
    min-width: 140px;
}

.lang-switcher-compact .lang-option {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.lang-dropdown-left {
    right: auto;
    left: 0;
}

/* --- Library Hero --- */
.library-hero {
    padding: var(--page-hero-space-top) 0 var(--page-hero-space-bottom);
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.library-hero::before {
    content: "";
    position: absolute;
    top: -200px;
    right: -100px;
    width: 600px;
    height: 600px;
    background: radial-gradient(
        ellipse,
        rgba(255, 107, 53, 0.1) 0%,
        transparent 70%
    );
    pointer-events: none;
}

.library-hero::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
}

.library-hero-content h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.library-hero-content p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 500px;
}

/* --- Filter Bar --- */
.library-filters {
    padding: var(--section-space-y-tight) 0 var(--space-lg);
    position: sticky;
    top: var(--nav-height);
    z-index: 90;
    background: rgba(10, 10, 18, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.filter-search {
    flex: 1;
    min-width: 240px;
    position: relative;
}

.filter-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    color: var(--text-muted);
}

.filter-search input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.filter-search input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-glass-hover);
}

.filter-search input::placeholder {
    color: var(--text-muted);
}

.filter-controls {
    display: flex;
    gap: var(--space-md);
}

.filter-select-wrap {
    position: relative;
}

.filter-select-wrap::after {
    content: "▾";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

.filter-select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    padding: 12px 40px 12px 18px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-select-wrap select:focus,
.filter-select-wrap select:hover {
    border-color: var(--accent-primary);
    background: var(--bg-glass-hover);
}

.filter-select-wrap select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.lib-count {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding-top: var(--space-md);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.lib-count strong {
    color: var(--accent-primary);
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-tag {
    padding: 6px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-tag:hover,
.quick-tag.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* --- Library Grid --- */
.library-grid-section {
    padding: var(--section-space-y) 0;
}

/* --- No Results --- */
.lib-no-results {
    text-align: center;
    padding: var(--section-space-y) 0;
    color: var(--text-secondary);
}

.lib-no-results-icon {
    display: block;
    font-size: 3rem;
    margin-bottom: var(--space-lg);
}

.lib-no-results p {
    font-size: 1.05rem;
}

/* --- Load More --- */
.lib-load-more {
    text-align: center;
    margin-top: var(--space-3xl);
}

/* ============================================
   DETAIL PAGE
   ============================================ */
.detail-hero {
    padding: var(--page-hero-space-top) 0 var(--page-hero-space-bottom);
    background: var(--bg-secondary);
    position: relative;
}

.detail-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 80% 20%, rgba(255, 107, 53, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.detail-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-3xl);
    align-items: start;
}

.detail-cover {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
}

.detail-cover img {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

.detail-info {
    padding-top: var(--space-md);
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-md);
}

.detail-tag {
    padding: 4px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.detail-tag.genre {
    background: rgba(255, 107, 53, 0.15);
    border-color: rgba(255, 107, 53, 0.3);
    color: var(--accent-primary);
}

.detail-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    line-height: 1.2;
}

.detail-chinese-name {
    font-family: var(--font-chinese);
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xl);
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.detail-meta-item {
    text-align: center;
    min-width: 80px;
}

.detail-meta-item .value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.detail-meta-item .value.status-ongoing {
    color: #22c55e;
}

.detail-meta-item .meta-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.detail-actions {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.detail-schedule {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
    width: fit-content;
}

.detail-schedule strong {
    color: var(--text-primary);
}

/* --- Synopsis --- */
.detail-synopsis {
    padding: var(--section-space-y) 0;
}

.detail-synopsis h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
}

.synopsis-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--text-secondary);
    max-width: 800px;
}

.synopsis-content p {
    margin-bottom: var(--space-md);
}

.synopsis-content strong {
    color: var(--text-primary);
}

.synopsis-content em {
    color: var(--accent-primary);
    font-style: normal;
}

/* --- Tags Section --- */
.detail-tags-section {
    margin-top: var(--space-3xl);
}

.detail-tags-section h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-item {
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.tag-item:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* --- Chapter List --- */
.chapter-list {
    padding: var(--section-space-y) 0;
    background: var(--bg-secondary);
}

.chapter-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.chapter-list-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
}

.chapter-list-controls {
    display: flex;
    gap: var(--space-sm);
}

.chapter-sort-btn {
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.chapter-sort-btn.active,
.chapter-sort-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.chapters {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chapter-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.chapter-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-accent);
    transform: translateX(4px);
}

.chapter-main {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.chapter-number {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 60px;
}

.chapter-title {
    font-size: 1rem;
    color: var(--text-primary);
}

.chapter-side {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.chapter-tag {
    padding: 3px 10px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
}

.chapter-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.chapter-check {
    width: 24px;
    height: 24px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.chapter-item.read .chapter-title {
    color: var(--text-muted);
}

.chapter-item.latest {
    background: rgba(255, 107, 53, 0.05);
    border-color: rgba(255, 107, 53, 0.2);
}

.chapter-list-more {
    text-align: center;
    margin-top: var(--space-xl);
}

/* --- Related Novels --- */
.related-novels {
    padding: var(--section-space-y) 0;
}

/* ============================================
   NAVBAR COMPONENTS
   ============================================ */
.nav-search-bar {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    max-width: 480px;
    margin: 0 auto;
}

.nav-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    transition: all var(--transition-smooth);
    width: 100%;
}

.nav-search-input-wrap:focus-within {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-primary);
}

.nav-search-icon-sm {
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.nav-search-field {
    background: transparent !important;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.nav-search-field::placeholder {
    color: var(--text-muted);
}

/* Quick results dropdown */
.nav-quick-results {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(15, 15, 26, 0.98);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    backdrop-filter: blur(24px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    overflow: hidden;
    animation: dropdownIn 0.18s ease;
}

.nav-quick-results.visible {
    display: block;
}

/* Quick result items */
.nqr-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.nqr-item:hover {
    background: rgba(255, 107, 53, 0.08);
}

.nqr-cover {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.nqr-info {
    flex: 1;
    min-width: 0;
}

.nqr-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nqr-genre {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.nqr-more {
    display: block;
    padding: 12px 16px;
    text-align: center;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--transition-fast);
}

.nqr-more:hover {
    background: rgba(255, 107, 53, 0.1);
}

.nqr-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.nqr-empty em {
    color: var(--text-primary);
    font-style: normal;
}

/* Category dropdown */
.cat-wrap {
    position: relative;
}

.cat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.cat-btn:hover,
.cat-wrap:hover .cat-btn,
.cat-wrap.open .cat-btn {
    background: var(--bg-glass-hover);
    border-color: var(--border-accent);
    color: var(--accent-primary);
}

.cat-chevron {
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
    color: var(--text-muted);
}

.cat-wrap.open .cat-chevron {
    transform: rotate(180deg);
}

.cat-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background: rgba(15, 15, 28, 0.98);
    border: 1px solid rgba(255, 107, 53, 0.2);
    border-top: 2px solid var(--accent-primary);
    border-radius: 16px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 0 30px rgba(255, 107, 53, 0.1);
    z-index: 9998;
    animation: dropdownIn 0.25s ease;
    overflow: hidden;
    padding: 8px 0;
}

.cat-dropdown::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
    background: transparent;
}

.cat-wrap.open .cat-dropdown {
    display: block;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cat-section-label {
    padding: 12px 20px 8px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    border-radius: 8px;
    margin: 2px 8px;
}

.cat-item:last-of-type {
    border-bottom: none;
}

.cat-item:hover {
    background: rgba(255, 107, 53, 0.1);
    color: var(--text-primary);
}

.cat-item .ci {
    width: 24px;
    height: 24px;
    text-align: center;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.cat-genres {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.cat-genre {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 10px;
    text-align: center;
    transition: all var(--transition-fast);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}

.cat-genre:hover {
    background: rgba(255, 107, 53, 0.1);
    border-color: rgba(255, 107, 53, 0.3);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

.cat-genre-icon {
    font-size: 1.6rem;
    line-height: 1;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .detail-layout {
        grid-template-columns: 220px 1fr;
        gap: var(--space-2xl);
    }
}

@media (max-width: 768px) {
    .nav-search-bar {
        display: none;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-search {
        min-width: 100%;
    }

    .filter-controls {
        width: 100%;
        justify-content: stretch;
    }

    .filter-select-wrap {
        flex: 1;
    }

    .filter-select-wrap select {
        width: 100%;
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .detail-cover {
        max-width: 240px;
        margin: 0 auto;
    }

    .detail-info {
        text-align: center;
    }

    .detail-tags {
        justify-content: center;
    }

    .detail-meta {
        justify-content: center;
    }

    .detail-actions {
        justify-content: center;
    }

    .detail-schedule {
        margin: 0 auto;
    }

    .chapter-list-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chapter-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .chapter-side {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .lib-count {
        flex-direction: column;
        align-items: flex-start;
    }

    .quick-tags {
        width: 100%;
    }

    .detail-meta {
        gap: var(--space-md);
    }

    .detail-meta-item {
        min-width: 70px;
    }

    .detail-meta-item .value {
        font-size: 1.1rem;
    }
}
