/* ============================================================
   FastTriage VRS — Design System
   Basado en: wwwroot/sample/fasttriage-redesign.html
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #EEF4F2;
  --white:       #FFFFFF;
  --primary:     #1A7B6B;
  --primary-lt:  #E6F4F1;
  --primary-md:  #B2DEDA;
  --primary-dk:  #145F53;
  --red:         #C0392B;
  --red-lt:      #FDECEA;
  --red-bd:      #E8B4B0;
  --text:        #1A2B26;
  --text-2:      #4A6860;
  --text-3:      #8AADA6;
  --border:      #D0E4E0;
  --shadow:      0 1px 3px rgba(26,123,107,0.08), 0 4px 12px rgba(26,123,107,0.06);
  --font:        'IBM Plex Sans', system-ui, sans-serif;
  --radius:      16px;

  /* Editor */
  --ed-primary:    #0f766e;
  --ed-primary-dk: #134e4a;
  --ed-primary-lt: #ccfbf1;
  --ed-muted:      #6b7280;
  --ed-border:     #d1d5db;
  --ed-danger:     #b91c1c;
  --ed-danger-lt:  #fef2f2;
}

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#root {
  height: 100%; height: 100dvh;
  overflow: hidden;
}

/* ── Loading / Error ───────────────────────────────────────── */
.app-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; height: 100dvh;
  background: var(--bg);
  font-family: var(--font);
  gap: 1rem;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--primary-md);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-3); font-size: 0.9rem; font-weight: 500; }

.error-card {
  background: var(--white); border: 1.5px solid var(--red-bd);
  border-radius: var(--radius); padding: 2rem 1.5rem;
  text-align: center; max-width: 320px;
  display: flex; flex-direction: column; gap: 0.5rem;
  box-shadow: var(--shadow);
}
.error-icon { font-size: 2.5rem; color: var(--red); }
.error-card p     { margin: 0; font-weight: 600; color: var(--red); }
.error-card small { color: var(--text-3); font-size: 0.8rem; }

