:root {
  --primary: #6C3CE9;
  --primary-dark: #4B21B8;
  --accent: #FF9F45;
  --success: #17B26A;
  --danger: #F04438;
  --bg: #F6F5FB;
  --card: #FFFFFF;
  --text: #221C35;
  --muted: #6B7280;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(76, 33, 184, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ================= NAVBAR ================= */
.navbar {
  background: linear-gradient(120deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
/* Outer row: [ brand + nav-links grouped on the left ] .... [ avatar + hamburger on the right ] */
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}
.navbar-left {
  display: flex;
  align-items: center;
  gap: 36px;
}
.brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .dot { width: 10px; height: 10px; background: var(--accent); border-radius: 50%; display: inline-block; }

.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { display: flex; align-items: center; gap: 6px; font-weight: 500; opacity: .92; transition: .2s; white-space: nowrap; }
.nav-links a:hover { opacity: 1; text-decoration: underline; }

.nav-right { display: flex; align-items: center; gap: 16px; }
.hamburger { display: none; background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }

/* ---- profile avatar + dropdown ---- */
.avatar-btn {
  display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.14); border: none; cursor: pointer;
  padding: 6px 16px 6px 6px; border-radius: 50px; color: #fff; font-weight: 600; font-size: 14px;
}
.avatar-img, .avatar-fallback {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--accent); color: #221C35;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.avatar-menu {
  position: absolute; top: 62px; right: 0; background: #fff; color: var(--text); border-radius: 14px;
  box-shadow: var(--shadow); min-width: 220px; padding: 8px; display: none; z-index: 200;
}
.avatar-menu.open { display: block; }
.avatar-menu a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.avatar-menu a:hover { background: #F3F0FC; color: var(--primary-dark); }
.avatar-menu .divider { height: 1px; background: #EFEDF7; margin: 6px 4px; }
.avatar-menu .menu-label { padding: 8px 14px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }

@media (max-width: 860px) {
  .hamburger { display: block; }
  .navbar-left { gap: 18px; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--primary-dark);
    flex-direction: column; align-items: stretch; padding: 10px 20px 18px; gap: 2px; box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 6px; border-bottom: 1px solid rgba(255,255,255,.08); }
  .avatar-btn span.hide-sm { display: none; }
}
@media (max-width: 600px) {
  .hero h1 { font-size: 30px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
}

/* ================= HERO ================= */
.hero {
  background: radial-gradient(circle at top right, rgba(255,159,69,.25), transparent 55%),
              linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 70px 0 90px;
  border-radius: 0 0 40px 40px;
}
.hero h1 { font-size: 42px; font-weight: 800; line-height: 1.2; margin-bottom: 14px; }
.hero p { font-size: 17px; opacity: .92; max-width: 560px; }
.hero .actions { margin-top: 26px; display: flex; gap: 14px; flex-wrap: wrap; }

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 26px; border-radius: 50px; font-weight: 600;
  border: none; cursor: pointer; font-size: 15px; transition: transform .15s, box-shadow .15s;
}
.btn-primary { background: var(--accent); color: #221C35; }
.btn-outline { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.7); }
.btn-solid { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.15); }
.btn-sm { padding: 7px 16px; font-size: 13px; border-radius: 30px; }
.btn-block { width: 100%; text-align: center; }

/* ================= CARDS / GRID ================= */
.section { padding: 60px 0; }
.section-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.section-sub { color: var(--muted); margin-bottom: 34px; }
.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; transition: transform .2s;
}
.card:hover { transform: translateY(-4px); }

