/* ============================================================
   Moban 8-10-21 · Bảng điều khiển "L-shape" · main.css
   Hải lam #01579B × Cam #FF7043 · nền #E3F2FD · bo góc 8px
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');

/* ---------- Overflow & image guards (must stay on top) ---------- */
html, body { overflow-x: hidden; }
img { max-width: 100%; height: auto; }

/* ---------- Theme variables ---------- */
:root {
    --primary: #01579B;
    --primary-deep: #013B6B;
    --accent: #FF7043;
    --accent-deep: #F4511E;
    --bg: #E3F2FD;
    --bg-soft: #F2F9FF;
    --card: #FFFFFF;
    --card-soft: #F7FBFF;
    --text: #0E2438;
    --muted: #54718C;
    --border: #C9E0F5;
    --zebra: #EFF7FE;
    --shadow: 0 6px 24px rgba(1, 87, 155, 0.08);
    --radius: 8px;
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 64px;
    --font-display: 'Chakra Petch', 'Be Vietnam Pro', sans-serif;
    --font-body: 'Be Vietnam Pro', 'Segoe UI', sans-serif;
}
html[data-theme="dark"] {
    --primary: #29A3E8;
    --primary-deep: #01579B;
    --bg: #07182A;
    --bg-soft: #0B2135;
    --card: #0E2A42;
    --card-soft: #113352;
    --text: #DFF0FD;
    --muted: #8FB3CE;
    --border: #1C4066;
    --zebra: #0C2438;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(1100px 480px at 85% -120px, rgba(255, 112, 67, 0.10), transparent 60%),
        radial-gradient(900px 420px at -120px -80px, rgba(1, 87, 155, 0.14), transparent 60%),
        var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    transition: background-color .3s ease, color .3s ease;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; margin: 0 0 .5em; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- L-shape shell grid (sidebar + main) ---------- */
.dash-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-areas: "sidebar main";
    min-height: 100vh;
    transition: grid-template-columns .28s ease;
}
body.sidebar-collapsed .dash-shell {
    grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr);
}
/* Guard: every grid child may never blow up the track */
.dash-shell > *, .dash-board > *, .kpi-grid > * { min-width: 0; }

.mobile-topbar { display: none; grid-area: topbar; }
.dash-sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 14px;
    background: linear-gradient(180deg, var(--primary-deep) 0%, #012B4E 100%);
    color: #E3F2FD;
    z-index: 120;
    transition: width .28s ease;
}
.dash-main { grid-area: main; padding: 26px clamp(16px, 3vw, 34px) 40px; }

/* ---------- Sidebar internals ---------- */
.sidebar-logo img { max-height: 42px; width: auto; display: block; margin: 0 auto; border-radius: var(--radius); }
.sidebar-nav .nav-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav .nav-menu li a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: var(--radius);
    color: #CDE8FB; font-weight: 500; white-space: nowrap;
    transition: background .2s ease, color .2s ease;
}
.sidebar-nav .nav-menu li a::before {
    content: ''; flex: none; width: 8px; height: 8px;
    border-radius: 2px; background: var(--accent); opacity: .55;
    transform: rotate(45deg); transition: opacity .2s ease;
}
.sidebar-nav .nav-menu li a:hover,
.sidebar-nav .nav-menu li.current-menu-item a,
.sidebar-nav .nav-menu li.is-active a { background: rgba(255, 255, 255, 0.10); color: #fff; }
.sidebar-nav .nav-menu li a:hover::before,
.sidebar-nav .nav-menu li.is-active a::before { opacity: 1; }

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 10px; padding: 9px; border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08); color: #CDE8FB;
    border: 1px solid rgba(255, 255, 255, 0.15); cursor: pointer;
    font-family: var(--font-body); font-size: .8rem;
    transition: background .2s ease;
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.16); }
.collapse-icon { display: inline-block; transition: transform .28s ease; }
body.sidebar-collapsed .collapse-icon { transform: rotate(180deg); }

/* Collapsed rail state */
body.sidebar-collapsed .sidebar-logo img { max-height: 30px; }
body.sidebar-collapsed .sidebar-nav .nav-menu li a { font-size: 0; justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .sidebar-nav .nav-menu li a::before { width: 10px; height: 10px; }
body.sidebar-collapsed .sidebar-actions { display: none; }
body.sidebar-collapsed .collapse-label { display: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius); border: 1px solid transparent;
    font-family: var(--font-display); font-weight: 600; font-size: .85rem;
    letter-spacing: .3px; cursor: pointer; white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease, background .2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(1, 87, 155, 0.25); }
