/* Target Path: style.css */
/* เขียนโค้ดจาก agent version: .agents-3.6 */
:root {
  /* Theme Base: Medical Blue (Default) */
  --primary-h: 215;
  --primary-s: 88%;
  --primary-l: 52%;
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-light: hsl(var(--primary-h), var(--primary-s), 16%);
  --primary-glow: hsla(var(--primary-h), var(--primary-s), 55%, 0.25);
  
  --accent-water: #00b4d8;
  --accent-urine: #f59e0b;
  --accent-night: #8b5cf6;
  --accent-amber: #d97706;
  --accent-danger: #ef4444;
  --accent-success: #10b981;
  
  /* Dark Mode Palette (Default) */
  --bg-body: #070d18;
  --bg-app: #0c1424;
  --bg-card: #131f36;
  --bg-card-elevated: #1a2a47;
  --bg-input: #0e172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border-color: #1e2e4a;
  --border-focus: #3b82f6;
  --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --font-main: 'Outfit', 'Sarabun', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  --safe-bottom: 76px;
}

/* 🟢 Theme 2: Emerald Clinical */
[data-palette="emerald"] {
  --primary-h: 160;
  --primary-s: 84%;
  --primary-l: 39%;
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-light: hsl(var(--primary-h), var(--primary-s), 14%);
  --primary-glow: hsla(var(--primary-h), var(--primary-s), 45%, 0.25);
}

/* 🌙 Theme 3: Midnight Amber Night-Owl (ถนอมสายตาตอนตื่นมาฉี่ตี 3) */
[data-palette="amber"] {
  --primary-h: 38;
  --primary-s: 92%;
  --primary-l: 50%;
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-light: hsl(var(--primary-h), var(--primary-s), 14%);
  --primary-glow: hsla(var(--primary-h), var(--primary-s), 50%, 0.25);
  --bg-body: #0a0805;
  --bg-app: #120e08;
  --bg-card: #1c150c;
  --bg-card-elevated: #281e11;
  --border-color: #352514;
}

/* ☀️ Light Mode */
[data-theme="light"] {
  --bg-body: #e2e8f0;
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-elevated: #f1f5f9;
  --bg-input: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-card: 0 4px 16px -2px rgba(0, 0, 0, 0.06);
  --primary-light: hsl(var(--primary-h), var(--primary-s), 94%);
  --primary-glow: hsla(var(--primary-h), var(--primary-s), 50%, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Mobile Frame Mockup Container */
.mobile-frame {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

@media (min-width: 640px) {
  .mobile-frame {
    height: 92vh;
    max-height: 900px;
    border-radius: 36px;
    border: 4px solid #1e293b;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.08);
  }
}

/* App Header */
.app-header {
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: var(--bg-app);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  z-index: 30;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent-water));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.header-logo .brand-text {
  display: flex;
  flex-direction: column;
}
.header-logo .brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.header-logo .brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.header-btn:hover {
  background: var(--bg-card-elevated);
  transform: scale(1.05);
}

/* Scrollable Main Area */
.app-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
}
.app-scroll::-webkit-scrollbar {
  display: none;
}

/* View Switcher */
.view-panel {
  display: none;
  animation: fadeIn 0.25s ease-out;
}
.view-panel.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Alert Banner (NPI Warning & Medication) */
.alert-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(245, 158, 11, 0.15));
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.alert-banner.safe {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(59, 130, 246, 0.15));
  border-color: rgba(16, 185, 129, 0.35);
}
.alert-icon {
  font-size: 1.2rem;
  color: var(--accent-danger);
  margin-top: 1px;
}
.alert-banner.safe .alert-icon {
  color: var(--accent-success);
}
.alert-content h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.alert-content p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Date Filter / Header Banner */
.date-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.date-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.date-pill {
  font-family: var(--font-mono);
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
}
.quick-date-btns {
  display: flex;
  gap: 4px;
}
.q-date-btn {
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  background: var(--bg-card-elevated);
  color: var(--text-muted);
  cursor: pointer;
}
.q-date-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Hero Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s;
}
.metric-card:hover {
  transform: translateY(-2px);
}
.metric-card.wide {
  grid-column: span 2;
}
.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.metric-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.metric-badge.water { background: rgba(0, 180, 216, 0.15); color: #00b4d8; }
.metric-badge.urine { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.metric-badge.night { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.metric-badge.balance { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.metric-val {
  font-size: 1.45rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.metric-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  font-family: var(--font-main);
}
.metric-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* NPI Progress Bar */
.npi-container {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}
.npi-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 6px;
}
.npi-bar-bg {
  height: 10px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.npi-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.npi-threshold-line {
  position: absolute;
  left: 33%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.5);
  z-index: 2;
}

/* Quick Action FABs / Floating Bar */
.quick-cta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}
.quick-cta-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.quick-cta-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-quick-log {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-quick-water {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.15), rgba(59, 130, 246, 0.12));
  border-color: rgba(0, 180, 216, 0.35);
  color: #38bdf8;
}
.btn-quick-urine {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15));
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}
.btn-quick-log:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}
.btn-quick-log i {
  font-size: 1.25rem;
}

