/* ============================================================
   XBH Flash Challenge - Design System
   Palette XBH chuẩn, mobile-first, font Be Vietnam Pro
   ============================================================ */

:root {
  --orange:   #E8580C;
  --orange-l: #FDE8DC;
  --orange-m: #FAC8AD;
  --dark:     #1A1A1A;
  --mid:      #555;
  --border:   #E8D5C4;
  --red:      #C0392B;
  --red-l:    #FDECEA;
  --green:    #1E6B35;
  --green-l:  #E6F4EC;
  --yellow:   #B7750D;
  --yellow-l: #FFF3DC;
  --blue:     #1A5276;
  --blue-l:   #EBF3FB;
  --cream:    #FFFBF5;
  --gray:     #F5F0EA;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--dark);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

/* ===== Layout ===== */

.app { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

.brand-bar {
  background: var(--orange);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-bar img { height: 28px; filter: brightness(0) invert(1); }
.brand-bar .ten-co-so { font-weight: 700; font-size: 16px; }

.day-strip {
  background: var(--orange-l);
  color: var(--dark);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* ===== Cards ===== */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
}
.card-head {
  background: var(--orange-l);
  margin: -16px -16px 12px;
  padding: 10px 16px;
  border-radius: 12px 12px 0 0;
  font-weight: 700;
  color: var(--dark);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.score-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.score-box .label { font-size: 12px; color: var(--mid); text-transform: uppercase; letter-spacing: 0.5px; }
.score-box .value { font-size: 28px; font-weight: 800; color: var(--orange); margin-top: 4px; }

/* ===== Timer ===== */

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 32px;
  color: var(--orange);
  text-align: center;
  padding: 12px 0;
}
.timer.warning { color: var(--yellow); }
.timer.danger { color: var(--red); }

/* ===== Forms ===== */

.btn {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: #fff;
  color: var(--orange);
  border: 1.5px solid var(--orange);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 140px; }

input[type=text], input[type=password], textarea, select {
  font-family: inherit;
  font-size: 16px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
textarea { min-height: 100px; resize: vertical; }
label { display: block; margin: 8px 0 4px; font-weight: 600; font-size: 14px; }

.upload-zone {
  border: 2px dashed var(--orange-m);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  background: #fff;
  cursor: pointer;
  color: var(--mid);
}
.upload-zone:hover { background: var(--orange-l); }
.upload-zone input[type=file] { display: none; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ===== Quiz ===== */

.quiz-question { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.quiz-question:last-child { border-bottom: 0; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.quiz-option {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
}
.quiz-option:hover { border-color: var(--orange-m); }
.quiz-option input { margin: 0; }
.quiz-option.correct { background: var(--green-l); border-color: var(--green); }
.quiz-option.wrong { background: var(--red-l); border-color: var(--red); }
.quiz-multi-hint { font-size: 13px; color: var(--mid); font-style: italic; margin-top: 4px; }

/* ===== Status ===== */

.status-msg {
  text-align: center;
  padding: 24px 16px;
  font-size: 15px;
  color: var(--mid);
}
.status-msg .icon { font-size: 36px; margin-bottom: 8px; }
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-ok { background: var(--green-l); color: var(--green); }
.tag-fail { background: var(--red-l); color: var(--red); }
.tag-wait { background: var(--yellow-l); color: var(--yellow); }
.tag-skip { background: var(--gray); color: var(--mid); }
.tag-info { background: var(--blue-l); color: var(--blue); }

/* ===== Tables ===== */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--gray); font-weight: 700; }
tr:nth-child(even) td { background: var(--gray); }

/* ===== Leaderboard ===== */

.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 6px;
}
.lb-row .rank { font-size: 22px; font-weight: 800; color: var(--orange); text-align: center; }
.lb-row.top1 { background: var(--orange-l); border-color: var(--orange); }
.lb-row .pts { font-weight: 800; font-size: 20px; color: var(--orange); }

/* ===== Bottom nav ===== */

.btm-nav {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  margin-top: 16px;
  padding: 8px 0;
}
.btm-nav a {
  display: block;
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--mid);
  font-weight: 600;
}
.btm-nav a.active { color: var(--orange); }

/* ===== Admin ===== */

.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.admin-side { background: #fff; border-right: 1px solid var(--border); padding: 16px; }
.admin-side .nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--dark);
  font-weight: 600;
  margin-bottom: 4px;
}
.admin-side .nav-link.active { background: var(--orange-l); color: var(--orange); }
.admin-main { padding: 24px; overflow-x: auto; }

.admin-toggle {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  background: var(--orange);
  color: #fff;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  align-items: center;
  justify-content: center;
}
.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 98;
}
.admin-overlay.open { display: block; }

@media (max-width: 720px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-toggle { display: flex; }
  .admin-side {
    position: fixed;
    top: 0;
    left: -260px;
    width: 240px;
    height: 100%;
    z-index: 99;
    transition: left 0.2s ease;
    box-shadow: 0 0 24px rgba(0,0,0,0.15);
    overflow-y: auto;
  }
  .admin-side.open { left: 0; }
  .admin-main { padding: 16px 16px 80px; }
}

/* ===== Responsive ===== */

@media (max-width: 600px) {
  .app { padding: 0 12px 24px; }
  h1 { font-size: 20px; }
  .timer { font-size: 28px; }
  .score-box .value { font-size: 24px; }
}

/* ===== Print ===== */

@media print {
  body { background: #fff; }
  .btm-nav, .btn, .brand-bar { display: none !important; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
