/**
 * Slumberly Dashboard CSS
 * Apple iOS 17/18 Dark Glassmorphic Design System.
 */

:root {
  --dash-bg-start: #1A0D2E;
  --dash-bg-end: #0E071A;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-subtle: rgba(255, 255, 255, 0.06);
  --accent-purple: #8B5CF6;
  --accent-purple-glow: rgba(139, 92, 246, 0.35);
  --accent-blue: #3B82F6;
  --accent-orange: #F97316;
  --accent-emerald: #10B981;
  --accent-red: #EF4444;
  --accent-cyan: #06B6D4;
}

body.dashboard-body {
  background: radial-gradient(ellipse at top, var(--dash-bg-start), var(--dash-bg-end));
  color: #FFFFFF;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.dashboard-main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 90px 20px 60px;
  box-sizing: border-box;
}

/* Starfield Background Canvas */
.stars-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* Nav Additions */
.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border-subtle);
  background: rgba(255, 255, 255, 0.04);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9CA3AF;
}

.sync-pill.sync-success .sync-dot { background: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }
.sync-pill.sync-syncing .sync-dot { background: var(--accent-purple); animation: pulse 1.2s infinite; }
.sync-pill.sync-warning .sync-dot { background: #FBBF24; }
.sync-pill.sync-error .sync-dot { background: var(--accent-red); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

.nav-user-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-capsule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
}

.capsule-avatar { font-size: 1.1rem; }
.capsule-name { font-size: 0.85rem; font-weight: 600; color: #E5E7EB; }

.btn-glass-logout {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #FCA5A5 !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
}
.btn-glass-logout:hover { background: rgba(239, 68, 68, 0.3) !important; }

/* Auth Card */
.auth-card {
  max-width: 440px;
  margin: 60px auto;
  text-align: center;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  background: rgba(26, 13, 46, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.auth-icon-pod {
  width: 64px;
  height: 64px;
  border-radius: 32px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 0 24px var(--accent-purple-glow);
}

.auth-card h2 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.auth-card p { font-size: 0.95rem; color: #9CA3AF; line-height: 1.5; margin: 0; }

.auth-security-badge {
  font-size: 0.8rem;
  color: #10B981;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

/* Quick Logger Bar */
.quick-logger-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.quick-log-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #FFFFFF;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.quick-log-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-sleep:hover { box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3); }
.btn-feed:hover { box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3); }
.btn-diaper:hover { box-shadow: 0 4px 16px rgba(6, 182, 212, 0.3); }
.btn-growth:hover { box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3); }
.btn-health:hover { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3); }

/* Tab Switcher Pills */
.tab-switcher-pill {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border-subtle);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #9CA3AF;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tab-content-pane { display: none; }
.tab-content-pane.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card Global */
.glass-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Hero Prediction Grid */
.hero-prediction-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .hero-prediction-grid { grid-template-columns: 1fr; }
}

/* SweetSpot Card */
.sweetspot-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header-compact {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon-pod {
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.15);
  border-radius: 14px;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.header-text-group h3 { font-size: 1.15rem; font-weight: 700; margin: 0; color: #F3F4F6; }
.header-text-group p { font-size: 0.85rem; color: #9CA3AF; margin: 2px 0 0; }

.sweetspot-badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-normal { background: rgba(59, 130, 246, 0.15); color: #93C5FD; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-spot { background: rgba(139, 92, 246, 0.25); color: #C4B5FD; border: 1px solid rgba(139, 92, 246, 0.5); box-shadow: 0 0 12px var(--accent-purple-glow); }
.badge-overdue { background: rgba(239, 68, 68, 0.2); color: #FCA5A5; border: 1px solid rgba(239, 68, 68, 0.4); }

.sweetspot-body {
  display: flex;
  align-items: center;
  gap: 24px;
}

.gauge-container {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 10;
}

.gauge-progress {
  fill: none;
  stroke: var(--accent-purple);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 339.29; /* 2 * PI * 54 */
  stroke-dashoffset: 80;
  transition: stroke-dashoffset 0.8s ease, stroke 0.4s ease;
}

.gauge-center-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge-val { font-size: 1.25rem; font-weight: 800; color: #FFFFFF; font-variant-numeric: tabular-nums; }
.gauge-sub { font-size: 0.65rem; color: #9CA3AF; text-transform: uppercase; letter-spacing: 0.5px; }

.sweetspot-info-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--glass-border-subtle);
}
.info-label { color: #9CA3AF; }
.info-val { font-weight: 600; color: #F3F4F6; }
.text-emerald { color: var(--accent-emerald) !important; }

/* Active Sleep Card */
.active-sleep-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.timer-dial-container {
  text-align: center;
  margin: 12px 0;
}

.timer-stopwatch-readout {
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: #FFFFFF;
}
.timer-subtext { font-size: 0.8rem; color: #9CA3AF; margin: 4px 0 0; }

.timer-actions {
  display: flex;
  gap: 8px;
}

.btn-timer-primary {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  color: #FFFFFF;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
  transition: transform 0.2s ease;
}
.btn-timer-primary:hover { transform: scale(1.02); }

.btn-timer-danger {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #FFFFFF;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.active-pulsing {
  border-color: rgba(59, 130, 246, 0.5) !important;
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.3) !important;
}

/* Summary Triad Grid */
.summary-triad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon-pod {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.pod-blue { background: rgba(59, 130, 246, 0.15); border: 1px solid rgba(59, 130, 246, 0.3); }
.pod-orange { background: rgba(249, 115, 22, 0.15); border: 1px solid rgba(249, 115, 22, 0.3); }
.pod-cyan { background: rgba(6, 182, 212, 0.15); border: 1px solid rgba(6, 182, 212, 0.3); }

.stat-label { font-size: 0.8rem; color: #9CA3AF; text-transform: uppercase; font-weight: 600; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: #FFFFFF; margin-top: 2px; }

/* Timeline Stream */
.section-container {
  padding: 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h3 { font-size: 1.15rem; font-weight: 700; margin: 0; }

.btn-subtle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: #E5E7EB;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-subtle:hover { background: rgba(255, 255, 255, 0.14); }

.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-empty-card {
  padding: 32px 20px;
  text-align: center;
  color: #9CA3AF;
  font-size: 0.95rem;
  border: 1px dashed var(--glass-border);
  border-radius: 16px;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 18px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.timeline-row:hover { transform: translateX(2px); background: rgba(255, 255, 255, 0.07); }

.timeline-icon-pod {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.timeline-row-info { flex: 1; }
.timeline-row-title { font-size: 0.95rem; font-weight: 700; color: #F3F4F6; }
.timeline-row-sub { font-size: 0.8rem; color: #9CA3AF; margin-top: 2px; }

.timeline-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-time-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #9CA3AF;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 8px;
  border-radius: 8px;
}

.btn-delete-log {
  background: transparent;
  border: none;
  color: #6B7280;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px;
}
.btn-delete-log:hover { color: #EF4444; }

/* Timeline Controls Bar */
.timeline-controls-bar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-arrow-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
}
.current-date-label { font-weight: 700; font-size: 1rem; min-width: 140px; text-align: center; }
.btn-today-pill {
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #C4B5FD;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-subtle);
  color: #9CA3AF;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-chip.active {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Charts View */
.chart-card {
  padding: 24px;
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.chart-header h3 { font-size: 1.15rem; font-weight: 700; margin: 0; }
.chart-header p { font-size: 0.85rem; color: #9CA3AF; margin: 2px 0 0; }

.legend-chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
}
.legend-group { display: flex; gap: 6px; }

.canvas-wrapper {
  width: 100%;
  height: 240px;
}

/* Profile Detail */
.profile-detail-card {
  padding: 36px 24px;
  text-align: center;
}
.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 40px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  margin: 0 auto 16px;
}
.settings-group {
  max-width: 500px;
  margin: 32px auto 0;
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid var(--glass-border-subtle);
}
.settings-group h3 { font-size: 0.95rem; margin-top: 0; margin-bottom: 12px; color: #9CA3AF; text-transform: uppercase; }
.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--glass-border-subtle);
  font-size: 0.85rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.modal-backdrop.modal-open {
  display: flex;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-sheet {
  max-width: 480px;
  width: 100%;
  background: #180D2A;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #9CA3AF;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9CA3AF;
  margin-bottom: 6px;
}

.glass-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: #FFFFFF;
  font-size: 0.95rem;
  box-sizing: border-box;
}
.glass-input:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px var(--accent-purple-glow);
}

.btn-modal-primary {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 20px var(--accent-purple-glow);
}

/* Nursing Dual Timers */
.nurse-dual-timers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.btn-side-timer {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  color: #FFFFFF;
}
.side-title { font-size: 0.75rem; font-weight: 700; color: #9CA3AF; }
.side-clock { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; }

.btn-side-timer.active-side {
  background: rgba(249, 115, 22, 0.2);
  border-color: #F97316;
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.4);
}

.nurse-actions-row {
  display: flex;
  gap: 10px;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--glass-border-subtle);
  margin: 20px 0;
}

/* Segmented Pills */
.segmented-pill-group {
  display: flex;
  gap: 8px;
}
.segment-option {
  flex: 1;
  position: relative;
}
.segment-option input { display: none; }
.segment-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.segment-option input:checked + span {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3B82F6;
  color: #93C5FD;
}

/* Toast */
.dashboard-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(26, 13, 46, 0.95);
  border: 1px solid var(--accent-purple);
  padding: 12px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px var(--accent-purple-glow);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 9999;
}
.dashboard-toast.toast-show {
  transform: translateX(-50%) translateY(0);
}
