/* ===== สไตล์ฝั่งผู้ใช้บริการ (mobile-first) ===== */

:root {
  --green-800: #17532d;
  --green-700: #1f6b3a;
  --green-600: #2a8048;
  --green-100: #dcefe1;
  --green-50: #eef7f0;
  --orange-600: #d9661c;
  --orange-50: #fdf1e7;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --text: #1d2a22;
  --muted: #5f6b63;
  --border: #dbe2dc;
  --danger: #c0392b;
  --danger-50: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 83, 45, 0.06), 0 4px 16px rgba(23, 83, 45, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--green-700); }

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

main.container { flex: 1; padding-bottom: 40px; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }

/* ----- Header / Footer ----- */

.site-header {
  background: var(--green-700);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 22px;
  flex-shrink: 0;
}

.brand strong { display: block; font-size: 17px; line-height: 1.3; }
.brand small { display: block; font-size: 13px; opacity: 0.85; }

.site-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 20px 16px;
}

/* ----- หน้าหลัก ----- */

.hero { text-align: center; padding: 32px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; color: var(--green-800); }
.hero p { margin: 0; color: var(--muted); }

.dept-banner {
  display: inline-block;
  margin-top: 14px !important;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-800) !important;
  font-weight: 600;
}

.menu-grid { display: grid; gap: 14px; }

.menu-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}

.menu-card:hover, .menu-card:focus-visible { border-color: var(--green-600); transform: translateY(-2px); }

.menu-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--green-50);
  font-size: 28px;
}

.menu-card.accent .menu-icon { background: var(--orange-50); }
.menu-title { font-size: 19px; font-weight: 700; color: var(--green-800); }
.menu-desc { font-size: 15px; color: var(--muted); }

.admin-entry { text-align: center; margin-top: 28px; }
.btn-small { font-size: 15px; font-weight: 600; padding: 8px 18px; }

/* ----- หัวหน้า / การ์ด ----- */

.back-link {
  display: inline-block;
  margin: 18px 0 4px;
  text-decoration: none;
  font-weight: 600;
}

.page-title { margin: 4px 0 4px; font-size: 25px; color: var(--green-800); }
.page-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 18px;
}

.card-title {
  margin: 0 0 14px;
  font-size: 19px;
  color: var(--green-800);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--green-50);
}

.hint { margin: -6px 0 14px; font-size: 14px; color: var(--muted); }

/* ----- ฟอร์ม ----- */

.field { margin-bottom: 14px; }

.field label, .field .label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.req { color: var(--danger); }

input[type='text'], input[type='tel'], input[type='password'], input:not([type]), select, textarea {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

textarea { min-height: 140px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(42, 128, 72, 0.18);
}

.is-invalid { border-color: var(--danger) !important; }

.field-error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 14px;
  min-height: 0;
}

.field-error:empty { display: none; }

.field .consent-row {
  display: flex;
  margin: 0;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 400 !important;
}

.consent-row input { width: 20px; height: 20px; margin: 3px 0 0; flex-shrink: 0; accent-color: var(--green-700); }
.consent-row.is-invalid { border-color: var(--danger); background: var(--danger-50); }

.captcha-field { display: flex; flex-direction: column; align-items: center; min-height: 70px; }

