/* ══════════════════════════════════════════════════════════════════
   SCEI Public Form Renderer — Styles
   One-question-at-a-time Typeform-style UX
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* Aura Health Rehab palette */
  --primary: #4a8073;        /* primary green — buttons, accents */
  --primary-dark: #244952;   /* deep teal — hover, headings */
  --primary-light: #edf3d9;  /* light green — tints, backgrounds */
  --accent: #c69849;         /* gold accent */
  --accent-2: #cf9d88;       /* clay accent */
  --text: #244952;
  --text-light: #5b7077;
  --text-muted: #9bb0ac;
  --white: #ffffff;
  --bg: #f6f8ef;
  --border: #dde6d2;
  --error: #e53e3e;
  --success: #4a8073;
  --radius: 12px;
  --font-display: 'Montserrat', 'Century Gothic', sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Loading ─────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--text-muted);
  font-size: 14px;
}

.loader-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--border);
  z-index: 100;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .3s ease;
  width: 0;
}

/* ── Welcome Screen ──────────────────────────────────────────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--white) 50%);
}

.welcome-logo {
  width: 150px;
  height: auto;
  margin-bottom: 24px;
}

.welcome-screen h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  max-width: 600px;
  line-height: 1.3;
}

.welcome-screen .welcome-desc {
  font-size: 15px;
  color: var(--text-light);
  max-width: 520px;
  line-height: 1.7;
  margin-bottom: 32px;
}

.welcome-screen .welcome-desc em { font-style: italic; }

/* ── Access Code Gate ────────────────────────────────────────── */
.code-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.code-gate h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.code-gate p {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}

.code-input {
  width: 280px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: monospace;
  text-align: center;
  letter-spacing: .1em;
  outline: none;
  transition: border-color .2s;
}

.code-input:focus { border-color: var(--primary); }

.code-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(27,63,56,.25);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-sm { padding: 10px 20px; font-size: 13px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 16px;
  color: var(--text);
}

.btn-icon:hover { border-color: var(--primary); background: var(--primary-light); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }

/* ── Question Slide ──────────────────────────────────────────── */
.question-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.question-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 24px 120px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn .3s ease;
}

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

.question-number {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

.question-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
}

.question-title .required-star { color: var(--error); }

.question-desc {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
  margin-bottom: 24px;
}

.question-desc:empty { display: none; }

/* ── Text Inputs ─────────────────────────────────────────────── */
.field-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  background: var(--white);
}

.field-input:focus { border-color: var(--primary); }

.field-input::placeholder { color: var(--text-muted); }

textarea.field-input {
  min-height: 120px;
  resize: vertical;
}

/* ── Staff-name autocomplete (opt-in via a field's properties.autocomplete
      === 'staff' in its form-def) ──────────────────────────────── */
.field-with-suggestions { position: relative; }

.staff-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(36, 73, 82, .14);
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
}

.staff-suggestions.open { display: block; }

.staff-suggestion-item {
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
}

.staff-suggestion-item:hover,
.staff-suggestion-item.highlighted {
  background: var(--primary-light);
}

.staff-suggestion-item + .staff-suggestion-item { border-top: 1px solid var(--border); }

/* ── Multiple Choice / Checkbox ──────────────────────────────── */
.choice-exclude-note {
  font-size: 13px;
  color: var(--text-light);
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
}

.choice-btn:hover { border-color: var(--primary); background: var(--primary-light); }

.choice-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  flex-shrink: 0;
  margin-top: 1px; /* keeps the key box aligned with the first text line now that .choice-btn is align-items:flex-start (needed for the optional 2-line label+description case below) */
  transition: border-color .15s, background .15s, color .15s;
}

.choice-btn.selected .choice-key {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.choice-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice-label { flex: 1; }

.choice-desc {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
  line-height: 1.4;
}

.other-input {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
  display: none;
}

.other-input.visible { display: block; }
.other-input:focus { border-color: var(--primary); }

/* ── Yes / No ────────────────────────────────────────────────── */
.yesno-row {
  display: flex;
  gap: 12px;
}

.yesno-btn {
  flex: 1;
  padding: 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}

.yesno-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.yesno-btn.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

/* ── Opinion Scale ───────────────────────────────────────────── */
.scale-container { text-align: center; }

.scale-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.scale-btn {
  width: 52px; height: 52px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scale-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.scale-btn.selected { border-color: var(--primary); background: var(--primary); color: var(--white); }

.scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-display);
}

/* ── Dropdown ────────────────────────────────────────────────── */
.field-select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text);
  background: var(--white);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%23718096'%3E%3Cpath d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
  transition: border-color .2s;
}

.field-select:focus { border-color: var(--primary); }

/* ── Date ────────────────────────────────────────────────────── */
input[type="date"].field-input { cursor: pointer; }

/* ── Contact Info / Address ──────────────────────────────────── */
.composite-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.composite-field label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}

.composite-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── File Upload ─────────────────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-drop-icon { font-size: 32px; margin-bottom: 8px; }

.file-drop-text {
  font-size: 14px;
  color: var(--text-light);
}

.file-drop-text strong { color: var(--primary); }

.file-preview {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.file-preview .file-name { flex: 1; color: var(--text); }
.file-preview .file-remove {
  color: var(--error);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width .2s;
}

/* ── Statement ───────────────────────────────────────────────── */
.statement-text {
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
}

/* ── Navigation Footer ───────────────────────────────────────── */
.nav-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.nav-left { display: flex; gap: 8px; }

.nav-footer .btn-next {
  margin-left: auto;
}

/* ── Validation Error ────────────────────────────────────────── */
.field-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 8px;
  min-height: 0;
}

/* ── Thank You Screen ────────────────────────────────────────── */
.thankyou-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--white) 50%);
}

.thankyou-icon {
  width: 64px; height: 64px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--white);
  margin-bottom: 24px;
}

.thankyou-screen h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  max-width: 500px;
}

.thankyou-screen p {
  font-size: 15px;
  color: var(--text-light);
  max-width: 480px;
  line-height: 1.7;
}

/* ── Error Screen ────────────────────────────────────────────── */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.error-screen h1 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 8px;
}

.error-screen p {
  color: var(--text-light);
  font-size: 14px;
}

/* ── Submitting overlay ──────────────────────────────────────── */
.submitting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-light);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .welcome-screen h1 { font-size: 22px; }
  .question-title { font-size: 18px; }
  .question-slide { padding: 24px 18px 100px; }
  .composite-row { grid-template-columns: 1fr; }
  .scale-btn { width: 44px; height: 44px; font-size: 16px; }
  .yesno-row { flex-direction: column; }
}