/* Section Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i {
  color: var(--primary);
}

/* Charts Container */
.chart-box {
  height: 200px;
  position: relative;
  width: 100%;
}

/* Log Form Styles */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.chip-btn {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-mono);
}
.chip-btn.active, .chip-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 10px var(--primary-glow);
}
.input-num-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-custom {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 50px 12px 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}
.input-custom:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-suffix {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Urine Color Visual Scale */
.color-scale-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.color-pill {
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.color-pill.active {
  border-color: var(--text-main);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.color-pill span {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Option Grid (Posture, Foam, Stream, Odor) */
.option-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.opt-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
}
.opt-card.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Symptom Checklist Chips */
.symptom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sym-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.sym-chip.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Submit Button */
.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px var(--primary-glow);
  transition: all 0.2s;
}
.btn-submit:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}
.btn-submit:active {
  transform: translateY(0);
}

/* History Logs List */
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border-left: 4px solid var(--primary);
}
.log-item.water {
  border-left-color: var(--accent-water);
}
.log-item.urine {
  border-left-color: var(--accent-urine);
}
.log-item.night {
  border-left-color: var(--accent-night);
}
.log-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.log-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.log-item.water .log-icon { background: rgba(0, 180, 216, 0.2); color: #00b4d8; }
.log-item.urine .log-icon { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.log-item.night .log-icon { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }

.log-meta h5 {
  font-size: 0.85rem;
  font-weight: 700;
}
.log-meta p {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.log-vol {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  text-align: right;
}
.log-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px 10px;
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 12px;
  transition: all 0.2s;
}
.nav-tab i {
  font-size: 1.15rem;
}
.nav-tab.active {
  color: var(--primary);
  transform: translateY(-2px);
}
.nav-tab.highlight {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  margin-top: -18px;
  box-shadow: 0 6px 16px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-tab.highlight i {
  font-size: 1.3rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlide {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Report Printable Container */
.report-paper {
  background: #fff;
  color: #0f172a;
  padding: 16px;
  border-radius: 12px;
  font-size: 0.8rem;
  margin: 12px 0;
  border: 1px solid #cbd5e1;
}
.report-paper h3 {
  font-size: 1rem;
  border-bottom: 2px solid #0284c7;
  padding-bottom: 4px;
  margin-bottom: 8px;
  color: #0369a1;
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.72rem;
}
.report-table th, .report-table td {
  border: 1px solid #e2e8f0;
  padding: 4px 6px;
  text-align: left;
}
.report-table th {
  background: #f1f5f9;
  font-weight: 700;
}

/* 🌙 Evening Fluid Guard Banner & Budget Box */
.evening-guard-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.75rem;
}
.evening-guard-banner i {
  font-size: 1.1rem;
  color: #f59e0b;
  margin-top: 2px;
}

.evening-budget-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.evening-budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.evening-budget-title {
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f59e0b;
}
.evening-progress-bar-bg {
  background: var(--bg-input);
  height: 10px;
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  margin-bottom: 6px;
  border: 1px solid var(--border-color);
}
.evening-progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease, background 0.4s ease;
}

/* 🩺 Clinical Mismatch / Neuro Alert Box */
.clinical-mismatch-box {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.74rem;
  color: var(--text-main);
  margin-top: 6px;
  line-height: 1.4;
}

/* 🏥 Doctor Specialist Switcher Tabs */
.doc-tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.doc-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.doc-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* 🎯 IPSS Questionnaire Styles */
.ipss-question-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.ipss-question-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
  line-height: 1.35;
}
.ipss-options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.ipss-opt-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.ipss-opt-btn.active {
  background: #d97706;
  border-color: #f59e0b;
  color: #fff;
  font-weight: 700;
}

/* 🚨 Red Flag Emergency Checklist */
.redflag-check-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.redflag-check-item.flagged {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}
.redflag-check-item input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #ef4444;
  cursor: pointer;
}

/* 🖨️ Clean A4 Print Styles for Doctor Report */
@media print {
  body, .mobile-frame, .app-scroll {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    max-width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  .app-header, .bottom-nav, .header-actions, .quick-cta-card, .date-filter-bar,
  .metrics-grid, .card, .btn-action-icon, .modal-sheet > div:first-child,
  #doctor-modal button, #btn-export-pdf, #btn-export-csv, .doc-tabs-bar, .modal-overlay:not(#doctor-modal) {
    display: none !important;
  }
  .modal-overlay#doctor-modal {
    position: static !important;
    display: block !important;
    background: none !important;
    padding: 0 !important;
    backdrop-filter: none !important;
  }
  .modal-sheet {
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .report-paper {
    border: 1px solid #94a3b8 !important;
    border-radius: 0 !important;
    padding: 12px !important;
    margin: 0 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }
  .report-table th, .report-table td {
    border: 1px solid #cbd5e1 !important;
    color: #000 !important;
  }
}

/* ─────────────────────────────────────────────
   ⏱️ Real-time Hydration Pacer Component
   แก้โค้ดจาก agent version: .agents-3.6
   ───────────────────────────────────────────── */
.hydration-pacer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.hydration-pacer-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #00b4d8, #3b82f6, #8b5cf6);
  opacity: 0.8;
}

