/* ============================================================================
   PanicLab — Sistem Reka Bentuk Playbook Interaktif, Visual & Mesra Pesakit
   Supports Dark Theme (Default Calm Night) & Light Theme + Calm Motion Mode
   ============================================================================ */

:root {
  --bg-base: #07111a;
  --bg-surface: #0d1b2a;
  --bg-card: #122436;
  --bg-elevated: #1a324a;
  --border-subtle: rgba(148, 184, 206, 0.16);
  --border-strong: rgba(45, 212, 191, 0.45);
  --text-primary: #f0f7fa;
  --text-secondary: #cbdce7;
  --text-muted: #8da6b8;
  --accent-teal: #2dd4bf;
  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-violet: #a78bfa;
  --accent-danger: #ef4444;
  --shadow-card: 0 14px 34px rgba(3, 9, 18, 0.46);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

body.light-theme {
  --bg-base: #f1f7f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-elevated: #e3f0f4;
  --border-subtle: rgba(15, 35, 52, 0.12);
  --border-strong: rgba(13, 148, 136, 0.45);
  --text-primary: #0f2230;
  --text-secondary: #304758;
  --text-muted: #5c7485;
  --accent-teal: #0d9488;
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-violet: #6d28d9;
  --accent-danger: #dc2626;
  --shadow-card: 0 10px 26px rgba(15, 35, 52, 0.07);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 14% 0%, rgba(45, 212, 191, 0.11), transparent 40%),
    radial-gradient(circle at 86% 6%, rgba(56, 189, 248, 0.1), transparent 36%),
    var(--bg-base);
  color: var(--text-primary);
  line-height: 1.64;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent-teal);
  outline-offset: 2px;
}

/* Dual Audience Visibility */
body.mode-layman .clinical-only {
  display: none !important;
}
body.mode-clinical .layman-only {
  display: none !important;
}

/* Calm Motion Override */
body.calm-motion *,
body.calm-motion *::before,
body.calm-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ======================= TOP STICKY HEADER ======================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 20, 32, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.92);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #14b8a6, #0284c7);
  display: grid;
  place-items: center;
  font-size: 19px;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.38);
  flex-shrink: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 1.06rem;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.15;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  transition: background 0.18s, color 0.18s;
}

.nav-links a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-links a.nav-emergency {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

body.light-theme .nav-links a.nav-emergency {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.09);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-toggle {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.segmented-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented-toggle button.active {
  background: linear-gradient(135deg, #0d9488, #0284c7);
  color: #ffffff;
}

/* ======================= QUICK SOS BAR ======================= */
.quick-sos-bar {
  background: linear-gradient(90deg, rgba(13, 148, 136, 0.16), rgba(2, 132, 199, 0.14));
  border-bottom: 1px solid var(--border-subtle);
}

.quick-sos-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-sos-label {
  font-size: 0.84rem;
  color: var(--text-primary);
}

.quick-sos-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ======================= BUTTONS & CHIPS ======================= */
.btn-primary,
.btn-secondary,
.btn-sos-primary,
.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease;
  border: 1px solid transparent;
  font-size: 0.85rem;
  padding: 9px 15px;
}

.btn-primary {
  background: linear-gradient(135deg, #0d9488, #0284c7);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(13, 148, 136, 0.38);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
}

.btn-sos-primary {
  background: linear-gradient(135deg, #ef4444, #d97706);
  color: #ffffff;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.82rem;
  box-shadow: 0 5px 16px rgba(239, 68, 68, 0.35);
}

.btn-sos-primary:hover {
  transform: translateY(-1px);
}

.chip-btn {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.chip-btn:hover,
.chip-btn.active {
  border-color: var(--accent-teal);
  color: var(--text-primary);
  background: rgba(45, 212, 191, 0.14);
}

.floating-sos-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 95;
  background: linear-gradient(135deg, #0d9488, #0284c7);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.45);
}

.floating-sos-btn:hover {
  transform: translateY(-2px);
}

/* Badges */
.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.pill-info {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.pill-safe {
  background: rgba(16, 185, 129, 0.16);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.32);
}

.pill-warn {
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.32);
}

.pill-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

body.light-theme .pill-danger {
  color: #dc2626;
}

/* ======================= MAIN CONTAINER & HERO ======================= */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 20px 80px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.95fr);
  gap: 24px;
  align-items: center;
  padding: 26px;
  background: linear-gradient(145deg, var(--bg-card), var(--bg-surface));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-teal);
  margin-bottom: 8px;
}

.hero h1 {
  font-size: clamp(1.65rem, 2.5vw, 2.35rem);
  line-height: 1.16;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.hero-lead {
  font-size: 0.96rem;
  color: var(--text-secondary);
  margin: 0 0 18px;
}

.hero-cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-stats-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.stat-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}

.stat-num {
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--accent-teal);
  line-height: 1.15;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.mastery-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.progress-track {
  height: 9px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #38bdf8);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ======================= SECTIONS & GRIDS ======================= */
.section-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-card);
}

