:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #f39c12;
    --text-color: #333;
    --text-muted: #666;
    --bg-body: #f4f4f4;
    --bg-content: #ffffff;
    --header-bg: #1c3552;
    --nav-header-mobile-bg: #1c3552;
    --border-color: #ddd;
    --link-hover: #2980b9;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --radius: 4px;
    --container-width: 1200px;
    --spacing: 15px;
}

[data-theme="dark"] {
    --primary-color: #3498db;
    --secondary-color: #ecf0f1;
    --text-color: #e0e0e0;
    --text-muted: #aaa;
    --bg-body: #121212;
    --bg-content: #1e1e1e;
    --header-bg: #0f2033;
    --nav-header-mobile-bg: #ecf0f1;
    --border-color: #333;
    --link-hover: #5dade2;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto Condensed', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 15px;
    transition: background-color 0.3s, color 0.3s;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

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

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Layout */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--spacing);
    width: 100%;
}

/* Header */
header {
    background-color: var(--header-bg);
    color: #fff;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

header .container {
    height: 100%;
}

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

.logo {
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.logo:hover {
    color: #f0f0f0;
}

.main-nav {
    display: flex;
    gap: 20px;
    margin-left: 30px;
}

.nav-item {
    position: relative;
    cursor: pointer;
    padding: 10px 0;
    font-weight: 500;
    font-size: 14px;
}

.nav-item:hover .dropdown {
    display: block;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-content);
    color: var(--text-color);
    min-width: 200px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--primary-color);
    z-index: 100;
}

.dropdown a {
    display: block;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
}

.dropdown a:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.dropdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 5px;
    min-width: 300px;
}

/* Search & Tools */
.header-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-form {
    display: flex;
}

.search-input {
    padding: 6px 10px;
    border: none;
    outline: none;
    border-radius: var(--radius) 0 0 var(--radius);
    width: 200px;
}

.search-btn {
    background: var(--accent-color);
    border: none;
    color: #fff;
    padding: 0 12px;
    cursor: pointer;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.theme-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
}

/* Sub Header */
.sub-header {
    background: #e0e0e0;
    padding: 8px 0;
    font-size: 12px;
    text-align: center;
    color: #555;
    border-bottom: 1px solid #ccc;
}

[data-theme="dark"] .sub-header {
    background: #222;
    border-color: #444;
    color: #999;
}

/* Main Content */
main {
    padding: 20px 0;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.title-text {
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-filter {
    padding: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-content);
    color: var(--text-color);
    cursor: pointer;
}

/* Grid Novels (Home) */
.novel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (min-width: 576px) {
    .novel-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    .novel-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 992px) {
    .novel-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

.novel-card {
    position: relative;
    background: var(--bg-content);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    overflow: hidden;
}

.novel-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.card-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 30px 10px 10px;
}

.card-title {
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 1px 1px 2px #000;
}

.badge {
    position: absolute;
    top: 0;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
}

.badge-hot {
    left: 0;
    background: var(--danger-color);
}

.badge-full {
    right: 0;
    background: var(--success-color);
}

/* Layout Grid (Main + Sidebar) */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
    margin-top: 30px;
}

@media (min-width: 992px) {
    .layout-grid {
        grid-template-columns: 3fr 1fr;
    }
}