.char-count { text-align: right; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ----- ปุ่ม ----- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); }
.btn-outline { background: #fff; color: var(--green-700); border-color: var(--green-600); }
.btn-outline:hover { background: var(--green-50); }
.btn-block { width: 100%; padding: 15px; font-size: 18px; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ----- แจ้งเตือน ----- */

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 600;
}

.alert-error { background: var(--danger-50); color: var(--danger); border: 1px solid #f5c6c0; }
.alert-info { background: var(--green-50); color: var(--green-800); border: 1px solid var(--green-100); }

/* ----- หัวข้อประเมิน ----- */

.q-group-title {
  margin: 18px 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--orange-600);
}

.q-group-title:first-child { margin-top: 0; }

.question {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 0 0 12px;
}

.question.is-invalid { background: var(--danger-50); }

.question legend {
  padding: 0;
  font-weight: 600;
  margin-bottom: 10px;
  float: left;
  width: 100%;
}

.scale {
  clear: both;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.scale label { position: relative; cursor: pointer; }

.scale input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.scale span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  color: var(--muted);
  transition: all 0.15s;
}

.scale .face { font-size: 26px; line-height: 1; border: 0; padding: 0; background: none; }
.scale .num { font-weight: 700; font-size: 15px; color: var(--text); border: 0; padding: 0; background: none; }

.scale input:checked + span {
  border-color: var(--green-600);
  background: var(--green-50);
  color: var(--green-800);
  box-shadow: 0 0 0 2px rgba(42, 128, 72, 0.25);
}

.scale input:focus-visible + span { outline: 3px solid rgba(42, 128, 72, 0.4); outline-offset: 2px; }

.placeholder-box {
  text-align: center;
  padding: 26px 12px;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: 12px;
}

/* ----- ประเภทเรื่อง (chips) ----- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.chips span {
  display: inline-block;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-weight: 600;
}

.chips input:checked + span { border-color: var(--orange-600); background: var(--orange-50); color: var(--orange-600); }
.chips input:focus-visible + span { outline: 3px solid rgba(217, 102, 28, 0.35); outline-offset: 2px; }

/* ----- ผลลัพธ์ / QR ----- */

.result-card { text-align: center; }
.result-icon { font-size: 46px; line-height: 1; }
.result-card h2 { margin: 8px 0 4px; color: var(--green-800); }

.ticket-code {
  display: inline-block;
  margin: 12px 0;
  padding: 10px 18px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 2px dashed var(--orange-600);
  border-radius: 12px;
  color: var(--orange-600);
  background: var(--orange-50);
  user-select: all;
}

.qr-box {
  display: inline-block;
  padding: 12px;
  margin: 8px 0 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.qr-box img, .qr-box canvas { display: block; }

.result-card .btn-block { margin-top: 20px; }

/* ----- ติดตามผล ----- */

.track-form { display: grid; gap: 10px; }

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.status-new { background: #e8f0fe; color: #1a56c4; }
.status-in_progress { background: var(--orange-50); color: var(--orange-600); }
.status-resolved { background: var(--green-100); color: var(--green-800); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.step { position: relative; padding-top: 34px; }

.step::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  z-index: 1;
}

.step::after {
  content: '';
  position: absolute;
  top: 12px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: var(--border);
}

.step:first-child::after { display: none; }
.step.done { color: var(--green-800); font-weight: 700; }
.step.done::before { background: var(--green-600); border-color: var(--green-600); }
.step.done::after { background: var(--green-600); }

.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 600; word-break: break-word; }

.reply-box {
  margin-top: 16px;
  padding: 14px;
  background: var(--green-50);
  border-left: 4px solid var(--green-600);
  border-radius: 8px;
  white-space: pre-wrap;
}

.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green-600);
}
.timeline time { display: block; font-size: 13px; color: var(--muted); }
.timeline .note { white-space: pre-wrap; }

/* ----- Dialog ----- */

dialog {
  border: 0;
  border-radius: 18px;
  padding: 28px 22px;
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

dialog::backdrop { background: rgba(20, 35, 25, 0.5); }
dialog h2 { margin: 8px 0; color: var(--green-800); }
dialog p { color: var(--muted); margin: 0 0 18px; }

@media (max-width: 400px) {
  .scale { gap: 4px; }
  .scale span { font-size: 11px; white-space: nowrap; padding: 8px 0; }
}

@media (min-width: 640px) {
  body { font-size: 17px; }
  .card { padding: 24px 26px; }
  .menu-grid { gap: 16px; }
  .scale span { font-size: 13px; }
}