/* ── Auth ──────────────────────────────────────────────────── */
.auth-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; height: 100dvh;
  background: var(--bg); padding: 1.5rem;
  font-family: var(--font);
}
.auth-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.25rem 1.75rem;
  width: min(100%, 340px);
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: var(--shadow);
}
.auth-icon  { font-size: 2rem; text-align: center; color: var(--primary); }
.auth-title { margin: 0; font-size: 1.3rem; font-weight: 600; color: var(--text); text-align: center; }
.auth-sub   { margin: 0; font-size: 0.85rem; color: var(--text-3); text-align: center; }
.auth-form  { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-input {
  width: 100%; padding: 0.9rem 1rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: var(--font);
  background: var(--bg); color: var(--text);
  transition: border-color 0.15s;
  -webkit-appearance: none; appearance: none;
}
.auth-input:focus { outline: none; border-color: var(--primary); background: var(--white); }
.auth-input--error { border-color: var(--red); }
.auth-error { margin: 0; font-size: 0.82rem; color: var(--red); font-weight: 600; text-align: center; }

/* shared buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.9rem 1.25rem; border: 1.5px solid transparent;
  border-radius: 10px; font-size: 0.95rem; font-weight: 500; font-family: var(--font);
  cursor: pointer; min-height: 50px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); filter: brightness(0.96); }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dk); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--white); color: var(--text-2); border-color: var(--border); }

/* ── Quiz shell ────────────────────────────────────────────── */
.quiz-app {
  display: flex; flex-direction: column;
  height: 100%; height: 100dvh;
  max-width: 430px; margin: 0 auto;
  overflow: hidden; position: relative;
  background: var(--bg);
}

/* ── Header ────────────────────────────────────────────────── */
.qz-header {
  background: var(--primary);
  padding: max(env(safe-area-inset-top, 0px), 0px) 0 0;
  flex-shrink: 0;
}
.qz-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
}
.qz-header-left { display: flex; align-items: center; gap: 12px; }
.qz-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.qz-logo svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.qz-title    { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -0.01em; }
.qz-subtitle { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 1px; font-weight: 400; }
.qz-counter {
  background: rgba(255,255,255,0.18); border-radius: 20px; padding: 5px 13px;
  display: flex; align-items: baseline; gap: 1px;
}
.qz-counter-n     { font-size: 17px; font-weight: 600; color: #fff; line-height: 1; }
.qz-counter-sep,
.qz-counter-total { font-size: 12px; color: rgba(255,255,255,0.6); line-height: 1; }

/* ── Progress ──────────────────────────────────────────────── */
.qz-progress-wrap { background: var(--primary); padding: 0 20px 14px; flex-shrink: 0; }
.qz-progress-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.qz-group-chip {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.08em; color: rgba(255,255,255,0.75);
}
.qz-progress-pct { font-size: 11px; color: rgba(255,255,255,0.55); }
.qz-progress-track { height: 4px; background: rgba(255,255,255,0.2); border-radius: 4px; overflow: visible; position: relative; }
.qz-progress-fill {
  height: 100%; border-radius: 4px; background: #fff;
  transition: width 0.55s cubic-bezier(0.4,0,0.2,1); position: relative;
}
.qz-progress-fill::after {
  content: ''; position: absolute; right: -4px; top: -3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

/* ── Question area ─────────────────────────────────────────── */
.qz-question-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px 18px; overflow: hidden; position: relative;
}
.question-card {
  width: 100%;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px 24px;
  box-shadow: var(--shadow); position: absolute;
  transition: transform 0.38s cubic-bezier(0.4,0,0.2,1), opacity 0.38s ease;
}
.question-card.state-enter  { transform: translateX(60px);  opacity: 0; }
.question-card.state-active { transform: translateX(0);     opacity: 1; }
.question-card.state-exit   { transform: translateX(-60px); opacity: 0; }

.q-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-lt); border: 1px solid var(--primary-md);
  border-radius: 6px; padding: 4px 10px;
  font-size: 11px; font-weight: 500; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 18px;
}
.q-tag-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.q-text { font-size: 22px; font-weight: 500; line-height: 1.38; color: var(--text); letter-spacing: -0.01em; }

