/* ── Theme variables (FlightOps palette) ─────────────────────────────────── */
:root {
  --bg:          #0C0F14;
  --surface:     #151921;
  --surface2:    #1C2230;
  --border:      #2A3040;
  --text:        #E8ECF2;
  --text-dim:    #8891A0;
  --text-muted:  #5A6375;
  --accent:      #4E9FFF;
  --accent-dim:  rgba(78,159,255,0.12);
  --green:       #34D399;
  --green-dim:   rgba(52,211,153,0.12);
  --yellow:      #FBBF24;
  --yellow-dim:  rgba(251,191,36,0.12);
  --orange:      #FB923C;
  --orange-dim:  rgba(251,146,60,0.12);
  --red:         #F87171;
  --red-dim:     rgba(248,113,113,0.12);
  --purple:      #C084FC;
  --purple-dim:  rgba(192,132,252,0.12);
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      none;
}

[data-theme="light"] {
  --bg:          #F4F5F7;
  --surface:     #FFFFFF;
  --surface2:    #EBEDF2;
  --border:      #D4D8E0;
  --text:        #1A1D24;
  --text-dim:    #5A6070;
  --text-muted:  #8891A0;
  --accent:      #2B7FE0;
  --accent-dim:  rgba(43,127,224,0.10);
  --green:       #16A76A;
  --green-dim:   rgba(22,167,106,0.10);
  --yellow:      #D49A08;
  --yellow-dim:  rgba(212,154,8,0.10);
  --orange:      #D97706;
  --orange-dim:  rgba(217,119,6,0.10);
  --red:         #DC4444;
  --red-dim:     rgba(220,68,68,0.10);
  --purple:      #9333EA;
  --purple-dim:  rgba(147,51,234,0.10);
  --shadow:      0 1px 3px rgba(0,0,0,0.06);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  min-height: 100dvh;
  padding-bottom: 40px;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Container ───────────────────────────────────────────────────────────── */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90vw;
}
.flash {
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: auto;
  transition: opacity 0.3s;
}
.flash-success { background: var(--green);  color: #000; }
.flash-error   { background: var(--red);    color: #fff; }
.flash-info    { background: var(--accent); color: #fff; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 360px; }
.auth-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 32px;
}
.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ── App header (sticky) ─────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.app-header .header-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* ── Log form sticky header ──────────────────────────────────────────────── */
.page-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.page-header .header-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.date-eyebrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.header-title {
  max-width: 480px;
  margin: 0 auto;
  padding: 2px 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}
.page-header .subtitle {
  max-width: 480px;
  margin: 0 auto;
  padding: 2px 16px 0;
  font-size: 11px;
  color: var(--text-muted);
}
.progress-bar {
  max-width: 480px;
  margin: 10px auto 0;
  height: 2px;
  background: var(--surface2);
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 10%;
  transition: width 0.4s ease;
}

/* ── Header shared ───────────────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.back-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.user-badge {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  text-decoration: none;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  transition: background 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--border); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary   { background: var(--accent);     color: #fff; }
.btn-secondary { background: var(--surface2);   color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--red-dim);    color: var(--red);  border: 1px solid var(--red); }
.btn-ghost     { background: transparent;       color: var(--text-dim); border: 1px solid var(--border); }
.btn-sm        { padding: 8px 14px; font-size: 13px; width: auto; display: inline-flex; }
.btn:disabled  { opacity: 0.4; pointer-events: none; }
.btn-submit    { font-size: 16px; padding: 16px; }

/* ── Form groups ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="time"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A6375' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.input-locked {
  opacity: 0.55;
  cursor: default;
  border-style: dashed;
}

/* ── Two-column grid ─────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Page title ──────────────────────────────────────────────────────────── */
.page-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 16px;
}

/* ── Dashboard log cards ─────────────────────────────────────────────────── */
.log-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.log-card-date {
  display: flex;
  flex-direction: column;
  min-width: 48px;
}
.log-date-main {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.log-date-day {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.log-card-info { flex: 1; }
.log-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Badges / severity pills ─────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}
.sev-none     { background: var(--green-dim);  color: var(--green); }
.sev-mild     { background: var(--yellow-dim); color: var(--yellow); }
.sev-moderate { background: var(--orange-dim); color: var(--orange); }
.sev-severe   { background: var(--red-dim);    color: var(--red); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ── Log form sections ───────────────────────────────────────────────────── */
.section {
  max-width: 480px;
  margin: 16px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section:nth-child(2) { animation-delay: 0.04s; }
.section:nth-child(3) { animation-delay: 0.08s; }
.section:nth-child(4) { animation-delay: 0.12s; }
.section:nth-child(5) { animation-delay: 0.16s; }
.section:nth-child(6) { animation-delay: 0.20s; }
.section:nth-child(7) { animation-delay: 0.24s; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}
.env-status-label {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-family: 'JetBrains Mono', monospace;
}
.section-body { padding: 16px; }

/* ── Environment grid ────────────────────────────────────────────────────── */
.env-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}
.env-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
}
.env-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.env-lbl {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}
.env-location {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: center;
  letter-spacing: 0.04em;
}
.env-error {
  font-size: 11px;
  color: var(--red);
  margin-top: 8px;
  text-align: center;
}

/* AQI coloring */
.aqi-good      { color: var(--green)  !important; }
.aqi-moderate  { color: var(--yellow) !important; }
.aqi-usg       { color: var(--orange) !important; }
.aqi-unhealthy { color: var(--red)    !important; }
.aqi-very      { color: #F43F5E       !important; }
.aqi-hazardous { color: #BE123C       !important; }

/* ── Symptom rows ────────────────────────────────────────────────────────── */
.symptom-rows { display: flex; flex-direction: column; gap: 8px; }
.symptom-row {
  display: grid;
  grid-template-columns: 90px 1fr 100px 28px;
  gap: 8px;
  align-items: end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  animation: fadeUp 0.2s ease both;
}

/* Severity select coloring */
.sev-select { transition: background 0.15s, border-color 0.15s, color 0.15s; }
.sev-select.sev-none     { background: var(--green-dim);  border-color: var(--green);  color: var(--green); }
.sev-select.sev-mild     { background: var(--yellow-dim); border-color: var(--yellow); color: var(--yellow); }
.sev-select.sev-moderate { background: var(--orange-dim); border-color: var(--orange); color: var(--orange); }
.sev-select.sev-severe   { background: var(--red-dim);    border-color: var(--red);    color: var(--red); }

/* ── Food entries ────────────────────────────────────────────────────────── */
.food-entries { display: flex; flex-direction: column; gap: 10px; }
.food-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  animation: fadeUp 0.2s ease both;
}
.food-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.food-entry-num {
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.food-label-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.food-label-input:focus { border-bottom-color: var(--accent); outline: none; }

/* ── Medication entries ──────────────────────────────────────────────────── */
.med-entries { display: flex; flex-direction: column; gap: 8px; }
.med-entry {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  animation: fadeUp 0.2s ease both;
}
.med-row-top {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.med-row-top .form-group { flex: 1; margin: 0; }
.med-row-bottom {
  display: grid;
  grid-template-columns: 1fr 100px 100px;
  gap: 8px;
}

/* ── Add / Remove buttons ────────────────────────────────────────────────── */
.add-btn {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
}
.add-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.remove-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.remove-btn:hover { background: var(--red-dim); border-color: var(--red); color: var(--red); }

/* ── Sliders ─────────────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row input[type="range"] {
  flex: 1;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  height: 4px;
  cursor: pointer;
}
.slider-row input[type="range"]:focus {
  box-shadow: none;
  border-color: transparent;
}
.slider-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  min-width: 22px;
  text-align: right;
  color: var(--accent);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: 4px;
  padding: 0 2px;
  text-transform: uppercase;
}

/* ── Chips ───────────────────────────────────────────────────────────────── */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-appearance: none;
}
.chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── Submit area ─────────────────────────────────────────────────────────── */
.submit-area {
  max-width: 480px;
  margin: 20px auto 0;
  padding: 0 16px;
  animation: fadeUp 0.25s 0.3s ease both;
}
.submit-note {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── View (read-only) sections ───────────────────────────────────────────── */
.view-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.view-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.view-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.view-row:last-child { border-bottom: none; }
.view-row-main { display: flex; align-items: center; gap: 8px; flex: 1; }
.view-label { font-size: 14px; color: var(--text); }
.view-meta  { font-size: 12px; color: var(--text-muted); }
.view-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
}
.view-note {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 8px 0 4px;
}
.view-food {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.view-food:last-child { margin-bottom: 0; }
.view-food-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.view-food-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.view-food-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

/* ── Profile medicine list ───────────────────────────────────────────────── */
.med-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.med-list-row:last-of-type { border-bottom: none; }
.med-list-info { display: flex; flex-direction: column; gap: 2px; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.mb-16 { margin-bottom: 16px; }
.mono  { font-family: 'JetBrains Mono', monospace; }