/* Table List (Latest Updates) */
.box {
    background: var(--bg-content);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.table tr:last-child {
    border-bottom: none;
}

.table tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.table td {
    padding: 10px;
    vertical-align: middle;
}

.table-thumb {
    width: 50px;
    height: 75px;
    object-fit: cover;
}

.novel-link {
    font-weight: bold;
    color: var(--secondary-color);
    display: block;
    margin-bottom: 3px;
}

.novel-link:hover {
    color: var(--primary-color);
}

.chapter-link {
    color: var(--primary-color);
}

.text-muted {
    color: var(--text-muted);
    font-size: 12px;
}

.text-right {
    text-align: right;
}

.hidden-mobile {
    display: none;
}

@media (min-width: 576px) {
    .hidden-mobile {
        display: table-cell;
    }
}

/* Sidebar Widgets */
.widget {
    background: var(--bg-content);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.widget-header {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    text-transform: uppercase;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-body {
    padding: 15px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.history-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 13px;
}

.top-item {
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.top-item:last-child {
    border: none;
    margin: 0;
}

.top-number {
    width: 24px;
    height: 24px;
    background: #bdc3c7;
    color: #666;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    font-weight: bold;
    font-size: 12px;
}

.top-1 {
    background: var(--danger-color);
    color: #fff;
}

.top-2 {
    background: var(--success-color);
    color: #fff;
}

.top-3 {
    background: var(--primary-color);
    color: #fff;
}

/* Novel Detail */
.breadcrumb {
    padding: 10px var(--spacing);
    background: var(--bg-content);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-color);
}

.breadcrumb .sep {
    margin: 0 5px;
}

.novel-info-block {
    display: flex;
    gap: 20px;
    flex-direction: column;
}

@media(min-width: 768px) {
    .novel-info-block {
        flex-direction: row;
    }
}

.novel-cover-img {
    width: 220px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    align-self: center;
}

.novel-meta {
    flex: 1;
    text-align: center;
}

@media(min-width: 768px) {
    .novel-meta {
        text-align: left;
    }
}

.novel-title-lg {
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.meta-row {
    margin-bottom: 8px;
    font-size: 14px;
}

.meta-label {
    font-weight: 600;
    color: var(--text-muted);
    width: 100px;
    display: inline-block;
}

.meta-value a {
    color: var(--primary-color);
}

.rating-stars {
    color: #f1c40f;
    font-size: 18px;
    margin: 10px 0;
}

.action-btns {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

@media(min-width: 768px) {
    .action-btns {
        justify-content: flex-start;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 20px;
    border-radius: 20px;
    color: #fff;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

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

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

.novel-desc {
    max-height: 200px;
    overflow: hidden;
    position: relative;
    line-height: 1.6;
    text-align: justify;
}

.novel-desc.expanded {
    max-height: none;
}

.desc-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: linear-gradient(transparent, var(--bg-content));
}

.chapter-list-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    font-size: 14px;
}

@media(min-width: 768px) {
    .chapter-list-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.chapter-item {
    border-bottom: 1px dashed var(--border-color);
    padding: 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.paging {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.page-link {
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-content);
    color: var(--text-color);
}

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

/* Footer */
footer {
    background: var(--bg-content);
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
    padding: 30px 0;
    text-align: center;
    color: var(--text-muted);
}

.social-links {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 20px;
}

/* Reader Styles */
.reader-container {
    max-width: 900px;
    margin: 0 auto;
    background: #f4f4e4;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 40px;
    color: #333;
}

[data-theme="dark"] .reader-container {
    background: #1f2937;
    color: #d1d5db;
}

.reader-header {
    text-align: center;
    margin-bottom: 30px;
}

.reader-novel-title {
    font-size: 24px;
    color: var(--success-color);
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 10px;
}

.reader-chapter-title {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: normal;
}

.reader-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 10px;
}

.chapter-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.btn-nav {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    background: #27ae60;
    color: white;
    border-radius: 4px;
    font-size: 14px;
}

.btn-nav:hover {
    background: #219150;
    color: white;
}

.btn-nav.disabled {
    background: #ccc;
    pointer-events: none;
}

.chapter-content {
    font-size: 18px;
    line-height: 1.8;
    text-align: justify;
    margin-bottom: 40px;
    font-family: 'Roboto Condensed', sans-serif;
}

.chapter-content p {
    margin-bottom: 15px;
}

.reader-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

.btn-warning {
    background: #f39c12;
    color: #fff;
}

.btn-info {
    background: #3498db;
    color: #fff;
}

.text-primary {
    color: var(--primary-color) !important;
}

.font-bold {
    font-weight: bold;
}

/* Mobile Menu Styles */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    margin-right: 10px;
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.nav-overlay.active {
    display: block;
}

.nav-header-mobile {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.close-menu-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
}

/* Responsive Logic */
@media (max-width: 991px) {
    .mobile-menu-btn {
        display: block;
    }

    .logo-text {
        display: none;
    }

    /* Hide text on small screens if overly crowded, or keep */

    .main-nav {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100%;
        background: var(--bg-content);
        color: var(--text-color);
        flex-direction: column;
        z-index: 1002;
        transition: left 0.3s ease;
        padding: 0;
        margin-left: 0;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }

    .main-nav.active {
        left: 0;
    }

    .nav-header-mobile {
        display: flex;
    }

    .nav-item {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-item>a,
    .nav-item>span.nav-link-mobile {
        display: block;
        /* Ensure full click area */
        padding: 15px;
        color: var(--text-color);
        font-weight: bold;
    }

    .dropdown {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(0, 0, 0, 0.03);
        display: none;
        width: 100%;
    }

    .dropdown.active,
    .nav-item:hover .dropdown {
        display: block;
    }

    /* Use simple hover or add JS for click */
    .dropdown-grid {
        grid-template-columns: 1fr;
    }

    /* .search-input {
        width: 120px;
    } */

}

@media (min-width: 576px) {
    .logo-text {
        display: inline;
    }

    .search-input {
        width: 200px;
    }
}

.nav-header-mobile .logo {
    color: var(--nav-header-mobile-bg);
}