/* ==========================================================================
   NAAG Customer Satisfaction Tool — Shared Styles (Hệ A2 NAAG)
   Khớp nguyên token, cỡ chữ, khoảng cách của Wireframe đã duyệt:
   - Màn 1 (index.html): Phương án A · Thẻ tập trung 1 màn
   - Màn 2 (admin.html): Phương án B · Chia đôi Danh sách & Panel thao tác
   ========================================================================== */
:root {
  /* Bộ màu thương hiệu trích trực tiếp từ Logo NAAG:
     - NAAG Navy:     #071766 (chữ NAAG)
     - Flame Crimson: #9b1b01 & Tagline Red: #cc1418 (cánh trên + slogan)
     - Flame Sky:     #2b98f6 (cánh dưới) */
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --line: #e7ebf4;
  --line-strong: #cfd7e8;
  --ink: #0d1533;
  --ink2: #46506b;
  --ink3: #596580;
  --brand: #071766;
  --brand-2: #0f2994;
  --brand-sky: #2b98f6;
  --brand-crimson: #9b1b01;
  --brand-red: #cc1418;
  --brand-soft: #edf1fc;
  --brand-border: #c5d1f0;
  --band-solid: #071766;
  --band-bg: linear-gradient(135deg, #040d3d 0%, #071766 58%, #0f2c8c 100%);
  --band-accent: linear-gradient(90deg, #9b1b01 0%, #d41519 32%, #071766 56%, #2b98f6 100%);
  --band-text: #ffffff;
  --band-sub: #dce6ff;
  --good: #166a44;
  --good-soft: #e4f4ec;
  --warn: #9a5400;
  --warn-soft: #fef2dc;
  --bad: #b8181d;
  --bad-soft: #fdebed;
  --star-on: #d97706;
  --star-off: #cbd5e1;
  --card-sh: inset 0 1px 0 #ffffff, 0 1px 2px rgba(7, 23, 102, 0.05), 0 8px 20px -14px rgba(7, 23, 102, 0.16);
  --pop-sh: 0 12px 32px -8px rgba(7, 23, 102, 0.18), 0 0 0 1px rgba(7, 23, 102, 0.06);
  --ring: 0 0 0 3px rgba(43, 152, 246, 0.28);
  --r-card: 14px;
  --r-btn: 10px;
  --r-chip: 999px;
  --font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

p, li { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; }
button:focus, a:focus, summary:focus,
button:focus-visible, a:focus-visible, summary:focus-visible { outline: none; }

.tabular-nums { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ================= HỆ COMPONENT CHUNG (D1) ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--card-sh);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--r-btn);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .08s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #ffffff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-chip);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-neutral { background: var(--surface-2); color: var(--ink2); border: 1px solid var(--line); }

.input, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input { min-height: 38px; }
.textarea { min-height: 84px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: var(--ring); }

/* Custom Popover Dropdown */
.dd-wrap { position: relative; display: inline-block; }
.dd-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.dd-trigger:hover { background: var(--surface-2); }
.dd-trigger[aria-expanded="true"] { border-color: var(--brand-2); box-shadow: var(--ring); }
.dd-trigger svg { width: 15px; height: 15px; color: var(--ink3); transition: transform .15s; }
.dd-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 70;
  display: grid;
  gap: 4px;
  min-width: 210px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--pop-sh);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
.dd-menu.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); pointer-events: auto; }
.dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.dd-item:hover { background: var(--surface-2); }
.dd-item[aria-selected="true"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* Switch control (touch target >= 32px) */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.switch-btn {
  position: relative;
  width: 44px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.switch-btn::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 1px;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background: var(--line-strong);
  transition: background .15s;
}
.switch-btn::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .22);
  transition: transform .15s;
}
.switch-btn[aria-checked="true"]::before { background: var(--brand); }
.switch-btn[aria-checked="true"]::after { transform: translateX(18px); }

/* Brand lockup & NAAG Official Logo */
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(4, 13, 61, 0.22);
  flex-shrink: 0;
}
.brand-logo-img {
  display: block;
  height: 36px;
  width: auto;
  object-fit: contain;
}
.brand-title { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.25; }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--band-sub); }

/* ================= MÀN 1 — PHIẾU ĐÁNH GIÁ (PHƯƠNG ÁN A) ================= */
.survey-page {
  min-height: 100vh;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.survey-shell { width: 100%; max-width: 560px; display: grid; gap: 14px; }

.survey-header {
  position: relative;
  overflow: hidden;
  background-color: var(--band-solid);
  background-image: var(--band-bg);
  color: var(--band-text);
  border-radius: 16px;
  padding: 16px 18px 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.survey-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--band-accent);
}

