* { box-sizing: border-box; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f4f6f9;
    margin: 0;
    color: #1f2937;
}
.navbar {
    background: #1e3a8a;
    color: #fff;
    padding: 0 24px;
}
.navbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    flex-wrap: wrap;
    position: relative;
}
.navbar a { color: #fff; text-decoration: none; }
.navbar .brand { font-weight: 700; font-size: 18px; }
.navbar .brand a { color: #fff; text-decoration: none; }
.nav-toggle {
    display: none; background: none; border: none; color: #fff; font-size: 22px;
    cursor: pointer; padding: 4px 8px; width: auto; margin: 0;
}
.navbar .nav-links { display: flex; align-items: center; gap: 6px; }
.nav-plain-link { padding: 8px 10px; font-size: 15px; border-radius: 6px; }
.nav-plain-link:hover { background: rgba(255,255,255,.12); }

/* Dropdown BỀN: điều khiển bằng class .open (JS click-toggle), không dùng
   :hover — tránh menu tự đóng/nháy khi rê chuột qua khoảng hở. */
.nav-dropdown { position: relative; }
.nav-dropdown-label {
    background: none; border: none; color: #fff; cursor: pointer; font-size: 15px;
    padding: 8px 10px; border-radius: 6px; width: auto; margin: 0; display: flex;
    align-items: center; gap: 4px; font-family: inherit;
}
.nav-dropdown-label:hover { background: rgba(255,255,255,.12); }
.nav-dropdown.open .nav-dropdown-label { background: rgba(255,255,255,.18); }
.caret { font-size: 11px; transition: transform .15s ease; }
.nav-dropdown.open .caret { transform: rotate(180deg); }

.nav-dropdown-menu {
    display: none; position: absolute; left: 0; top: calc(100% + 8px); background: #fff;
    border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.18); min-width: 260px;
    max-width: 320px; max-height: 75vh; overflow-y: auto;
    padding: 6px 0; z-index: 30;
}
.nav-dropdown-menu--right { left: auto; right: 0; }
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: block; color: #1a1f2e; margin: 0; padding: 9px 16px; font-size: 14px;
}
.nav-dropdown-menu a:hover { background: #f2f4fc; }
.nav-dropdown-empty {
    padding: 12px 16px; font-size: 13.5px; color: #8a92a6; max-width: 240px;
}
.nav-dropdown-soon {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 9px 16px; font-size: 14px; color: #b3b9c6; cursor: default;
}
.nav-dropdown-soon em {
    font-style: normal; font-size: 11px; background: #f2f0fa; color: #7c6fce;
    padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.nav-dropdown-info { display: block; padding: 9px 16px; font-size: 13.5px; color: #92400e; }
.nav-dropdown-divider { height: 1px; background: #eef0f4; margin: 6px 0; }

@media (max-width: 780px) {
    .nav-toggle { display: block; }
    .navbar .nav-links {
        display: none; flex-direction: column; align-items: stretch; width: 100%;
        gap: 2px; padding-top: 10px;
    }
    .navbar .nav-links.open { display: flex; }
    .nav-dropdown-menu, .nav-dropdown-menu--right { position: static; box-shadow: none; width: 100%; }
    .nav-dropdown.open .nav-dropdown-menu { border-top: 1px solid rgba(0,0,0,.06); margin-top: 4px; }
}

.header-sticky-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
}
/* ---------- Breadcrumb: hiện trên các trang công cụ theo chương, để
   không bị "chôn cứng" ở 1 chương — bấm ngược ra môn/cấp học/trang chủ. ---------- */
.breadcrumb-bar { background: #eef1fb; border-bottom: 1px solid #e0e4f5; }
.breadcrumb-inner {
    max-width: 1180px; margin: 0 auto; padding: 10px 24px; font-size: 13.5px;
    color: #5b6478; display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.breadcrumb-inner a { color: #3949ab; text-decoration: none; }
.breadcrumb-inner a:hover { text-decoration: underline; }
.crumb-sep { color: #b3b9c6; }
.crumb-current { color: #1a1f2e; font-weight: 600; }
@media (max-width: 780px) { .breadcrumb-inner { padding: 8px 16px; font-size: 12.5px; } }

/* ---------- Menu: nhóm chương xổ ra trong mega-menu (details/summary),
   để duyệt thẳng lý thuyết/bài tập từng chương mà không cần qua trang chủ. ---------- */
.nav-chapter-group { border-top: 1px solid #f2f3f8; }
.nav-chapter-group:first-child { border-top: none; }
.nav-chapter-group summary {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 9px 16px; font-size: 14px; color: #1a1f2e; cursor: pointer; list-style: none;
}
.nav-chapter-group summary::-webkit-details-marker { display: none; }
.nav-chapter-group summary::after { content: '▾'; font-size: 11px; color: #8a92a6; flex-shrink: 0; }
.nav-chapter-group[open] summary::after { content: '▴'; }
.nav-chapter-group summary:hover { background: #f2f4fc; }
.nav-chapter-count { font-size: 11.5px; color: #8a92a6; font-weight: 400; white-space: nowrap; }
.nav-chapter-list { background: #fafbff; padding: 2px 0 6px; }
.nav-chapter-list a { padding: 7px 16px 7px 28px; font-size: 13.5px; }
.nav-chapter-overview { font-weight: 600; color: #3949ab !important; }
.nav-chapter-noTool {
    display: block; padding: 7px 16px 7px 28px; font-size: 13.5px; color: #b3b9c6;
}
.nav-chapter-noTool em { font-style: normal; }

/* ---------- Dashboard: dòng trạng thái VIP ngay dưới "Xin chào" ---------- */
.vip-status-line { margin: 8px 0 0; font-size: 14.5px; color: #5b6478; }
.vip-status-line strong { color: #92400e; }

.container { max-width: 900px; margin: 30px auto; padding: 0 16px; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-free { background: #e5e7eb; color: #374151; }
.badge-vip { background: #fde68a; color: #92400e; }
.badge-admin { background: #ddd6fe; color: #5b21b6; }
input, select, button {
    width: 100%;
    padding: 10px 12px;
    margin: 6px 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
}
button {
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
button:hover { background: #1d4ed8; }
.exam-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}
.locked { opacity: 0.6; }
.error { color: #dc2626; margin-bottom: 12px; }
.success { color: #16a34a; margin-bottom: 12px; }

.google-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 11px; border: 1px solid #dadce0; border-radius: 8px;
    background: #fff; color: #3c4043; font-weight: 600; font-size: 14.5px;
    text-decoration: none; box-sizing: border-box;
}
.google-btn:hover { background: #f7f8f8; }
.divider { display: flex; align-items: center; text-align: center; color: #9aa0ac; font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid #e5e7eb; }
.divider span { padding: 0 10px; }
.question-block { margin-bottom: 22px; }
.qr-box { text-align: center; }
.qr-box img { max-width: 260px; border-radius: 8px; }

/* ---------- Trang chủ: hero ---------- */
.hero-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    text-align: center;
    padding: 48px 24px;
    border-radius: 14px;
    margin-bottom: 20px;
}
.hero-card h1 { font-size: 30px; margin: 0 0 10px; }
.hero-sub { font-size: 16px; color: #e4e9fb; max-width: 580px; margin: 0 auto 22px; }
.hero-card .btn-primary,
.hero-card .btn-secondary {
    display: inline-block; padding: 12px 26px; border-radius: 8px; text-decoration: none;
    font-weight: 600; margin: 0 6px;
}
.hero-card .btn-primary { background: #fff; color: #1e3a8a; }
.hero-card .btn-primary:hover { background: #eef0fa; }
.hero-card .btn-secondary { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.hero-card .btn-secondary:hover { background: rgba(255,255,255,.25); }
.hero-stats { font-size: 13px; color: #cdd6f4; margin-top: 18px; }

/* ---------- Trang chủ: lưới thẻ môn học ---------- */
.section-empty { color: #8a92a6; font-size: 14.5px; }
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.subject-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    text-align: left; background: #f7f8fc; border: 1px solid #e7e9f2; border-radius: 12px;
    padding: 16px; cursor: pointer; width: 100%; margin: 0; font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.subject-card:hover { border-color: #a9b6f2; box-shadow: 0 6px 16px rgba(37,99,235,.12); transform: translateY(-1px); }
.subject-card.is-active { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.subject-icon { font-size: 26px; }
.subject-name { font-weight: 700; font-size: 15px; color: #1a1f2e; }
.subject-meta { font-size: 12.5px; color: #7c8394; }
.subject-card--soon {
    cursor: default; background: #fafafc; border-style: dashed; opacity: .8;
}
.subject-card--soon:hover { border-color: #e7e9f2; box-shadow: none; transform: none; }
.subject-badge-soon {
    font-size: 11px; font-weight: 600; background: #f2f0fa; color: #7c6fce;
    padding: 3px 9px; border-radius: 20px; align-self: flex-start;
}

/* ---------- Trang chủ: panel danh sách chương ---------- */
.chapter-panel {
    margin-top: 18px; padding-top: 18px; border-top: 1px solid #eef0f4;
}
.chapter-panel-head {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.chapter-panel-head h4 { margin: 0; font-size: 16px; }
.chapter-panel-close {
    width: auto; margin: 0; padding: 6px 12px; font-size: 13px; font-weight: 600;
    background: #eef0fa; color: #1a1f2e; border-radius: 8px;
}
.chapter-panel-close:hover { background: #e2e6f7; }
.chapter-panel-body .exam-item { text-decoration: none; color: inherit; display: flex; }
.chapter-panel-body .exam-item:hover { background: #f7f8fc; border-radius: 8px; padding-left: 8px; padding-right: 8px; }

/* ---------- Trang chủ: khối "Đề thi trắc nghiệm" RIÊNG cho từng môn-lớp,
   tách khỏi danh sách chương ở trên (không dùng chung 1 khối cho mọi
   môn) — hiện cho CẢ khách vãng lai để biết phần bài tập tồn tại. ---------- */
.exam-summary-block { margin-top: 18px; padding-top: 16px; border-top: 1px dashed #e0e3ee; }
.exam-summary-title { font-weight: 700; font-size: 14.5px; margin-bottom: 10px; color: #1a1f2e; }
.exam-summary-groups { display: flex; flex-direction: column; gap: 4px; }
.exam-summary-row {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 9px 0; border-bottom: 1px solid #f2f3f8; text-decoration: none; color: inherit;
    font-size: 13.5px;
}
a.exam-summary-row:hover { background: #f7f8fc; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.exam-summary-label { color: #3a4053; }
.exam-summary-badges { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.badge-mini {
    font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-mini-free { background: #e5e7eb; color: #374151; }
.badge-mini-vip { background: #fde68a; color: #92400e; }
.exam-summary-cta { margin-top: 12px; font-size: 13.5px; color: #5b6478; }
.exam-summary-cta a { color: #2563eb; font-weight: 600; text-decoration: none; }
.exam-summary-cta a:hover { text-decoration: underline; }

/* ---------- Dashboard: Tab lọc đề thi theo môn/lớp ---------- */
/* Container bao ngoài — bình thường nằm đúng vị trí trong DOM,
   khi thêm .is-sticky (JS gắn sau khi user bấm) thì treo dưới sticky header */
.sticky-tabs-container {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 16px;
    z-index: 900;
    /* Không sticky mặc định — chỉ sticky khi JS gắn .is-sticky */
}
.sticky-tabs-container.is-sticky {
    position: sticky;
    top: var(--sticky-header-height, 0px);
}

.exam-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.exam-tab-btn {
    /* Gọn nhỏ như pill tag */
    width: auto;
    margin: 0;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border: 1.5px solid #d1d5db;
    border-radius: 20px;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.exam-tab-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}
.exam-tab-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
@media (max-width: 600px) {
    .exam-tabs { flex-wrap: nowrap; gap: 6px; }
    .exam-tab-btn { font-size: 12px; padding: 5px 12px; }
}

/* ---------- Quiz Interactive Features ---------- */
.quiz-mode-selector {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; margin-top: 15px;
}
.quiz-mode-selector > label { font-weight: 600; margin-bottom: 8px; display: block; }
.radio-group { display: flex; gap: 15px; margin-bottom: 10px; }
.radio-btn { cursor: pointer; display: flex; align-items: center; gap: 5px; font-weight: 500; }
.mode-desc { font-size: 13px; color: #64748b; margin: 0; line-height: 1.4; }

.options-group { margin-top: 10px; }
.option-label {
    display: block; padding: 10px 15px; margin-bottom: 8px; border: 1px solid #e2e8f0;
    border-radius: 6px; cursor: pointer; transition: all 0.2s; background: #fff;
}
.option-label:hover { background: #f8fafc; border-color: #cbd5e1; }
.option-label.opt-correct { background: #dcfce7; border-color: #4ade80; color: #166534; font-weight: 600; }
.option-label.opt-wrong { background: #fee2e2; border-color: #f87171; color: #991b1b; }

.explanation-block {
    background: #f1f5f9; border-left: 4px solid #3b82f6; padding: 12px 15px;
    margin-top: 15px; border-radius: 4px; font-size: 14px; color: #334155;
}
.explanation-block p { margin: 5px 0 0 0; }

.floating-quiz-bar {
    position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.15); border-top: 1px solid #e2e8f0;
    z-index: 9999; padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.floating-inner {
    max-width: 1180px; margin: 0 auto; padding: 0 24px; display: flex;
    justify-content: space-between; align-items: center;
}
.quiz-progress { font-size: 14px; font-weight: 600; color: #475569; }
.quiz-timer { font-size: 20px; font-weight: 700; color: #1e293b; font-family: monospace; letter-spacing: 1px; }
.btn-submit {
    background: #2563eb; color: #fff; border: none; padding: 10px 20px;
    border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 15px;
}
.btn-submit:hover { background: #1d4ed8; }

/* Nút cuộn lên đầu bên trong floating-quiz-bar */
.btn-quiz-top {
    width: 36px; height: 36px; min-width: 36px;
    padding: 0; margin: 0;
    border: 1.5px solid #e2e8f0; border-radius: 50%;
    background: #f8fafc; color: #475569;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: background .15s, border-color .15s;
}
.btn-quiz-top:hover { background: #e0e7ff; border-color: #818cf8; color: #4338ca; }

/* ---------- Trang chặn VIP (quiz.php) ---------- */
.vip-gate {
    text-align: center;
    padding: 60px 20px;
    margin-top: 40px;
    background: linear-gradient(to bottom, #ffffff, #fdfbf7);
    border: 1px solid #fcebb6;
}
.vip-gate-icon { font-size: 64px; margin-bottom: 20px; line-height: 1; }
.vip-gate-title { font-size: 26px; color: #92400e; margin: 0 0 16px; }
.vip-gate-desc { font-size: 16px; color: #5b6478; max-width: 500px; margin: 0 auto 30px; line-height: 1.5; }
.vip-gate-btn {
    display: inline-block;
    background: #f5a623;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    padding: 16px 32px;
    border-radius: 30px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(245, 166, 35, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 30px;
}
.vip-gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 166, 35, 0.6);
}
.vip-gate-links { font-size: 14.5px; color: #8a92a6; }
.vip-gate-links a { color: #3949ab; text-decoration: none; font-weight: 600; padding: 4px 8px; }
.vip-gate-links a:hover { text-decoration: underline; background: #f0f3fa; border-radius: 4px; }

@media (max-width: 600px) {
    .floating-inner { padding: 0 15px; }
    .quiz-progress { font-size: 13px; }
    .quiz-progress span::before { content: "Làm: "; }
    .quiz-progress { color: transparent; font-size: 0; } /* Hide "Đã làm" text */
    .quiz-progress span { color: #475569; font-size: 14px; }
    .quiz-timer { font-size: 18px; }
    .btn-submit { padding: 8px 14px; font-size: 14px; }
}

/* Đệm padding-bottom cho body để không bị thanh floating che mất câu cuối */
body:has(.floating-quiz-bar) { padding-bottom: 90px; }

/* Nút cuộn lên đầu trang */
.scroll-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    z-index: 9998;
    padding: 10px;
}
.scroll-to-top:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
}
.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}
@media (max-width: 600px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        padding: 8px;
    }
}

