/* assets/css/main.css */

/* ─── Variables ─────────────────────────────── */
:root {
    --primary:       #e8222e;
    --primary-dark:  #c01920;
    --primary-light: #ffeced;
    --accent:        #ff6b35;
    --text:          #1a1a2e;
    --text-muted:    #6b7280;
    --bg:            #f3f4f6;
    --surface:       #ffffff;
    --border:        #e5e7eb;
    --radius:        8px;
    --radius-lg:     14px;
    --shadow:        0 2px 12px rgba(0,0,0,.08);
    --shadow-hover:  0 8px 28px rgba(0,0,0,.14);
    --font:          'Be Vietnam Pro', Arial, sans-serif;
    --transition:    .2s ease;
}

/* ─── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}
img { display: block; max-width: 100%; height: auto; }
a  { color: inherit; text-decoration: none; }
button, select { font-family: inherit; }

/* ─── Container ──────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ─── Header ─────────────────────────────────── */
.site-header {
    background: var(--surface);
    border-bottom: 3px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
    flex-wrap: wrap;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 22px;
    color: var(--primary);
    white-space: nowrap;
}
.logo-icon { font-size: 26px; }

/* ─── Nav ────────────────────────────────────── */
.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}
.main-nav > a, .main-nav .dropbtn {
    padding: 7px 13px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}
.main-nav > a:hover, .main-nav .dropbtn:hover, .dropdown:hover .dropbtn {
    background: var(--primary-light);
    color: var(--primary);
}

/* Dropdown */
.dropdown { position: relative; }
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;           /* sát ngay dưới, không có gap */
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,.14);
    min-width: 560px;
    padding: 10px;
    padding-top: 14px;   /* bù lại phần bridge */
    z-index: 200;
    column-count: 3;
    column-gap: 0;
}
/* Bridge vô hình lấp khoảng hở giữa nút và dropdown */
.dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;        /* phủ khoảng trống */
    background: transparent;
}
.dropdown:hover .dropbtn { background: var(--primary-light); color: var(--primary); }
/* dropdown shown/hidden via JS */
.dropdown-content a {
    display: block;
    padding: 7px 14px;
    font-size: 13.5px;
    break-inside: avoid;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.dropdown-content a:hover { background: var(--primary-light); color: var(--primary); }

/* ─── Search form ────────────────────────────── */
.search-form {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 50px;
    overflow: hidden;
    transition: border-color var(--transition);
}
.search-form:focus-within { border-color: var(--primary); }
.search-form input {
    flex: 1;
    padding: 8px 16px;
    background: none;
    border: none;
    outline: none;
    font-size: 14px;
    min-width: 0;
}
.search-form button {
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
}
.search-form button:hover { background: var(--primary-dark); }

/* Mobile hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

/* ─── Main content ───────────────────────────── */
.site-main { min-height: 70vh; padding: 0; }

/* ─── Section title ──────────────────────────── */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}
.section-title small { font-size: 14px; font-weight: 400; color: var(--text-muted); }

/* ─── Comic grid ─────────────────────────────── */
.comic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 18px;
}
.comic-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}
.comic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.comic-thumb {
    display: block;
    position: relative;
    overflow: hidden;
    aspect-ratio: 2/3;
}
.comic-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}
.comic-card:hover .comic-thumb img { transform: scale(1.05); }

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    backdrop-filter: blur(4px);
}
.badge--ongoing { background: rgba(34,197,94,.85); }
.badge--done    { background: rgba(59,130,246,.85); }

.chap-label {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,.7);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
}