.pacer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.pacer-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pacer-title {
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.pacer-time-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.pacer-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.pacer-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pacer-status-pill.on-track {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
}

.pacer-status-pill.under-pace {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
}

.pacer-status-pill.ahead-pace {
  background: rgba(59, 130, 246, 0.15);
  color: #38bdf8;
  border-color: rgba(59, 130, 246, 0.35);
}

.pacer-status-pill.overpace-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
  animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.pacer-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
}

.pacer-stat-item {
  display: flex;
  flex-direction: column;
}

.pacer-stat-label {
  font-size: 0.66rem;
  color: var(--text-muted);
}

.pacer-stat-val {
  font-size: 1.05rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.pacer-stat-val.actual {
  color: var(--accent-water);
}

.pacer-stat-val.target {
  color: var(--primary);
}

.pacer-stat-unit {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.pacer-stat-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pacer-diff-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.pacer-diff-badge.on-track {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.pacer-diff-badge.under-pace {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.pacer-diff-badge.ahead-pace {
  background: rgba(59, 130, 246, 0.15);
  color: #38bdf8;
}

.pacer-diff-badge.overpace-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Timeline Gauge Track */
.pacer-gauge-container {
  margin: 14px 0 10px 0;
  padding: 0 4px;
}

.pacer-track-wrap {
  position: relative;
  padding-bottom: 28px;
}

.pacer-track-bg {
  position: relative;
  width: 100%;
  height: 18px;
  background: var(--bg-input);
  border-radius: 12px;
  overflow: visible;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.25);
}

.pacer-evening-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(239, 68, 68, 0.15);
  border-left: 2px dashed rgba(239, 68, 68, 0.6);
  border-radius: 0 12px 12px 0;
  pointer-events: none;
}

.pacer-track-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(90deg, #00b4d8 0%, #3b82f6 70%, #60a5fa 100%);
  border-radius: 12px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(0, 180, 216, 0.45);
}

.pacer-target-pin {
  position: absolute;
  top: -8px;
  bottom: -8px;
  width: 3px;
  background: #f59e0b;
  transform: translateX(-50%);
  z-index: 10;
  transition: left 0.5s ease;
  pointer-events: none;
}

.pacer-pin-head {
  width: 12px;
  height: 12px;
  background: #f59e0b;
  border: 2px solid #ffffff;
  border-radius: 50%;
  position: absolute;
  top: -6px;
  left: -4.5px;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.9);
}

.pacer-pin-line {
  width: 3px;
  height: 100%;
  background: #f59e0b;
  border-radius: 2px;
}

/* Time Anchor Points */
.pacer-anchors-row {
  position: relative;
  width: 100%;
  margin-top: 8px;
  height: 24px;
}

.pacer-anchor-point {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.64rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pacer-anchor-point.anchor-evening {
  color: #f87171;
  font-weight: 700;
}

.pacer-anchor-time {
  font-weight: 700;
  font-size: 0.68rem;
}

.pacer-anchor-cc {
  font-size: 0.6rem;
  opacity: 0.85;
  font-family: var(--font-mono);
}

/* Behavioral Feedback Box */
.pacer-feedback-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  line-height: 1.35;
  background: rgba(0, 180, 216, 0.08);
  border: 1px solid rgba(0, 180, 216, 0.2);
  color: var(--text-main);
  transition: all 0.3s ease;
}

.pacer-feedback-box.on-track {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}

.pacer-feedback-box.under-pace {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
}

.pacer-feedback-box.ahead-pace {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}

.pacer-feedback-box.overpace-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.pacer-feedback-icon {
  font-size: 0.9rem;
  color: var(--primary);
  flex-shrink: 0;
}

.pacer-feedback-box.overpace-danger .pacer-feedback-icon {
  color: #ef4444;
}

.pacer-feedback-box.under-pace .pacer-feedback-icon {
  color: #f59e0b;
}

.pacer-feedback-box.on-track .pacer-feedback-icon {
  color: #10b981;
}

.pacer-feedback-box.ahead-pace .pacer-feedback-icon {
  color: #38bdf8;
}