/* ── Actions ───────────────────────────────────────────────── */
.qz-actions {
  padding: 0 18px max(env(safe-area-inset-bottom, 20px), 20px);
  flex-shrink: 0;
}
.btn-back {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; width: 100%;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--white); color: var(--text-2);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; margin-bottom: 10px;
  transition: transform 0.12s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent; outline: none;
  box-shadow: var(--shadow);
}
.btn-back:active { transform: scale(0.98); background: var(--bg); }
.btn-back svg { width: 15px; height: 15px; stroke: var(--text-3); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-back.hidden { visibility: hidden; pointer-events: none; }

.qz-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-choice {
  display: flex; align-items: center; justify-content: center;
  height: 68px; border-radius: 12px; border: 1.5px solid transparent;
  cursor: pointer; outline: none;
  transition: transform 0.12s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-choice:active { transform: scale(0.96); filter: brightness(0.96); }
.btn-choice--pressed { transform: scale(0.94) !important; filter: brightness(0.88) !important; }
.btn-no  { background: var(--red-lt);  border-color: var(--red-bd); }
.btn-yes { background: var(--primary); border-color: var(--primary-dk); }
.btn-choice-label { font-size: 20px; font-weight: 600; letter-spacing: 0.06em; line-height: 1; }
.btn-no  .btn-choice-label { color: var(--red); }
.btn-yes .btn-choice-label { color: #fff; }

/* ── Result ────────────────────────────────────────────────── */
.result-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; height: 100dvh;
  padding: 36px 20px max(env(safe-area-inset-bottom, 32px), 32px);
  text-align: center; background: var(--bg);
  font-family: var(--font);
  animation: rsIn 0.4s ease; overflow-y: auto;
}
@keyframes rsIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-icon-wrap {
  width: 72px; height: 72px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px; border: 1.5px solid;
}
.result-icon-wrap.positive { background: var(--red-lt); border-color: var(--red-bd); }
.result-icon-wrap.positive svg { stroke: var(--red); }
.result-icon-wrap.negative { background: var(--primary-lt); border-color: var(--primary-md); }
.result-icon-wrap.negative svg { stroke: var(--primary); }
.result-icon-wrap svg { width: 36px; height: 36px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.result-title { font-size: 26px; font-weight: 600; margin-bottom: 10px; line-height: 1.2; }
.result-title.positive { color: var(--red); }
.result-title.negative { color: var(--primary); }
.result-subtitle { font-size: 15px; color: var(--text-2); line-height: 1.6; max-width: 280px; margin: 0 auto 24px; font-weight: 400; }
.result-veredicto {
  font-size: 17px; font-weight: 600; margin-bottom: 32px;
  padding: 12px 24px; border-radius: 10px; border: 1.5px solid;
}
.result-veredicto--positive { background: var(--red-lt); border-color: var(--red-bd); color: var(--red); }
.result-veredicto--negative { background: var(--primary-lt); border-color: var(--primary-md); color: var(--primary); }
.btn-restart {
  width: 100%; max-width: 360px; height: 56px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--white); color: var(--text-2);
  font-family: var(--font); font-size: 15px; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease;
}
.btn-restart:active { transform: scale(0.98); }

/* ══════════════════════════════════════════════════════════════
   EDITOR
   ══════════════════════════════════════════════════════════════ */
.ed-root {
  position: fixed; inset: 0; background: #f0fdf9;
  display: flex; flex-direction: column;
  font-family: var(--font); overflow-y: auto; overflow-x: hidden;
}
.ed-topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ed-primary); color: #fff;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.ed-back-btn {
  background: none; border: none; color: #fff;
  padding: 0.4rem; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  min-width: 2.5rem; min-height: 2.5rem;
  -webkit-tap-highlight-color: transparent; transition: background 0.15s;
}
.ed-back-btn:active { background: rgba(255,255,255,0.15); }
.ed-topbar-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ed-topbar-sub  { font-size: 0.68rem; opacity: 0.75; letter-spacing: 0.05em; }
.ed-topbar-main { font-size: 1.05rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-count-chip  { background: rgba(255,255,255,0.2); border-radius: 99px; font-size: 0.8rem; font-weight: 600; padding: 0.2rem 0.7rem; }
.ed-actions-bar { display: flex; gap: 0.6rem; padding: 0.75rem 1rem; background: var(--ed-primary-dk); }
.ed-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.65rem 0.5rem; border-radius: 10px; border: none;
  font-size: 0.88rem; font-weight: 500; font-family: var(--font);
  cursor: pointer; min-height: 2.75rem;
  -webkit-tap-highlight-color: transparent;
}
.ed-action-btn--white { background: #fff; color: var(--ed-primary); }
.ed-action-btn--white:active { background: var(--ed-primary-lt); }
.ed-action-btn--ghost { background: rgba(255,255,255,0.12); color: #fff; border: 1.5px solid rgba(255,255,255,0.3); }
.ed-action-btn--ghost:active { background: rgba(255,255,255,0.22); }
.ed-main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 1rem 0.9rem 6rem; box-sizing: border-box; }
.ed-empty { text-align: center; color: var(--ed-muted); margin-top: 4rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.ed-empty-icon { font-size: 3rem; }
.ed-empty p    { font-size: 1rem; font-weight: 600; margin: 0; }
.ed-empty small { font-size: 0.875rem; }
.ed-sections { display: flex; flex-direction: column; gap: 1.25rem; }
.ed-section  { display: flex; flex-direction: column; gap: 0; }
.ed-section-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0.25rem 0.5rem; }
.ed-section-title { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ed-primary); }
.ed-section-count { background: var(--ed-primary-lt); color: var(--ed-primary); font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 99px; }
.ed-section-cards { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,0.07); }
.ed-item {
  width: 100%; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1rem; background: none; border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer; text-align: left; min-height: 3.25rem;
  -webkit-tap-highlight-color: transparent; transition: background 0.1s;
}
.ed-item:last-child { border-bottom: none; }
.ed-item:active { background: #f0fdf9; }
.ed-item-num { flex-shrink: 0; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--ed-primary-lt); color: var(--ed-primary); font-size: 0.75rem; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.ed-item-text { flex: 1; font-size: 0.9rem; color: #212121; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ed-chip { flex-shrink: 0; padding: 0.2rem 0.55rem; border-radius: 99px; font-weight: 500; font-size: 0.65rem; white-space: nowrap; }
.ed-chip--ok { background: #d1fae5; color: #065f46; }
.ed-chip--no { background: #f3f4f6; color: #6b7280; }
.ed-btn { display: flex; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.8rem 1rem; border: none; border-radius: 10px; font-size: 0.92rem; font-weight: 500; cursor: pointer; min-height: 2.9rem; font-family: var(--font); -webkit-tap-highlight-color: transparent; box-sizing: border-box; transition: background 0.15s; }
.ed-btn--full { width: 100%; }
.ed-btn--mt   { margin-top: 0.5rem; }
.ed-btn--primary        { background: var(--ed-primary); color: #fff; }
.ed-btn--primary:active { background: var(--ed-primary-dk); }
.ed-btn--danger         { background: var(--ed-danger); color: #fff; }
.ed-btn--danger:active  { background: #991b1b; }
.ed-btn--ghost { background: transparent; color: var(--ed-muted); border: 2px solid var(--ed-border); }
.ed-btn--ghost:active { background: #f5f5f5; }
.ed-btn--del-outline { background: transparent; color: var(--ed-danger); border: 2px solid #fca5a5; }
.ed-btn--del-outline:active { background: var(--ed-danger-lt); }
.ed-label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ed-primary); }
.ed-input { width: 100%; padding: 0.8rem 1rem; border: 2px solid var(--ed-border); border-radius: 10px; font-size: 1rem; background: #fff; color: #212121; box-sizing: border-box; transition: border-color 0.15s; -webkit-appearance: none; appearance: none; font-family: var(--font); }
.ed-input:focus { outline: none; border-color: var(--ed-primary); }
.ed-textarea { resize: vertical; line-height: 1.45; min-height: 5rem; }
.ed-del-confirm { background: var(--ed-danger-lt); border: 2px solid #fca5a5; border-radius: 10px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem; }
.ed-del-msg { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--ed-danger); text-align: center; }
.ed-del-btns { display: flex; gap: 0.5rem; }
.ed-del-btns .ed-btn { flex: 1; }
.ed-fab { position: fixed; bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem)); right: 1.25rem; z-index: 30; width: 3.75rem; height: 3.75rem; border-radius: 50%; background: var(--ed-primary); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,0.25); -webkit-tap-highlight-color: transparent; transition: background 0.15s, transform 0.1s; }
.ed-fab:active { background: var(--ed-primary-dk); transform: scale(0.93); }
.ed-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.45); backdrop-filter: blur(2px); }
.ed-sheet { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: #fff; border-radius: 22px 22px 0 0; padding: 0.5rem 1.25rem; padding-bottom: max(2rem, env(safe-area-inset-bottom, 2rem)); display: flex; flex-direction: column; gap: 1rem; max-height: 92vh; overflow-y: auto; box-shadow: 0 -4px 24px rgba(0,0,0,0.12); animation: sheetUp 0.25s cubic-bezier(.4,0,.2,1); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.ed-sheet-handle { display: block; width: 2.5rem; height: 4px; background: #e0e0e0; border-radius: 99px; margin: 0.5rem auto 0; }
.ed-sheet-title { margin: 0; font-size: 1.1rem; font-weight: 600; color: #212121; text-align: center; }
.ed-toast { position: fixed; bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0px) + 5.5rem)); left: 50%; transform: translateX(-50%); z-index: 60; padding: 0.65rem 1.25rem; border-radius: 99px; font-size: 0.88rem; font-weight: 500; font-family: var(--font); white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.2); animation: toastIn 0.2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.ed-toast--ok   { background: var(--ed-primary); color: #fff; }
.ed-toast--warn { background: #f59e0b; color: #fff; }
.ed-toast--err  { background: var(--ed-danger);  color: #fff; }
