@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Playfair+Display:wght@700;800&display=swap');

:root {
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Playfair Display', Georgia, serif;
  --accent: #b91c1c;
  --accent-dark: #7f1d1d;
  --accent-soft: #fef2f2;
  --gold: #d97706;
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-alt: #f5f3f0;
  --text: #1a1a2e;
  --text-dim: #6b7280;
  --text-mute: #9ca3af;
  --border: #e5e2dd;
  --border-strong: #d6d3ce;
  --green: #059669;
  --green-mid: #10b981;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-mid: #ef4444;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-mid: #3b82f6;
  --blue-soft: #eff6ff;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, .08);
  --radius: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-family: var(--font-head); color: var(--text); margin: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-family: var(--font); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(185, 28, 28, .25);
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 14px; font-weight: 700; }
.brand-text span { font-size: 12px; color: var(--text-dim); }

.nav { display: flex; align-items: center; gap: 8px; }
.nav a {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav a.primary {
  background: var(--accent); color: #fff;
}
.nav a.primary:hover { background: var(--accent-dark); }
.nav-logout {
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-logout:hover { background: var(--surface-alt); color: var(--text); }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  animation: fadeUp .4s ease;
}

.hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero-icon {
  width: 72px; height: 72px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 36px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(185, 28, 28, .3);
}
.eyebrow {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--font-head);
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 8px;
  line-height: 1.25;
}
.hero p {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0 auto;
  max-width: 540px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}
.section-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-family: var(--font);
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.section-title small {
  font-family: var(--font);
  font-weight: 400; font-size: 13px; color: var(--text-dim);
}

.grid { display: grid; gap: 12px; }

.input, .textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, .12);
  background: #fff;
}

.criteria-list { display: flex; flex-direction: column; gap: 8px; }
.criteria-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  transition: background .15s;
}
.criteria-row:hover { background: var(--surface-alt); }
.criteria-num {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--surface-alt);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-dim);
}
.criteria-text { font-size: 14px; line-height: 1.5; }
.vote-group { display: flex; gap: 6px; }
.vote-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.vote-btn:hover { transform: scale(1.08); }
.vote-btn.is-yes {
  background: var(--green-soft);
  border-color: var(--green-mid);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, .2);
}
.vote-btn.is-no {
  background: var(--red-soft);
  border-color: var(--red-mid);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, .2);
}

.score-summary {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface-alt);
  border-radius: 12px;
}
.score-summary .label { font-weight: 600; color: var(--text); }
.score-summary .value {
  font-family: var(--font-head);
  font-size: 26px; font-weight: 800; color: var(--accent);
}

.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-btn {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 11px 18px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.is-active-green { background: var(--green-soft); border-color: var(--green-mid); color: var(--green); font-weight: 700; }
.choice-btn.is-active-red   { background: var(--red-soft);   border-color: var(--red-mid);   color: var(--red);   font-weight: 700; }
.choice-btn.is-active-blue  { background: var(--blue-soft);  border-color: var(--blue-mid);  color: var(--blue);  font-weight: 700; }

.field-label {
  display: block;
  font-weight: 600; font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px rgba(185, 28, 28, .3);
}
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-alt); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 16px; border-radius: 14px; }