.btn-primary { background: var(--primary); color: #fff; }
html[data-theme="dark"] .btn-primary { color: #04121F; }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; }
.btn-login { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.28); }
.btn-login:hover { background: rgba(255, 255, 255, 0.22); box-shadow: none; }
.btn-register { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .75rem; }
.btn-lg { padding: 13px 24px; font-size: .95rem; }
.btn-block { width: 100%; margin-top: 14px; }

/* ---------- Topbar ---------- */
.dash-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    flex-wrap: wrap; margin-bottom: 22px;
}
.dash-title { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0; color: var(--text); }
.dash-subtitle { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.dash-breadcrumb { margin: 0 0 6px; font-size: .8rem; color: var(--muted); }
.dash-breadcrumb a { color: var(--primary); }

/* ============================================================
   DASHBOARD BOARD — brand-new grid-template-areas map
   "kpi / table+feed / top+feed" → hình chữ L ngược
   ============================================================ */
.dash-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
        "kpi    kpi   kpi"
        "table  table feed"
        "top    top   feed";
    gap: 20px;
    align-items: start;
}
.dash-board--list {
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
    grid-template-areas: "list feed";
}
.dash-board--single {
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
    grid-template-areas: "article feed";
}
.dash-board--page {
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
    grid-template-areas: "article feed";
}
.panel-kpi { grid-area: kpi; }
.panel-table { grid-area: table; }
.panel-feed { grid-area: feed; }
.panel-top { grid-area: top; }
.panel-list { grid-area: list; }
.panel-article { grid-area: article; }

/* ---------- Panels ---------- */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    transition: background-color .3s ease, border-color .3s ease;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head-gap { margin-top: 22px; }
.panel-title { font-size: 1rem; margin: 0; }
.panel-link { font-size: .8rem; font-weight: 600; color: var(--accent); }
.panel-link:hover { text-decoration: underline; }

/* ---------- KPI row ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
    transition: transform .2s ease;
}
.kpi-card::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
}
.kpi-card:hover { transform: translateY(-3px); }
.kpi-icon { font-size: 1.6rem; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-value { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.1; }
.kpi-label { font-size: .75rem; color: var(--muted); }
.kpi-trend { margin-left: auto; font-size: .68rem; font-weight: 700; padding: 3px 7px; border-radius: 999px; }
.kpi-up { color: #0B7A3B; background: rgba(16, 185, 129, 0.14); }
.kpi-flat { color: var(--muted); background: rgba(120, 144, 168, 0.15); }
html[data-theme="dark"] .kpi-up { color: #4ADE80; }

/* ---------- Data table (zebra + scroll wrapper) ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 560px; }
.data-table th {
    text-align: left; font-family: var(--font-display); font-size: .72rem;
    text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
    padding: 10px 12px; border-bottom: 2px solid var(--border);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: var(--zebra); }
.data-table tbody tr { transition: background .18s ease; }
.data-table tbody tr:hover { background: rgba(255, 112, 67, 0.10); }
.cell-game { display: flex; align-items: center; gap: 10px; font-weight: 600; white-space: nowrap; }
.table-thumb { width: 38px; height: 38px; object-fit: cover; border-radius: var(--radius); flex: none; }
.rank-pill {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius);
    font-family: var(--font-display); font-weight: 700; font-size: .8rem;
    background: var(--card-soft); color: var(--muted); border: 1px solid var(--border);
}
.rank-gold { background: #FFC93C; border-color: #E8A800; color: #5A4000; }
.rank-silver { background: #D9E2EC; border-color: #B0BEC5; color: #37474F; }
.rank-bronze { background: #E2A06B; border-color: #C97F42; color: #4E2A0D; }
.score-tag {
    font-family: var(--font-display); font-weight: 700; color: var(--accent);
    background: rgba(255, 112, 67, 0.14); padding: 3px 9px; border-radius: 999px; font-size: .8rem;
}

/* ---------- News feed ---------- */
.news-feed { display: flex; flex-direction: column; }
.feed-item { border-bottom: 1px dashed var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-link { display: flex; gap: 12px; padding: 11px 2px; align-items: center; }
.feed-thumb { flex: none; width: 52px; height: 52px; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--card-soft); font-size: 1.3rem; }
.feed-thumb img { width: 100%; height: 100%; object-fit: cover; }
.feed-content { display: flex; flex-direction: column; min-width: 0; }
.feed-title {
    font-size: .85rem; color: var(--text); line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-date { font-size: .72rem; color: var(--muted); margin-top: 3px; }
.feed-link:hover .feed-title { color: var(--accent); }
.feed-empty { color: var(--muted); padding: 12px 0; }

/* ---------- Top ranking cards ---------- */
.top-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.top-card {
    position: relative; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); display: block; background: var(--card-soft);
    transition: transform .2s ease;
}
.top-card:hover { transform: translateY(-3px); }
.top-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.top-medal { position: absolute; top: 8px; left: 8px; font-size: 1.2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); z-index: 2; }
.top-info { display: flex; flex-direction: column; padding: 9px 10px; }
.top-info strong { font-size: .8rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-score { font-style: normal; font-family: var(--font-display); color: var(--accent); font-size: .75rem; font-weight: 700; }

/* ---------- Poster strip ---------- */
.poster-strip-section { margin-top: 26px; }
.poster-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.poster-item {
    width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
    border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow); transition: transform .25s ease;
}
.poster-item:hover { transform: scale(1.025) rotate(-0.5deg); }

