/* ══════════════════════════════════════════════════════════
   Components — Premium minimalist design system
   Everything should feel intentional and spacious
   ══════════════════════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: var(--r-sm);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--dur) var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--cot); color: var(--text-inv); }
.btn-primary:hover { background: var(--cot-hover); box-shadow: var(--sh-sm); }
.btn-secondary { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--gray-300); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 10px 14px; }
.btn-ghost:hover { background: var(--surface-inset); color: var(--text); }
.btn-outline { background: transparent; border: 1.5px solid var(--cot); color: var(--cot); }
.btn-outline:hover { background: var(--cot-50); }
.btn-danger { background: var(--red); color: var(--text-inv); }
.btn-danger:hover { background: #B91C1C; }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; border-radius: 6px; }
.btn-xs { padding: 5px 10px; font-size: 0.72rem; border-radius: 5px; }
.btn-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ── */
label.field {
  display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.required::after { content: ' *'; color: var(--red); }
input[type=text], input[type=email], select, textarea {
  width: 100%; padding: 10px 14px; font: inherit; font-size: 0.88rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder, select option[value=""] { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--cot); box-shadow: var(--sh-focus);
}
.field-error { border-color: var(--red) !important; box-shadow: 0 0 0 4px rgba(220,38,38,0.08) !important; }
select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-bottom: var(--s4); }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════════════════
   WIZARD — The core assessment experience
   ══════════════════════════════════════════════════════════ */

.wizard {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 var(--s4);
}

/* Progress bar — fixed below nav, full viewport width */
.wizard-progress {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 99;
  height: 3px; background: var(--border-light);
}
.wizard-progress .fill {
  height: 100%; background: var(--cot);
  border-radius: 0 2px 2px 0;
  transition: width 0.4s var(--ease);
}

/* Breadcrumb — minimal context */
.wizard-breadcrumb {
  text-align: center;
  padding: var(--s6) 0 var(--s4);
  font-size: 0.75rem;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.wizard-breadcrumb .active { color: var(--text-2); font-weight: 500; }

/* Step tracker — horizontal dots */
.wizard-steps {
  display: flex; justify-content: center; gap: 6px;
  padding-bottom: var(--s6);
}
.wizard-steps .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: all var(--dur) var(--ease);
}
.wizard-steps .dot.done { background: var(--green); }
.wizard-steps .dot.active { background: var(--cot); transform: scale(1.4); }

/* Question card — the star of every screen */
.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s10) var(--s8);
  margin-bottom: var(--s5);
  box-shadow: var(--sh-md);
  animation: fadeIn 0.25s var(--ease);
}

/* Question text — big, clear, unmissable */
.wizard-q-text {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.02em;
  margin-bottom: var(--s2);
}

/* Help text */
.wizard-q-help {
  font-size: 0.82rem;
  color: var(--text-3);
  line-height: 1.5;
  margin-bottom: var(--s2);
}

/* Meta row — question number + weight */
.wizard-q-meta {
  display: flex; align-items: center; gap: var(--s3);
  margin-bottom: var(--s8);
}
.wizard-q-num {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-3); letter-spacing: 0.04em;
}
.wizard-q-weight {
  font-size: 0.68rem; font-weight: 500;
  color: var(--text-3); background: var(--surface-inset);
  padding: 3px 10px; border-radius: var(--r-pill);
}

/* ── Answer Cards ── */
.wizard-answers {
  display: flex; flex-direction: column; gap: 10px;
}

.wizard-answer {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  font-size: 0.88rem;
  color: var(--text-2);
  user-select: none;
  min-height: 52px;
}
.wizard-answer:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}
.wizard-answer:focus-visible {
  outline: none;
  border-color: var(--cot);
  box-shadow: var(--sh-focus);
}
.wizard-answer.highlighted {
  border-color: var(--gray-300);
  background: var(--gray-50);
}
.wizard-answer.selected {
  border-color: var(--cot);
  background: var(--cot-50);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--cot-200);
}