.comic-meta {
    padding: 10px 12px;
}
.comic-title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}
.comic-title a:hover { color: var(--primary); }
.comic-views {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Buttons ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary  { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled)  { background: var(--primary-dark); }
.btn--outline  { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn--outline:hover:not(:disabled)  { background: var(--primary-light); }
.btn--ghost    { background: var(--border); color: var(--text); }
.btn--ghost:hover:not(:disabled)    { background: #d1d5db; }

/* ─── Breadcrumb ─────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--text-muted); }

/* ─── Pagination ─────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 36px;
    flex-wrap: wrap;
}
.pag-btn {
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    padding: 0 8px;
}
.pag-btn:hover     { border-color: var(--primary); color: var(--primary); }
.pag-active        { background: var(--primary); color: #fff !important; border-color: var(--primary); }
.pag-dots          { color: var(--text-muted); padding: 0 4px; }

/* ─── Detail page ────────────────────────────── */
.detail-wrap {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 32px;
    margin-bottom: 32px;
}
.detail-cover img {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    aspect-ratio: 5/7;
    object-fit: cover;
}
.detail-title { font-size: 26px; font-weight: 700; line-height: 1.3; margin-bottom: 6px; }
.detail-alt   { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }

.detail-meta  { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.detail-meta li { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; }
.meta-label { min-width: 80px; font-weight: 600; color: var(--text-muted); }
.meta-value { flex: 1; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-tag {
    padding: 3px 10px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 500;
    transition: background var(--transition);
}
.cat-tag:hover { background: var(--primary); color: #fff; }

.detail-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.detail-desc {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}
.desc-text { line-height: 1.9; color: #374151; }

/* ─── Chapter list ───────────────────────────── */
.chapter-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    max-height: 460px;
    overflow-y: auto;
}
.chapter-item {
    padding: 9px 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chapter-item:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Search hero ────────────────────────────── */
.search-hero {
    text-align: center;
    padding: 40px 0 32px;
}
.search-hero h1 { font-size: 28px; margin-bottom: 20px; }
.search-form--large {
    max-width: 560px;
    margin: 0 auto;
    border-radius: 12px;
    border-width: 2px;
}
.search-form--large input { padding: 14px 20px; font-size: 15px; }
.search-form--large button { padding: 14px 24px; border-radius: 0 10px 10px 0; }

/* ─── Empty state ────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 2;
}

/* ─── Footer ─────────────────────────────────── */
.site-footer {
    background: #1a1a2e;
    color: #9ca3af;
    margin-top: 60px;
    padding: 40px 0 20px;
}
.footer-inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 32px;
    margin-bottom: 28px;
}
.footer-brand .logo-text { color: #fff; font-size: 20px; font-weight: 700; display: block; margin-bottom: 10px; }
.footer-brand p { font-size: 13.5px; line-height: 1.8; }
.footer-links h4 { color: #fff; font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.footer-links a { display: block; font-size: 13.5px; margin-bottom: 8px; transition: color var(--transition); }
.footer-links a:hover { color: var(--primary); }
.footer-copy { font-size: 13px; text-align: center; border-top: 1px solid rgba(255,255,255,.08); padding-top: 20px; }

/* ─── Section spacing ────────────────────────── */
.section { margin-bottom: 40px; }

/* ─── Responsive ─────────────────────────────── */

/* Search mobile — ẩn trên desktop */
.nav-search-mobile { display: none; }

/* Hamburger animation */
.nav-toggle span { transition: transform .25s, opacity .25s; }
.nav-toggle.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 900px) {
    /* Hamburger hiện */
    .nav-toggle { display: flex; }

    /* Ẩn search desktop (chỉ ẩn wrap trong header, không ẩn search-hero) */
    #searchWrap { display: none !important; }

    /* Nav mobile — overlay từ top header xuống */
    .main-nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 200;
        background: var(--surface);
        box-shadow: 0 8px 24px rgba(0,0,0,.15);
        border-top: 2px solid var(--primary);
    }
    .main-nav.open { display: flex; }

    /* Links trong nav mobile */
    .main-nav > a {
        padding: 13px 16px;
        border-radius: 0;
        font-size: 15px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        display: block;
    }
    .main-nav > a:hover { background: var(--primary-light); color: var(--primary); }

    /* Dropdown thể loại — static, không absolute */
    .dropdown {
        width: 100%;
        flex-shrink: 0;
        position: static !important;
    }
    .dropdown::after { display: none; }
    .dropdown .dropbtn {
        width: 100%;
        padding: 13px 16px;
        border-radius: 0;
        font-size: 15px;
        justify-content: space-between;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
    }
    .dropdown-content {
        position: static !important;
        display: none;
        box-shadow: none !important;
        border: none !important;
        border-bottom: 1px solid var(--border) !important;
        border-radius: 0 !important;
        min-width: 100% !important;
        width: 100%;
        column-count: 2;
        column-gap: 0;
        padding: 4px 0 !important;
        background: #f8f9fa;
        flex-shrink: 0;
    }
    .dropdown-content a {
        border-bottom: 1px solid #eee;
        border-radius: 0;
        font-size: 14px;
        padding: 10px 16px;
    }

    /* Hiện search mobile trong nav */
    .nav-search-mobile {
        display: block !important;
        padding: 12px 16px;
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        background: var(--surface);
    }
    .nav-search-mobile .search-form {
        width: 100%;
        border-radius: 8px;
    }

    /* Header layout */
    .header-inner {
        flex-wrap: nowrap;
        position: relative;
    }
    .logo { flex: 1; min-width: 0; }

    .detail-wrap { grid-template-columns: 1fr; }
    .detail-cover { max-width: 260px; }
    .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 640px) {
    .comic-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
    .detail-cta { flex-direction: column; }
    .detail-cta .btn { width: 100%; justify-content: center; }
    /* Search hero trên mobile */
    .search-form--large { border-radius: 8px; }
    .search-form--large input { padding: 10px 14px; font-size: 14px; }
    .search-form--large button { padding: 10px 16px; font-size: 13px; }
    .search-hero { padding: 24px 0 20px; }
    .search-hero h1 { font-size: 22px; }
}

/* ─── Search wrap mobile ────────────────────── */
.search-wrap-mobile {
    position: relative;
    width: 100%;
}
.search-dropdown--mobile {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 28px rgba(0,0,0,.15);
    z-index: 300;
    overflow: hidden;
    max-height: 340px;
    overflow-y: auto;
}

/* ─── Search autocomplete ────────────────────── */
.search-wrap {
    position: relative;
    flex: 0 0 auto;
}
.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 380px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,.15);
    z-index: 300;
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}
.search-suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text);
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}
.search-suggest-item:last-child { border-bottom: none; }
.search-suggest-item:hover,
.search-suggest-item.active { background: var(--primary-light); }
.search-suggest-item img {
    width: 40px; height: 56px;
    object-fit: cover; border-radius: 4px; flex-shrink: 0;
}
.suggest-info { flex: 1; min-width: 0; }
.suggest-name {
    display: block; font-size: 13.5px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px;
}
.suggest-meta { font-size: 12px; color: var(--text-muted); }

/* ─── Page content spacing ───────────────────── */
.site-main > .container { padding-top: 24px; padding-bottom: 24px; }