/* ---------- Post cards (index / archive) ---------- */
.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.post-card { background: var(--card-soft); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: transform .2s ease, box-shadow .2s ease; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.post-card-link { display: block; color: inherit; }
.post-card-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--zebra); }
.post-card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .post-card-thumb img { transform: scale(1.05); }
.post-card-body { display: flex; flex-direction: column; padding: 14px; }
.post-card-date { font-size: .72rem; color: var(--muted); }
.post-card-title { font-size: 1rem; margin: 5px 0 7px; color: var(--text); }
.post-card-excerpt { font-size: .83rem; color: var(--muted); margin: 0 0 10px; }
.post-card-more { font-size: .8rem; font-weight: 700; color: var(--accent); }

/* ---------- Single / page article ---------- */
.article-thumb { margin-bottom: 18px; border-radius: var(--radius); overflow: hidden; }
.article-content { line-height: 1.8; font-size: .95rem; overflow-wrap: break-word; }
.article-content img { border-radius: var(--radius); }
.article-content table { display: block; overflow-x: auto; max-width: 100%; }
.article-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.panel-comments { margin-top: 22px; }

/* ---------- Search & widgets ---------- */
.sidebar-search { display: flex; gap: 8px; }
.search-input {
    flex: 1; min-width: 0; padding: 9px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
    font-family: var(--font-body);
}
.search-input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.search-btn { border: none; border-radius: var(--radius); background: var(--primary); cursor: pointer; padding: 0 13px; font-size: .95rem; }
html[data-theme="dark"] .search-btn { color: #04121F; }
.widget-zone { margin-top: 20px; }
.widget-zone .widget { margin-bottom: 16px; }
.widget-title { font-size: .95rem; margin: 0 0 10px; }

/* ---------- Pagination ---------- */
.pagination-wrap { margin-top: 22px; }
.pagination, .nav-links { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.pagination a, .nav-links a, .pagination span, .nav-links span {
    padding: 7px 13px; border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-size: .85rem; background: var(--card);
}
.pagination .current, .nav-links .current { background: var(--primary); color: #fff; border-color: var(--primary); }
html[data-theme="dark"] .pagination .current, html[data-theme="dark"] .nav-links .current { color: #04121F; }

/* ---------- Theme toggle & drawer overlay ---------- */
.theme-toggle {
    position: fixed; bottom: 22px; right: 22px; width: 48px; height: 48px;
    border-radius: 50%; border: 1px solid var(--border); cursor: pointer;
    background: var(--card); color: var(--text); font-size: 1.2rem;
    box-shadow: var(--shadow); z-index: 300;
    transition: transform .2s ease, background .3s ease;
}
.theme-toggle:hover { transform: rotate(18deg) scale(1.06); }
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(1, 25, 45, 0.55);
    opacity: 0; visibility: hidden; transition: opacity .25s ease; z-index: 250;
}
body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }

/* ---------- Footer ---------- */
.site-footer { background: var(--primary-deep); color: #BBD9F0; margin-top: 46px; padding: 40px 0 26px; }
html[data-theme="dark"] .site-footer { background: #050F1B; }
.footer-widgets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; margin-bottom: 26px; }
.footer-widget { min-width: 0; }
.site-footer .widget-title { color: #fff; font-size: .95rem; }
.site-footer a { color: #9CCBEF; }
.site-footer a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, 0.14); padding-top: 22px; text-align: center; }
.disclaimer-text { font-size: .8rem; color: #8FB3CE; max-width: 760px; margin: 14px auto 0; line-height: 1.7; }

/* ---------- Reveal animation ---------- */
.panel, .kpi-card { animation: dash-rise .55s ease both; }
.dash-board > .panel:nth-child(2) { animation-delay: .08s; }
.dash-board > .panel:nth-child(3) { animation-delay: .16s; }
.dash-board > .panel:nth-child(4) { animation-delay: .24s; }
@keyframes dash-rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none; transition: none; }
}