/* Letter badge */
.wizard-answer .letter {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-inset);
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  flex-shrink: 0;
  transition: all var(--dur) var(--ease);
}
.wizard-answer.selected .letter {
  background: var(--cot); color: var(--text-inv);
}
.wizard-answer .text { flex: 1; line-height: 1.4; }

/* N/A answer */
.wizard-answer.na {
  border-style: dashed;
  color: var(--text-3);
}
.wizard-answer.na .letter {
  background: transparent;
  border: 1.5px dashed var(--gray-300);
}

/* ── Wizard Navigation ── */
.wizard-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--s3) 0 var(--s8);
}
.wizard-nav .center { flex: 1; text-align: center; }

/* ── AI Assistant Panel ── */
.wizard-ai {
  margin-top: var(--s5);
  border-top: 1px solid var(--border-light);
  padding-top: var(--s4);
}
.wizard-ai-toggle {
  font: inherit; font-size: 0.78rem; color: var(--text-3);
  background: none; border: none; cursor: pointer; padding: 4px 0;
  display: flex; align-items: center; gap: 6px;
  transition: color var(--dur) var(--ease);
}
.wizard-ai-toggle:hover { color: var(--cot); }

.wizard-ai-content {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.3s var(--ease), opacity 0.2s var(--ease);
}
.wizard-ai-content.open {
  max-height: 500px; opacity: 1; padding-top: var(--s3);
}

/* Guidance text block */
.wizard-ai-guidance {
  font-size: 0.82rem; color: var(--text-2); line-height: 1.6;
  background: var(--surface-inset); padding: var(--s4); border-radius: var(--r-sm);
}

/* Chat messages */
.wizard-ai-chat {
  max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3) 0;
}
.ai-msg {
  max-width: 85%; padding: 10px 14px;
  border-radius: var(--r-md); font-size: 0.82rem; line-height: 1.5;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--cot); color: var(--text-inv);
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--surface-inset); color: var(--text-2);
  border-bottom-left-radius: 4px;
}

/* Chat input */
.wizard-ai-input {
  display: flex; gap: 8px; margin-top: var(--s2);
}
.wizard-ai-input input {
  flex: 1; padding: 8px 12px; font-size: 0.82rem;
  border-radius: var(--r-sm);
}
.wizard-ai-input .btn { flex-shrink: 0; }

/* ── Section Summary ── */
.wizard-summary {
  text-align: center;
  padding: var(--s12) var(--s6);
  animation: fadeIn 0.3s var(--ease);
}
.wizard-summary .icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--green-bg); color: var(--green);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: var(--s4); font-size: 1.4rem;
  animation: scaleIn 0.4s var(--ease);
}
.wizard-summary h3 { font-size: 1.15rem; margin-bottom: var(--s2); }
.wizard-summary .stats {
  font-size: 0.85rem; color: var(--text-2); margin-bottom: var(--s6);
}

/* ── Assessment Complete ── */
.assessment-complete {
  text-align: center; padding: var(--s12) var(--s6);
}
.assessment-complete .check {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green); color: var(--text-inv);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; margin-bottom: var(--s5);
  animation: scaleIn 0.5s var(--ease);
}

/* ══════════════════════════════════════════════════════════
   Phase Selection Tiles
   ══════════════════════════════════════════════════════════ */

.phase-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 600px) { .phase-grid { grid-template-columns: 1fr; } }

