/* Main Layout & Aesthetic */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Header */
.site-header {
    height: var(--header-height);
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -1px;
}

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

.main-navigation ul {
    display: flex;
    list-style: none;
    gap: 30px;
}

.main-navigation a {
    font-weight: 600;
    font-size: 15px;
    text-transform: uppercase;
}

.main-navigation a:hover {
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 20px;
    align-items: center;
}

.header-actions i {
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.header-actions i:hover {
    color: var(--primary-color);
}

/* Hero Slider */
.hero-slider-section {
    padding: 40px 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--primary-color);
}

.hero-slider {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.slider-item {
    height: 350px;
    border-radius: var(--border-radius);
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    padding: 20px;
}

.slider-content {
    position: relative;
    z-index: 2;
}

.slider-content h3 {
    font-size: 18px;
    margin: 5px 0 10px;
}

.manga-genre {
    font-size: 12px;
    background: var(--primary-color);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Manga Grid & Cards */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 25px;
}

.manga-card {
    background: var(--surface-dark);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.3s ease;
}

.manga-card:hover {
    transform: translateY(-5px);
}

.manga-card-thumb {
    position: relative;
    aspect-ratio: 3/4;
    overflow: hidden;
}

.manga-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.manga-card:hover .manga-card-thumb img {
    transform: scale(1.1);
}

.thumb-overlays {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.pushpin-icon {
    font-size: 18px;
    color: var(--primary-color);
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.verified-icon {
    color: #3498db;
    font-size: 16px;
    vertical-align: middle;
    margin-left: 5px;
}

/* Chapter Pills */
.chapter-pill {
    background: var(--surface-lighter);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    transition: var(--transition);
}

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

.chapter-pill:hover * {
    color: #fff;
}

/* Manga Tabs */
.manga-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 12px 25px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 700;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Ranking Widget */
.ranking-widget {
    background: var(--surface-dark);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
}

.widget-title {
    font-size: 16px;
    margin-bottom: 15px;
}

.ranking-header {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.rank-badge {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
}

.rank-badge.gold { background: rgba(241, 196, 15, 0.2); color: #f1c40f; border: 1px solid #f1c40f; }
.rank-badge.blue { background: rgba(52, 152, 219, 0.2); color: #3498db; border: 1px solid #3498db; }

/* Chapter Controls Bar */
.chapter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.chapter-search {
    display: flex;
    align-items: center;
    background: var(--surface-lighter);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
    flex: 1;
    min-width: 150px;
}

.chapter-search i {
    color: var(--text-muted);
    font-size: 16px;
    margin-right: 6px;
}

.chapter-search input {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 8px 0;
    width: 100%;
    font-size: 13px;
    outline: none;
}

.sort-toggle {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.sort-btn {
    background: var(--surface-lighter);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sort-btn i {
    font-size: 14px;
}

.sort-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.sort-btn:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Chapter Grid (Multi-column) */
.chapter-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 16px;
}

.chapter-grid-item {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface-lighter);
    border-radius: 6px;
    text-decoration: none !important;
    color: var(--text-main);
    font-size: 13px;
    transition: all 0.2s ease;
    overflow: hidden;
    border: 1px solid transparent;
    gap: 8px;
    min-height: 40px;
    box-sizing: border-box;
}

.chapter-grid-item:hover {
    background: rgba(255, 61, 90, 0.08);
    border-color: rgba(255, 61, 90, 0.2);
    color: var(--primary-color);
}

.cg-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    font-weight: 500;
    display: inline-block;
}

.cg-date {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
    display: inline-block;
}

/* Pagination */
.chapter-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pag-btn {
    background: var(--surface-lighter);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pag-btn:hover:not([disabled]):not(.active) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pag-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.pag-btn[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

.pag-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 10px;
}

/* Responsive: 3 columns on large */
@media screen and (min-width: 1024px) {
    .chapter-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile: 1 column */
@media screen and (max-width: 768px) {
    .chapter-grid {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
    }
    .chapter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .sort-toggle {
        justify-content: center;
    }
    .chapter-grid-item {
        padding: 10px 14px !important;
        font-size: 14px !important;
        min-height: 44px !important;
        border-bottom: 1px solid var(--border-color);
        border-radius: 0 !important;
        background: transparent !important;
    }
    .chapter-grid-item:hover {
        background: rgba(255, 61, 90, 0.05) !important;
    }
    .cg-date {
        font-size: 12px;
    }
}


/* Footer & Back to Top */
.footer-search {
    margin-top: 20px;
    position: relative;
    max-width: 300px;
}

.footer-search input {
    width: 100%;
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    padding: 10px 40px 10px 15px;
    border-radius: 25px;
    color: #fff;
}

.footer-search button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    opacity: 0.8;
    transition: var(--transition);
}

.back-to-top:hover {
    opacity: 1;
    transform: translateY(-5px);
}

/* Novel Reader Core */
.reader-container { 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    transition: background-color 0.3s ease, color 0.3s ease;
    padding-bottom: 60px; /* space for fixed footer nav */
}
.reader-container.theme-light { background: #ffffff; color: #1a1a1a; }
.reader-container.theme-sepia { background: #f8f1e3; color: #4a3728; }
.reader-container.theme-dark { background: #121212; color: #d8d8d8; }

/* ===== Compact Top Bar ===== */
.reader-topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    height: 50px;
}

.topbar-inner {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 12px;
}

.topbar-back {
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    padding: 6px;
    flex-shrink: 0;
}
.topbar-back:hover { color: var(--primary-color); }

.topbar-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-novel-name {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-chapter-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-settings-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.topbar-settings-btn:hover,
.topbar-settings-btn.active {
    background: var(--primary-color);
}

/* ===== Settings Drawer ===== */
.settings-drawer {
    position: fixed;
    bottom: 60px; /* above footer nav */
    left: 0;
    right: 0;
    z-index: 180;
    background: rgba(20, 20, 20, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: #fff;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px 16px 0 0;
    max-height: 60vh;
    overflow-y: auto;
}

.settings-drawer.open {
    transform: translateY(0);
}

.settings-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 170;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.settings-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.settings-drawer-inner {
    padding: 20px 20px 16px;
}

.drawer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.drawer-row:last-child { border-bottom: none; }

.drawer-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    flex-shrink: 0;
}

.drawer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-btn {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    width: 42px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.drawer-btn:hover { background: rgba(255,255,255,0.2); }
.drawer-btn:active { transform: scale(0.95); }

.drawer-value {
    min-width: 45px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary-color);
}

.drawer-select {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    -webkit-appearance: none;
}
.drawer-select option { background: #1a1a1a; color: #fff; }

/* Theme selector buttons in drawer */
.theme-controls {
    gap: 6px;
}

.theme-controls .theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.15);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 52px;
    height: 34px;
}

.theme-controls .theme-btn.theme-white {
    background: #fff;
    color: #333;
}
.theme-controls .theme-btn.theme-sepia {
    background: #f4ecd8;
    color: #5b4636;
}
.theme-controls .theme-btn.theme-dark {
    background: #1a1a1a;
    color: #d1d1d1;
}
.theme-controls .theme-btn.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

/* ===== Reading Area ===== */
.reader-area { 
    flex: 1; 
    padding: 24px 0 40px; 
}

.reader-header { 
    text-align: center; 
    margin-bottom: 30px; 
    padding-bottom: 20px; 
    border-bottom: 1px solid rgba(128,128,128,0.15);
}

.chapter-title { 
    font-size: 1.5rem; 
    font-weight: 700; 
    line-height: 1.4; 
    margin-bottom: 10px;
}

.reader-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 13px;
    color: inherit;
    opacity: 0.6;
}

.reader-meta i {
    font-size: 14px;
    vertical-align: middle;
    margin-right: 3px;
}

.chapter-content { 
    line-height: 2.0; 
    letter-spacing: 0.02em; 
}
.chapter-content p { 
    margin-bottom: 24px; 
}
.chapter-content.font-serif { font-family: 'Georgia', 'Times New Roman', serif; }
.chapter-content.font-sans-serif { font-family: 'Inter', sans-serif; }

/* Theme-specific content colors */
.reader-container.theme-light .chapter-content { color: #1a1a1a; }
.reader-container.theme-sepia .chapter-content { color: #4a3728; }
.reader-container.theme-dark .chapter-content { color: #d8d8d8; }

.reader-container.theme-light .reader-area { background-color: #ffffff; }
.reader-container.theme-sepia .reader-area { background-color: #f8f1e3; }
.reader-container.theme-dark .reader-area { background-color: #121212; }

.reader-container.theme-light .reader-header { border-bottom-color: rgba(0,0,0,0.1); }
.reader-container.theme-sepia .reader-header { border-bottom-color: rgba(91,70,54,0.15); }
.reader-container.theme-dark .reader-header { border-bottom-color: rgba(255,255,255,0.08); }

/* Paragraph hover - desktop only */
.novel-para { position: relative; transition: 0.2s; }

/* Font Families */
.font-serif { font-family: 'Georgia', 'Times New Roman', serif; }
.font-sans-serif { font-family: 'Inter', sans-serif; }

/* Novel Specific UI */
.vip-tag { background: #f1c40f; color: #000; padding: 2px 6px; font-size: 10px; font-weight: bold; border-radius: 4px; margin-left: 10px; vertical-align: middle; }

.paywall-content i {
    font-size: 64px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.paywall-content h2 {
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 15px;
}

.paywall-content p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.paywall-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Ad Placeholders */
.ad-placeholder {
    transition: opacity 0.3s ease;
}

.ad-placeholder:hover {
    opacity: 0.7;
}

/* Reader Tweaks */
.container-narrow {
    max-width: 800px;
}


/* Page Template Adjustments */
.vip-upgrade-page .alert-success {
    color: #fff;
    font-weight: 600;
    text-align: center;
}

/* Reader */
.reader-nav-bar {
    background: var(--surface-dark);
    height: 60px;
    display: flex;
    align-items: center;
}

.nav-bar-inner {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.chapter-images img {
    margin: 0 auto;
    display: block;
    width: 100%;
}

/* LIGHT MODE OVERRIDES */
body.light-mode {
    --background-dark: var(--bg-light);
    --surface-dark: var(--surface-light);
    --text-main: var(--text-light);
    --border-color: #ddd;
    --text-muted: var(--text-muted-light);
}

body.light-mode .site-header {
    background: rgba(255, 255, 255, 0.9);
}

body.light-mode .manga-card {
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* Mobile Optimizations */
@media screen and (max-width: 768px) {
    /* Homepage Hero Slider Fix - Horizontal Scroll */
    .hero-slider {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        gap: 15px;
        grid-template-columns: none !important; /* Force override of the grid */
        padding-bottom: 20px;
        -webkit-overflow-scrolling: touch;
        margin: 0 -20px;
        padding: 0 20px 20px;
    }
    .slider-item {
        flex: 0 0 85% !important;
        min-width: 280px;
        height: 180px !important;
        scroll-snap-align: start;
        border-radius: 12px;
    }
    .slider-content {
        padding: 15px !important;
    }
    .slider-content h3 { font-size: 1.1rem !important; }
    .slider-content p { display: none !important; }
    .slider-content .btn { font-size: 12px; padding: 5px 15px; }

    /* Reader Toolbar Fix - Compact Height */
    .reader-settings-bar {
        position: fixed !important;
        top: 60px !important; /* Move it up slightly if header is smaller */
        padding: 8px 0 !important;
        background: rgba(26, 26, 26, 0.98) !important;
    }
    .settings-inner {
        gap: 5px !important;
        justify-content: space-around !important;
        flex-wrap: nowrap !important;
    }
    .setting-group {
        gap: 10px !important;
        flex: none !important;
        justify-content: center !important;
    }
    .setting-label {
        display: none !important; /* Hide "Cỡ chữ", "Phông chữ" to save space */
    }
    .setting-item {
        gap: 5px !important;
    }
    .setting-item button {
        padding: 6px 12px !important;
        font-size: 13px !important;
        min-width: 35px;
    }
    .theme-btn {
        width: 28px !important;
        height: 28px !important;
    }
    .size-val {
        min-width: 35px !important;
        font-size: 13px !important;
    }
    
    /* Layout Adjustments */
    .reader-area {
        padding-top: 100px !important; /* Account for fixed bar */
    }
    .chapter-title {
        font-size: 1.4rem !important;
        margin-bottom: 5px !important;
    }
}

/* Bookmark Button States */
.btn-bookmark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.btn-bookmark span {
    font-size: 13px;
}

.btn-bookmark.bookmarked {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
}

.btn-bookmark.bookmarked i {
    color: #fff !important;
}

.btn-bookmark:hover {
    transform: scale(1.05);
}

/* Continue Reading Button */
.novel-actions .btn .dashicons-controls-play {
    font-size: 18px;
    vertical-align: middle;
    margin-right: 4px;
}
