/* ==========================================================================
   TARI L1 INTERNAL SURVEY FILL-OUT SYSTEM (IRIS CALLER EDITION)
   Design System & Styling
   ========================================================================== */

:root {
  color-scheme: light dark;
  --navy: #16213f;
  --navy-dark: #0d1730;
  --navy-light: #243a72;
  --gold: #c9a227;
  --gold-hover: #b08a17;
  --gold-bright: #f2b705;
  --gold-soft: rgba(201, 162, 39, 0.12);
  --gold-line: rgba(201, 162, 39, 0.4);

  --bg: #f5f7fb;
  --card-bg: #ffffff;
  --card-subtle: #f8fafc;
  --text: #334155;
  --text-muted: #64748b;
  --head: #0f172a;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --err: #ef4444;
  --err-bg: #fef2f2;
  --ok: #10b981;
  --ok-bg: #ecfdf5;

  --sans: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Prompt', 'Sarabun', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 5px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.12);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card-bg: #151d33;
    --card-subtle: #1c2744;
    --text: #cbd5e1;
    --text-muted: #94a3b8;
    --head: #f8fafc;
    --line: #222f4d;
    --line-strong: #334155;
    --gold-soft: rgba(242, 183, 5, 0.15);
    --gold-line: rgba(242, 183, 5, 0.45);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Top Sticky Header
   -------------------------------------------------------------------------- */
header.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 23, 48, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.header-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title h1 {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gold-soft);
  color: var(--gold-bright);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  margin-top: 2px;
  width: fit-content;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-score-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.live-score-pill .score-num {
  color: var(--gold-bright);
  font-weight: 800;
}

.live-score-pill .score-lvl {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 400;
}

.header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.progress-line {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  width: 100%;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  transition: width 0.3s ease;
}

/* --------------------------------------------------------------------------
   Main Container & Banner
   -------------------------------------------------------------------------- */
.main-wrap {
  max-width: 1000px;
  margin: 24px auto 80px;
  padding: 0 18px;
}

.hero-banner {
  background: linear-gradient(135deg, #0d1730 0%, #16213f 60%, #243a72 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  color: #ffffff;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-banner::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(201, 162, 39, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold-bright);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.hero-banner h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
}

.hero-banner p {
  color: #cbd5e1;
  font-size: 14.5px;
  max-width: 720px;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-chip {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   Cards System
   -------------------------------------------------------------------------- */
.form-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
}

.form-card:hover {
  box-shadow: var(--shadow-md);
}

.form-card.pillar-card {
  border-left: 4.5px solid var(--gold);
}

.card-head {
  margin-bottom: 20px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 6px;
}

.card-head h3 {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--head);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pillar-badge {
  background: var(--navy);
  color: var(--gold-bright);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

@media (prefers-color-scheme: dark) {
  .pillar-badge {
    background: #243a72;
    color: #ffd859;
  }
}

.card-head p.sub {
  color: var(--text-muted);
  font-size: 13.5px;
}

/* --------------------------------------------------------------------------
   Form Grid & Fields
   -------------------------------------------------------------------------- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 700px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.field-grid .col-full {
  grid-column: 1 / -1;
}

.field-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.field-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--head);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.req-star {
  color: var(--err);
  font-style: normal;
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--head);
  background: var(--card-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Highlight for required fields */
.field-highlight {
  background: var(--gold-soft);
  border: 1.5px solid var(--gold-line);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
}

/* Company Autocomplete styling */
.comp-search-box {
  position: relative;
}

.comp-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--card-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.comp-dropdown.show {
  display: block;
}

.comp-option {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.comp-option:last-child {
  border-bottom: none;
}

.comp-option:hover {
  background: var(--card-subtle);
  border-left: 3px solid var(--gold);
}

.comp-opt-name {
  font-weight: 600;
  color: var(--head);
  font-size: 13.5px;
}

.comp-opt-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.comp-opt-tag {
  background: var(--card-subtle);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.autofill-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  margin-top: 4px;
  align-self: flex-start;
}

/* --------------------------------------------------------------------------
   Question Items & Scale Buttons
   -------------------------------------------------------------------------- */
.question-item {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.question-item:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.q-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.q-num {
  background: var(--navy);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  min-width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .q-num {
    background: #243a72;
    color: var(--gold-bright);
  }
}

.q-content {
  flex: 1;
}

.q-text {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--head);
  line-height: 1.5;
}

.q-badge {
  display: inline-flex;
  align-items: center;
  background: var(--card-subtle);
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 6px;
}

/* 0-5 Scale Buttons Grid */
.scale-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

@media (max-width: 820px) {
  .scale-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .scale-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.scale-grid label {
  cursor: pointer;
  display: flex;
  margin: 0;
}

.scale-grid input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scale-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px 6px 10px;
  background: var(--card-bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  user-select: none;
}

.scale-grid label:hover .scale-btn {
  border-color: var(--navy-light);
  background: var(--card-subtle);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.scale-btn .scale-num {
  font-size: 20px;
  font-weight: 800;
  color: var(--head);
  line-height: 1;
  margin-bottom: 6px;
}

.scale-btn .scale-main {
  font-size: 12px;
  font-weight: 700;
  color: var(--head);
  line-height: 1.3;
  margin-bottom: 3px;
}

.scale-btn .scale-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Checked State */
.scale-grid input[type="radio"]:checked + .scale-btn {
  background: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(22, 33, 63, 0.3);
  transform: translateY(-2px);
}

.scale-grid input[type="radio"]:checked + .scale-btn .scale-num {
  color: var(--gold-bright);
}

.scale-grid input[type="radio"]:checked + .scale-btn .scale-main {
  color: #ffffff;
}

.scale-grid input[type="radio"]:checked + .scale-btn .scale-desc {
  color: #cbd5e1;
}

@media (prefers-color-scheme: dark) {
  .scale-grid input[type="radio"]:checked + .scale-btn {
    background: var(--gold-bright);
    border-color: var(--gold-bright);
  }
  .scale-grid input[type="radio"]:checked + .scale-btn .scale-num {
    color: var(--navy-dark);
  }
  .scale-grid input[type="radio"]:checked + .scale-btn .scale-main {
    color: var(--navy-dark);
    font-weight: 800;
  }
  .scale-grid input[type="radio"]:checked + .scale-btn .scale-desc {
    color: #1e293b;
    font-weight: 600;
  }
}

/* --------------------------------------------------------------------------
   Section Under P7: Additional Assessment & Consent (Image 2)
   -------------------------------------------------------------------------- */
.consent-section {
  border-top: 2px dashed var(--gold);
}

.consent-card-box {
  background: var(--card-subtle);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
  transition: var(--transition);
  cursor: pointer;
}

.consent-card-box:hover {
  border-color: var(--gold);
  background: var(--card-bg);
}

.consent-card-box.active {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.consent-header-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.custom-cb {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}

.consent-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--head);
}

.consent-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Expandable details container */
.consent-details {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-left: 3.5px solid var(--gold);
  border-radius: var(--radius-sm);
  display: none;
}

.consent-details.show {
  display: block;
}

.details-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-tag {
  background: var(--card-subtle);
  border: 1px solid var(--line);
  color: var(--head);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}

.benefits-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--head);
  margin-bottom: 6px;
}

.benefits-list {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text);
}

.benefits-list li {
  margin-bottom: 5px;
}

/* Coordinator Callout (ผู้ประสานงาน) */
.coordinator-callout {
  background: var(--card-bg);
  border: 1.5px solid var(--navy-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 18px 0;
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.coordinator-callout.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.coord-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.coord-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--head);
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-info-btn {
  background: var(--card-subtle);
  border: 1px solid var(--line-strong);
  color: var(--head);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.copy-info-btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-hover);
}

/* PDPA Consent Item */
.pdpa-box {
  background: #fdfaf0;
  border: 1.5px solid rgba(201, 162, 39, 0.4);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-top: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

@media (prefers-color-scheme: dark) {
  .pdpa-box {
    background: rgba(201, 162, 39, 0.08);
    border-color: rgba(201, 162, 39, 0.3);
  }
}

.pdpa-box label {
  font-size: 13.5px;
  color: var(--head);
  font-weight: 500;
  line-height: 1.6;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Caller Notes & Actions
   -------------------------------------------------------------------------- */
.action-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--navy);
  color: #ffffff;
  border: 1.5px solid var(--navy);
  border-radius: var(--radius-sm);
  padding: 12px 28px;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(22, 33, 63, 0.2);
}

.btn-primary:hover {
  background: #1e2c52;
  border-color: #1e2c52;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(22, 33, 63, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--text);
  color: var(--head);
  background: var(--card-subtle);
}

.submit-alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: none;
  line-height: 1.5;
}

.submit-alert.show {
  display: block !important;
}

.submit-alert.error {
  background: var(--err-bg);
  border: 1px solid var(--err);
  color: var(--err);
}

.submit-alert.success {
  background: var(--ok-bg);
  border: 1px solid var(--ok);
  color: var(--ok);
}

/* --------------------------------------------------------------------------
   Settings Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--head);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--card-subtle);
  color: var(--head);
}

.modal-body {
  padding: 20px 24px;
}

.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: Consolas, monospace;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  margin: 10px 0;
  white-space: pre;
}

.copy-code-btn {
  background: var(--navy);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