.stat-card { text-align: center; }
.stat-card .num { font-size: 30px; font-weight: 800; color: var(--primary); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.note-card .cover { border-radius: 12px; overflow: hidden; margin-bottom: 14px; height: 160px; background: linear-gradient(135deg,#eee,#ddd); display:flex; align-items:center; justify-content:center; color: var(--primary); }
.note-card h3 { margin: 6px 0; font-size: 18px; }
.note-card .price { color: var(--primary); font-weight: 700; font-size: 20px; }
.badge { display: inline-block; padding: 3px 12px; border-radius: 30px; font-size: 12px; font-weight: 600; }
.badge-pass { background: #E6F9F0; color: var(--success); }
.badge-fail { background: #FDECEA; color: var(--danger); }
.badge-group { background: #EEE7FD; color: var(--primary-dark); }

/* ================= FORMS ================= */
.form-card { max-width: 460px; margin: 60px auto; }
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid #E2E0EE;
  font-size: 14px; font-family: inherit; background: #FBFAFF;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.alert { padding: 12px 18px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #E6F9F0; color: #0E8E52; }
.alert-error { background: #FDECEA; color: #C42D22; }
.alert-info { background: #EEF2FF; color: #3143C4; }

/* ================= TABLES ================= */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 16px; text-align: left; font-size: 14px; border-bottom: 1px solid #F0EEF7; }
th { background: #F3F0FC; color: var(--primary-dark); font-weight: 700; }
tr:hover { background: #FAFAFF; }

/* ================= SIDEBAR (dashboard/admin layout) ================= */
.layout { display: flex; min-height: calc(100vh - 68px); }
.sidebar {
  width: 240px; background: #fff; box-shadow: 2px 0 12px rgba(0,0,0,.04); padding: 24px 0; flex-shrink: 0;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 12px 26px; font-weight: 500; color: var(--text); font-size: 14.5px;
}
.sidebar a.active, .sidebar a:hover { background: #F1EBFE; color: var(--primary-dark); border-right: 3px solid var(--primary); }
.main-content { flex: 1; padding: 30px; }

/* ================= EXAM PAGE ================= */
.exam-header {
  display: flex; justify-content: space-between; align-items: center; background: #fff;
  padding: 16px 24px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; position: sticky; top: 76px; z-index: 10;
}
.timer { font-size: 20px; font-weight: 700; color: var(--danger); background: #FDECEA; padding: 8px 18px; border-radius: 30px; }
.question-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; margin-bottom: 20px; }
.question-box .qnum { color: var(--primary); font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.option-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1.5px solid #E2E0EE; border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: .15s; }
.option-row:hover { border-color: var(--primary); background: #FAF8FF; }
.option-row input { width: auto; }
.qnav-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.qnav-grid button {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid #ddd; background: #fff; font-size: 12px; cursor: pointer;
}
.qnav-grid button.answered { background: var(--success); color: #fff; border-color: var(--success); }
.qnav-grid button.current { border: 2px solid var(--primary); font-weight: 700; }

/* ---- matching-question layout ---- */
.match-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1.5px solid #E2E0EE; border-radius: 10px; margin-bottom: 10px;
}
.match-row .left-text { flex: 1; font-weight: 600; }
.match-row select { flex: 1; }
.match-pair-builder { border: 1.5px dashed #D8D2F2; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.match-pair-builder .grid-2 { gap: 12px; margin-bottom: 0; }

/* ================= RESULT PAGE ================= */
.result-hero { text-align: center; padding: 40px 20px; border-radius: var(--radius); color: #fff; }
.result-pass { background: linear-gradient(120deg, #17B26A, #0E8E52); }
.result-fail { background: linear-gradient(120deg, #F04438, #C42D22); }
.result-hero .score { font-size: 52px; font-weight: 800; }

/* ================= FOOTER ================= */
footer { background: #221C35; color: #cfcbe0; padding: 34px 0; text-align: center; margin-top: 60px; }
footer a { color: #fff; }

.pdf-frame { width: 100%; height: 80vh; border: none; border-radius: var(--radius); box-shadow: var(--shadow); }

/* ================= BLOG CONTENT (rendered admin HTML) ================= */
.blog-content { font-size: 16px; line-height: 1.8; color: var(--text); margin-top: 10px; }
.blog-content h1, .blog-content h2, .blog-content h3 { margin-top: 32px; margin-bottom: 12px; font-weight: 700; }
.blog-content p { margin-bottom: 16px; }
.blog-content img { border-radius: 12px; margin: 16px 0; }
.blog-content ul, .blog-content ol { margin-bottom: 16px; padding-left: 24px; }
.blog-content li { margin-bottom: 6px; }
.blog-content a { color: var(--primary); text-decoration: underline; }
.blog-content blockquote { border-left: 4px solid var(--primary); padding: 10px 18px; background: #F8F6FF; border-radius: 0 10px 10px 0; margin: 18px 0; color: var(--muted); }
.blog-content code { background: #F1EEFA; padding: 2px 6px; border-radius: 6px; font-size: 14px; }

/* ================= ICONS ================= */
.icon { vertical-align: middle; flex-shrink: 0; }
.icon-circle {
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: #EEE7FD; color: var(--primary); margin: 0 auto 10px;
}
.stat-card .icon-circle { background: linear-gradient(135deg, #EEE7FD, #F6F0FF); }

/* ================= MODAL / NOTICE POPUP ================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(34,28,53,.55); display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: var(--radius); max-width: 460px; width: 100%; padding: 30px; box-shadow: var(--shadow);
  text-align: center;
}
.modal-box .icon-circle { width: 60px; height: 60px; }
.modal-box h3 { margin: 10px 0; font-size: 20px; }
.modal-box p { color: var(--muted); font-size: 14.5px; line-height: 1.6; text-align: left; }

/* ================= RESPONSIVE POLISH ================= */
@media (max-width: 700px) {
  .exam-header { flex-direction: column; align-items: flex-start; gap: 10px; top: 10px; }
  .qnav-grid { grid-template-columns: repeat(6, 1fr); }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 10px; }
  .sidebar a { flex-direction: column; gap: 4px; padding: 10px 16px; font-size: 12px; white-space: nowrap; border-right: none !important; }
  .match-row { flex-direction: column; align-items: stretch; }
}