.phase-tile {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5);
  cursor: pointer; transition: all var(--dur) var(--ease);
  position: relative;
}
.phase-tile:hover { border-color: var(--gray-300); box-shadow: var(--sh-sm); }
.phase-tile.selected {
  border-color: var(--cot); background: var(--cot-50);
  box-shadow: 0 0 0 1px var(--cot-200);
}
.phase-tile .tile-check {
  position: absolute; top: var(--s3); right: var(--s3);
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); display: flex;
  align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease);
}
.phase-tile.selected .tile-check {
  background: var(--cot); border-color: var(--cot); color: var(--text-inv);
}
.phase-tile h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: var(--s1); color: var(--text); }
.phase-tile .tile-desc { font-size: 0.78rem; color: var(--text-3); line-height: 1.4; }
.phase-tile .tile-count {
  margin-top: var(--s3); font-size: 0.72rem; font-weight: 500; color: var(--text-3);
}

/* ══════════════════════════════════════════════════════════
   Results
   ══════════════════════════════════════════════════════════ */

/* Category hero */
.cat-hero {
  border-radius: var(--r-xl); padding: var(--s10) var(--s6);
  text-align: center; color: var(--text-inv);
  margin-bottom: var(--s4);
}
.cat-hero.c1 { background: linear-gradient(135deg, #059669, #10B981); }
.cat-hero.c2 { background: linear-gradient(135deg, #B45309, #F59E0B); }
.cat-hero.c3 { background: linear-gradient(135deg, #C2410C, #F97316); }
.cat-hero.c4 { background: linear-gradient(135deg, #991B1B, #EF4444); }
.cat-hero.none { background: var(--gray-700); }
.cat-hero .cat-num {
  font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -0.04em;
}
.cat-hero .cat-label { font-size: 1rem; opacity: 0.85; margin-top: var(--s2); }
.cat-hero .cat-desc {
  font-size: 0.82rem; opacity: 0.7; margin-top: var(--s2);
  max-width: 420px; margin-left: auto; margin-right: auto; line-height: 1.5;
}

/* Result tiles */
.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
@media (max-width: 600px) { .results-grid { grid-template-columns: 1fr; } }
.result-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--s5) var(--s4);
  text-align: center;
}
.result-tile .label {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-3); margin-bottom: var(--s2);
}
.result-tile .score {
  font-size: 2.2rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: var(--s1);
}
.result-tile .level {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 3px 12px; border-radius: var(--r-pill);
}
/* Category color variants */
.result-tile.low .score { color: var(--green); }
.result-tile.low .level { background: var(--green-bg); color: var(--green); }
.result-tile.medium .score { color: var(--amber); }
.result-tile.medium .level { background: var(--amber-bg); color: var(--amber); }
.result-tile.high .score { color: var(--red); }
.result-tile.high .level { background: var(--red-bg); color: var(--red); }
.result-tile.cat-1 { border-left: 3px solid var(--green); }
.result-tile.cat-2 { border-left: 3px solid var(--amber); }
.result-tile.cat-3 { border-left: 3px solid var(--orange); }
.result-tile.cat-4 { border-left: 3px solid var(--red); }

/* Score bars */
.score-bar { height: 6px; background: var(--surface-inset); border-radius: var(--r-pill); overflow: hidden; margin: 6px 0; }
.score-bar .fill { height: 100%; border-radius: var(--r-pill); transition: width 0.6s var(--ease); }
.score-bar .fill.low { background: var(--green); }
.score-bar .fill.medium { background: var(--amber); }
.score-bar .fill.high { background: var(--red); }

/* Phase result block */
.phase-result {
  padding: var(--s5); background: var(--surface-inset);
  border-radius: var(--r-md); margin-bottom: var(--s3);
}
.phase-result h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: var(--s3); }

/* Legend */
.legend-row { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: 0.75rem; color: var(--text-3); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ══════════════════════════════════════════════════════════
   Lookup Table
   ══════════════════════════════════════════════════════════ */
.lookup-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border-radius: var(--r-sm); overflow: hidden; font-size: 0.82rem;
  border: 1px solid var(--border);
}
.lookup-table th, .lookup-table td { padding: 10px 14px; text-align: center; }
.lookup-table th {
  background: var(--charcoal); color: var(--text-inv);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.lookup-table td { background: var(--surface); border-top: 1px solid var(--border); }
.lookup-table .highlight { font-weight: 800; background: var(--cot-50) !important; }

/* ══════════════════════════════════════════════════════════
   Misc Components
   ══════════════════════════════════════════════════════════ */

/* Badges */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.draft { background: var(--amber-bg); color: var(--amber); }
.badge.final { background: var(--green-bg); color: var(--green); }

/* Info boxes */
.info-box {
  background: var(--cot-50); border: 1px solid var(--cot-200);
  border-radius: var(--r-sm); padding: var(--s3) var(--s4);
  font-size: 0.82rem; color: var(--cot-active); line-height: 1.5;
  margin-bottom: var(--s4);
}
.warn-box {
  background: var(--amber-bg); border: 1px solid var(--amber-border);
  border-radius: var(--r-sm); padding: var(--s3) var(--s4);
  font-size: 0.82rem; color: var(--amber); line-height: 1.5;
  margin-bottom: var(--s4);
}
.error-box {
  background: var(--red-bg); border: 1px solid var(--red-border);
  border-radius: var(--r-sm); padding: var(--s3) var(--s4);
  font-size: 0.82rem; color: var(--red); line-height: 1.5;
  margin-bottom: var(--s4);
}

/* Saved assessment items */
.saved-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s3) var(--s4); background: var(--surface-inset);
  border-radius: var(--r-sm); margin-bottom: var(--s2); gap: var(--s3);
}
.saved-item .si-info { flex: 1; min-width: 0; }
.saved-item .si-info strong {
  display: block; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.saved-item .si-info span { font-size: 0.72rem; color: var(--text-3); }
.saved-item .si-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Toast */
.toast {
  position: fixed; bottom: var(--s6); left: 50%; transform: translateX(-50%);
  background: var(--gray-800); color: var(--text-inv);
  padding: 10px 24px; border-radius: var(--r-sm);
  font-size: 0.82rem; font-weight: 500;
  z-index: 400; box-shadow: var(--sh-lg);
  animation: fadeIn 0.2s var(--ease), toastOut 0.2s var(--ease) 2.3s forwards;
}
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* How-it-works grid */
.how-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); }
@media (max-width: 600px) { .how-grid { grid-template-columns: repeat(2, 1fr); } }
.how-step { text-align: center; padding: var(--s4) var(--s2); }
.how-step .num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--cot-50); color: var(--cot);
  font-weight: 800; font-size: 0.88rem;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: var(--s2);
}
.how-step strong { display: block; font-size: 0.82rem; color: var(--text); margin-bottom: 2px; }
.how-step span { font-size: 0.72rem; color: var(--text-3); line-height: 1.4; }

/* Spinner */
.spinner {
  width: 24px; height: 24px; border: 2.5px solid var(--border);
  border-top-color: var(--cot); border-radius: 50%;
  animation: spin 0.6s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-inset) 25%, var(--border-light) 50%, var(--surface-inset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm); height: 16px;
}

/* Section badge */
.section-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.section-badge.risk { background: var(--red-bg); color: var(--red); }
.section-badge.complexity { background: var(--amber-bg); color: var(--amber); }

/* Counter */
.counter { font-size: 0.75rem; color: var(--text-3); }

/* Print elements (hidden on screen) */
.print-header { display: none; }
.print-signature { display: none; }
.no-print {}

/* ── Responsive for wizard ── */
@media (max-width: 600px) {
  .wizard-card { padding: var(--s6) var(--s5); border-radius: var(--r-lg); }
  .wizard-q-text { font-size: 1.1rem; }
  .wizard-answer { padding: 12px 14px; min-height: 48px; }
  .wizard-answer .letter { width: 28px; height: 28px; font-size: 0.7rem; }
  .results-grid { grid-template-columns: 1fr; }
  .phase-grid { grid-template-columns: 1fr; }
}