.alert {
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: var(--red-soft); border: 1px solid #fecaca; color: var(--red); }
.alert-success { background: var(--green-soft); border: 1px solid #a7f3d0; color: var(--green); }
.alert ul { margin: 0; padding-left: 20px; }

/* === Home: Hero QR === */
.qr-hero {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  margin-top: 24px;
  box-shadow: var(--shadow);
}
.qr-hero h2 {
  font-family: var(--font-head);
  font-size: 22px;
  margin: 0 0 4px;
}
.qr-hero .meta {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}
.qr-hero .qr-frame {
  display: inline-block;
  padding: 14px;
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(185, 28, 28, .12);
}
.qr-hero .qr-frame img {
  display: block;
  width: 280px; height: 280px;
}
.qr-hero .url {
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
  max-width: 360px;
  margin: 14px auto 0;
}
.qr-hero .actions {
  margin-top: 18px;
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}

/* === Home: Survey list (when multi) === */
.survey-section-title {
  font-family: var(--font-head);
  font-size: 18px;
  margin: 32px 0 12px;
  color: var(--text);
}
.survey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.survey-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.survey-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.survey-card h3 {
  font-family: var(--font-head);
  margin: 0; font-size: 17px; line-height: 1.35;
}
.survey-meta { font-size: 13px; color: var(--text-dim); display: flex; gap: 12px; flex-wrap: wrap; }
.survey-meta span::before { content: "·"; margin-right: 6px; color: var(--text-mute); }
.survey-meta span:first-child::before { content: ""; margin: 0; }
.survey-card .qr-thumb {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  align-self: center;
}
.survey-card .qr-thumb img { display: block; width: 140px; height: 140px; }
.survey-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .icon {
  font-size: 48px; margin-bottom: 12px;
}

/* === Thank you === */
.thanks-card {
  text-align: center;
  padding: 60px 24px;
}
.thanks-icon {
  font-size: 64px;
  margin-bottom: 16px;
  display: inline-block;
  animation: pop .5s ease;
}
.thanks-card h1 {
  font-family: var(--font-head);
  font-size: 26px;
  margin: 8px 0;
}
.thanks-score {
  display: inline-block;
  padding: 8px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 16px;
  margin: 12px 0;
}
.thanks-score.good   { background: var(--green-soft); color: var(--green); }
.thanks-score.ok     { background: var(--amber-soft); color: var(--amber); }
.thanks-score.bad    { background: var(--red-soft);   color: var(--red);   }

/* === QR Poster === */
.poster {
  max-width: 640px;
  margin: 24px auto;
  background: #fff;
  border: 2px solid var(--text);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
}
.poster .org { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.poster h1 { font-family: var(--font-head); font-size: 26px; margin: 12px 0 4px; }
.poster .sub { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }
.poster .qr-frame { display: inline-block; padding: 16px; border: 4px solid var(--accent); border-radius: 16px; background: #fff; }
.poster .qr-frame img { display: block; width: 320px; height: 320px; }
.poster .url { font-size: 12px; color: var(--text-dim); margin-top: 16px; word-break: break-all; }
.poster .footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-dim); }

/* === Stats Dashboard (admin) === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px; color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red);   }
.stat-value.blue  { color: var(--blue);  }
.stat-value.amber { color: var(--amber); }

.criteria-bar {
  margin-bottom: 12px;
}
.criteria-bar .row {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 5px;
}
.criteria-bar .row .text { color: var(--text-dim); padding-right: 12px; }
.criteria-bar .row .pct { font-weight: 700; }
.criteria-bar .track {
  height: 8px; border-radius: 4px;
  background: var(--surface-alt); overflow: hidden;
}
.criteria-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 4px;
  transition: width .6s ease;
}

/* Floating progress bar for survey form */
.progress-bar {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  margin: -32px -20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 5;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .3s ease;
}
.progress-text { font-size: 13px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }

/* === Admin dashboard panel (chỉ hiện khi đăng nhập) === */
.admin-panel {
  background: linear-gradient(135deg, #fff 0%, #f5f3f0 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.admin-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.admin-panel-head h2 {
  font-family: var(--font-head);
  font-size: 22px;
  margin: 0;
}
.admin-panel-head p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}
.mini-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.mini-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}
.mini-stat .num {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.mini-stat .num .dim {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
}
.mini-stat .lbl {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-actions .btn {
  font-size: 13px;
  padding: 9px 14px;
}
.recent-responses {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.recent-responses h4 {
  font-family: var(--font-head);
  font-size: 14px;
  margin: 0 0 8px;
  color: var(--text);
}
.recent-responses ul {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}
.recent-responses li {
  display: grid;
  grid-template-columns: 80px 130px 70px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface-alt);
}
.recent-responses li:last-child { border-bottom: none; }
.recent-responses .r-time { color: var(--text-mute); font-size: 12px; }
.recent-responses .r-name { font-weight: 600; color: var(--text); }
.recent-responses .r-score {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.recent-responses .r-score.good { background: var(--green-soft); color: var(--green); }
.recent-responses .r-score.ok   { background: var(--amber-soft); color: var(--amber); }
.recent-responses .r-score.bad  { background: var(--red-soft);   color: var(--red); }
.recent-responses .r-survey { color: var(--text-dim); font-size: 12px; }

/* Reusable for dashboard */
.recent-responses-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.recent-responses-list li {
  display: grid;
  grid-template-columns: 80px 160px 70px 1fr;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-alt);
}
.recent-responses-list li:last-child { border-bottom: none; }
.recent-responses-list .r-time { color: var(--text-mute); font-size: 12px; }
.recent-responses-list .r-name { font-weight: 600; color: var(--text); }
.recent-responses-list .r-score {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.recent-responses-list .r-score.good { background: var(--green-soft); color: var(--green); }
.recent-responses-list .r-score.ok   { background: var(--amber-soft); color: var(--amber); }
.recent-responses-list .r-score.bad  { background: var(--red-soft);   color: var(--red); }
.recent-responses-list .r-survey { color: var(--text-dim); font-size: 12px; }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 700;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--surface-alt);
}
.data-table tbody tr:hover { background: var(--surface-alt); }
.data-table td a { font-size: 16px; padding: 0 4px; text-decoration: none; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.status-pill.green { background: var(--green-soft); color: var(--green); }
.status-pill.gray  { background: var(--surface-alt); color: var(--text-dim); }

@media (max-width: 600px) {
  .recent-responses-list li {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 8px; }
}

@media (max-width: 600px) {
  .recent-responses li {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .recent-responses .r-time { grid-column: 1 / 2; }
  .recent-responses .r-score { grid-column: 2 / 3; grid-row: 1 / 2; }
  .recent-responses .r-name { grid-column: 1 / -1; }
  .recent-responses .r-survey { grid-column: 1 / -1; }
}

/* === Header công văn (2 cột) — đúng mẫu phiếu === */
.gov-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 8px 0 16px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.55;
}
.gov-col-left .gov-line { font-weight: 700; text-transform: uppercase; }
.gov-col-right .gov-country { font-weight: 700; text-transform: uppercase; }
.gov-col-right .gov-motto { font-weight: 600; }
.gov-divider {
  width: 70px; height: 1px;
  background: var(--text);
  margin: 4px auto 0;
}
.gov-place {
  font-style: italic;
  text-align: center;
  font-size: 12.5px;
  color: var(--text);
  margin: 8px 0 0;
}
.doc-title {
  font-family: var(--font-head);
  text-align: center;
  margin: 18px 0 6px;
  text-transform: uppercase;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: .01em;
}
.doc-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 8px;
}

@media (max-width: 600px) {
  .gov-header { grid-template-columns: 1fr; gap: 10px; }
  .doc-title { font-size: 18px; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0%   { transform: scale(.6); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .poster { border: 2px solid #000; box-shadow: none; }
}

@media (max-width: 600px) {
  .container { padding: 20px 16px 48px; }
  .hero h1 { font-size: 26px; }
  .qr-hero .qr-frame img { width: 220px; height: 220px; }
  .criteria-row {
    grid-template-columns: 28px 1fr;
  }
  .criteria-row .vote-group { grid-column: 1 / -1; justify-content: flex-end; }
}