.mode-pill-set {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(13, 18, 48, 0.36);
  gap: 2px;
  flex-shrink: 0;
}
.mode-pill-set button {
  border: 0;
  background: transparent;
  color: #ffffff;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.mode-pill-set button[aria-pressed="true"] { background: #ffffff; color: var(--brand); }

.service-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.service-strip-meta { min-width: 0; }
.service-strip-label { font-size: 12px; color: var(--ink3); font-weight: 600; }
.service-strip-name { font-size: 14.5px; font-weight: 700; color: var(--ink); margin-top: 2px; }

.survey-card { padding: 20px; display: grid; gap: 18px; }
.q-block { display: grid; gap: 8px; }
.q-block-lg { display: grid; gap: 10px; }
.q-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.q-title-sm { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.q-sub { margin: 4px 0 0; font-size: 13px; color: var(--ink2); }

.star-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.star-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 68px;
  padding: 8px 2px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.star-btn:hover { background: var(--surface-2); }
.star-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.star-btn svg { width: 24px; height: 24px; color: var(--star-off); transition: color .15s; }
.star-btn.lit svg { color: var(--star-on); fill: var(--star-on); }
.star-btn span { font-size: 12px; font-weight: 600; color: var(--ink2); text-align: center; line-height: 1.2; }
.star-btn[aria-pressed="true"] span { color: var(--brand); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--r-chip);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-btn[aria-pressed="true"] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.chip-btn svg { width: 14px; height: 14px; }

.nps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.nps-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}
.nps-btn:hover { background: var(--surface-2); }
.nps-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.nps-btn strong { font-size: 13px; font-weight: 600; }
.nps-btn small { font-size: 12px; color: var(--ink3); }
.nps-btn[aria-pressed="true"] small { color: var(--brand); }

.submit-btn { width: 100%; min-height: 44px; font-size: 14.5px; }

/* ================= MÀN 2 — QUẢN TRỊ (PHƯƠNG ÁN B · MASTER-DETAIL) ================= */
.admin-header {
  position: relative;
  background-color: var(--band-solid);
  background-image: var(--band-bg);
  color: var(--band-text);
  padding: 14px 20px 17px;
}
.admin-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--band-accent);
}
.admin-header-inner {
  max-width: 1560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-nav-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-btn-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.admin-btn-top:hover { background: rgba(255, 255, 255, 0.2); }
.admin-btn-top.solid { background: #ffffff; color: var(--brand); border-color: #ffffff; }
.admin-btn-top.solid:hover { background: #eef0fd; }
.admin-btn-top svg { width: 15px; height: 15px; }

.admin-main {
  max-width: 1560px;
  margin: 0 auto;
  padding: 18px 20px 44px;
  display: grid;
  gap: 16px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink2); text-wrap: balance; }
.kpi-ico {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--brand-soft);
  color: var(--brand);
}
.kpi-ico.good { background: var(--good-soft); color: var(--good); }
.kpi-ico.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-ico.bad { background: var(--bad-soft); color: var(--bad); }
.kpi-ico svg { width: 16px; height: 16px; }
.kpi-val { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-val.bad { color: var(--bad); }
.kpi-sub { font-size: 12px; color: var(--ink3); }
.kpi-sub.bad { color: var(--bad); font-weight: 600; }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
}
.filter-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink3);
  pointer-events: none;
}
.search-box input { padding-left: 34px; }

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
  align-items: start;
}
.master-list { display: grid; gap: 8px; }
.master-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  gap: 6px;
  transition: background .15s, border-color .15s;
}
.master-item:hover { background: var(--surface-2); }
.master-item[aria-selected="true"] { background: var(--brand-soft); border-color: var(--brand); }
.master-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.case-code { font-weight: 700; color: var(--brand); }
.case-client { font-weight: 600; color: var(--ink); }
.case-sub { font-size: 12px; color: var(--ink3); }
.overdue-flag { color: var(--bad); font-weight: 700; }

.detail-sticky { position: sticky; top: 16px; padding: 18px; display: grid; gap: 14px; }
.detail-box {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.detail-actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cause-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cause-grid .chip-btn { justify-content: center; border-radius: 10px; }

/* Overlays (Modal QR / Cài đặt / Tạo link nhanh) & Toast */
.overlay-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  place-items: center;
  padding: 16px;
}
.overlay-mask.open { display: grid; }
.modal-box {
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--pop-sh);
  padding: 20px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.modal-title { margin: 0; font-size: 16px; font-weight: 700; }
.modal-sub { font-size: 12.5px; color: var(--ink2); margin-top: 2px; }
.qr-preview-box {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  gap: 10px;
}
.qr-link-text { font-size: 12px; color: var(--ink2); word-break: break-all; text-align: center; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 120;
  background: #18181b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* States: Skeleton, Empty, Error, Thank-you */
.skel {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skelShimmer 1.4s infinite linear;
}
@keyframes skelShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.state-box {
  padding: 36px 24px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 480px;
  margin: 12px auto;
}
.state-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.state-icon.bad { background: var(--bad-soft); color: var(--bad); }
.state-icon.good { background: var(--good-soft); color: var(--good); }
.state-box h2 { margin: 4px 0 0; font-size: 17px; font-weight: 700; }
.state-box p { margin: 0; font-size: 13.5px; color: var(--ink2); max-width: 360px; }

/* ================= RESPONSIVE MOBILE (<= 767px) ================= */
@media (max-width: 767px) {
  .survey-header { flex-direction: column; align-items: flex-start; }
  .brand-logo-img { height: 32px; }
  .star-btn { min-height: 62px; }
  .admin-header { padding: 12px 14px 15px; }
  .admin-header-inner { flex-direction: column; align-items: stretch; gap: 10px; }
  .admin-nav-actions { display: grid; grid-template-columns: 1fr 1fr 38px; gap: 6px; }
  .admin-nav-actions .admin-btn-top { padding: 0 8px; font-size: 12.5px; }
  .admin-main { padding: 14px 12px 36px; gap: 12px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-val { font-size: 22px; }
  .split-grid { grid-template-columns: minmax(0, 1fr); }
  .cause-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-sticky { position: static; }
  .search-box { max-width: none; width: 100%; flex-basis: 100%; }
}