.section-head {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-num {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent-teal);
  margin-bottom: 4px;
}

.section-head h2 {
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}

.section-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 78ch;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
}

.panel-card h3 {
  margin: 0 0 8px;
  font-size: 1.06rem;
}

/* Alert Banners */
.alert-banner {
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 0.88rem;
  border-left: 4px solid var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
}

.alert-safe {
  border-left-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.11);
}

.alert-warn {
  border-left-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
}

.alert-danger {
  border-left-color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.13);
}

.reasoning-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.88rem;
}

/* ======================= CANVAS & INTERACTIVE LABS ======================= */
.canvas-frame {
  width: 100%;
  background: #071320;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 8px;
}

body.light-theme .canvas-frame {
  background: #f8fafc;
}

.canvas-frame canvas {
  width: 100%;
  height: auto;
  display: block;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.hotspot-list {
  display: grid;
  gap: 8px;
}

.hotspot-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.hotspot-btn:hover,
.hotspot-btn.active {
  background: var(--bg-elevated);
  border-color: var(--accent-teal);
  border-left-color: var(--accent-teal);
}

/* ======================= CHECKBOX TILES & SYMPTOM GRIDS ======================= */
.symptom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 8px;
}

.redflag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 9px;
}

.check-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.check-tile:hover {
  border-color: var(--accent-teal);
}

.check-tile input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent-teal);
  flex-shrink: 0;
}

.check-tile.checked {
  background: rgba(45, 212, 191, 0.12);
  border-color: var(--accent-teal);
}

/* ======================= TABLES ======================= */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.clinical-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.clinical-table th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.clinical-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  color: var(--text-secondary);
}

.clinical-table tr:last-child td {
  border-bottom: none;
}

/* ======================= BREATHING PACER & SOS MODAL ======================= */
.qh-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 10, 18, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.qh-modal-backdrop[hidden] {
  display: none !important;
}

.qh-modal-card {
  width: 100%;
  max-width: 960px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.qh-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.qh-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}

.qh-tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.qh-tab-btn.active {
  background: linear-gradient(135deg, #0d9488, #0284c7);
  color: #ffffff;
  border-color: transparent;
}

.first-aid-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  align-items: center;
}

.breathing-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 290px;
}

.breathing-orb-wrap {
  position: relative;
  width: 176px;
  height: 176px;
  display: grid;
  place-items: center;
  margin: 12px 0;
}

.breathing-ring-guide {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(45, 212, 191, 0.35);
}

.breathing-orb {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5eead4, #0d9488 65%, #0369a1);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  box-shadow: 0 0 32px rgba(45, 212, 191, 0.36);
  transform: scale(0.78);
  transition: transform 0.35s ease-in-out;
}

.grounding-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.grounding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.grounding-card.done {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.14);
}

.grounding-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-teal);
}

/* ======================= FORMS & DOCTOR NOTE ======================= */
.form-group {
  margin-bottom: 11px;
}

.field-title {
  display: block;
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-select,
.form-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.86rem;
}

.doc-note-textarea {
  width: 100%;
  min-height: 250px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
}

/* ======================= CAFFEINE & MYTH CARDS ======================= */
.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 8px;
}

.myth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 13px;
  display: grid;
  gap: 6px;
}

/* ======================= QUIZ CARDS ======================= */
.quiz-grid {
  display: grid;
  gap: 14px;
}

.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.quiz-opt-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quiz-opt-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--accent-teal);
}

.quiz-opt-btn.correct {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--accent-emerald);
}

.quiz-opt-btn.wrong {
  background: rgba(239, 68, 68, 0.16);
  border-color: var(--accent-danger);
}

/* ======================= FOOTER & REFERENCES ======================= */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px;
}

.ref-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 0.82rem;
}

.footer {
  margin-top: 28px;
  padding: 22px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ======================= RESPONSIVE ======================= */
@media (max-width: 960px) {
  .hero,
  .two-col,
  .three-col,
  .first-aid-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 14px 12px 80px;
  }
  .section-block,
  .hero {
    padding: 16px;
  }
  .floating-sos-btn {
    right: 12px;
    bottom: 12px;
    padding: 10px 14px;
    font-size: 0.8rem;
  }
}

@media print {
  .topbar,
  .quick-sos-bar,
  .floating-sos-btn {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
