/* ==========================================================================
   Daily Pulse / Hydration Tracker App — Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:wght@600;700;800&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap');

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --primary:            #006b2f;
  --primary-container:  #00873d;
  --on-primary:         #ffffff;
  --primary-fixed:      #84fb9d;
  --primary-fixed-dim:  #67de84;

  --secondary:          #116e00;
  --secondary-container:#95f779;
  --on-secondary-container: #137300;
  --on-secondary:       #ffffff;

  --tertiary:           #7b5500;
  --tertiary-container: #9b6c00;
  --tertiary-fixed:     #ffdeac;
  --tertiary-fixed-dim: #febb3c;

  --surface:            #f9f9fc;
  --surface-bright:     #f9f9fc;
  --surface-dim:        #dadadc;
  --surface-container:  #eeeef0;
  --surface-container-low: #f3f3f6;
  --surface-container-high: #e8e8ea;
  --surface-container-highest: #e2e2e5;
  --surface-variant:    #e2e2e5;

  --on-surface:         #1a1c1e;
  --on-surface-variant: #3e4a3e;
  --on-background:      #1a1c1e;
  --inverse-surface:    #2f3133;
  --inverse-on-surface: #f0f0f3;
  --inverse-primary:    #67de84;

  --outline:            #6e7a6d;
  --outline-variant:    #bdcabb;

  --error:              #ba1a1a;
  --error-container:    #ffdad6;

  --nova-gold:          #f5b335;

  /* Sidebar */
  --sidebar-width:      256px;

  /* Typography */
  --font-display:       'Montserrat', sans-serif;
  --font-body:          'Inter', sans-serif;

  /* Radius */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-card:   0 2px 12px rgba(0,0,0,0.06);
  --shadow-soft:   0 8px 32px rgba(0,0,0,0.08);
  --shadow-input:  0 0 0 3px rgba(0,107,47,0.12);

  /* Transitions */
  --t-fast:  150ms ease;
  --t-base:  220ms ease;
  --t-slow:  400ms ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
html { font-size:16px; }
body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor:pointer; border:none; background:none; font-family:inherit; }
input, select, textarea { font-family:inherit; outline:none; }
img { display:block; max-width:100%; }
ul { list-style:none; }

/* Material Icons */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--surface-container-low);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  padding: 16px;
  z-index: 100;
  transition: transform var(--t-base);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .material-symbols-outlined {
  color: white;
  font-size: 20px;
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--on-surface-variant);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface-variant);
  transition: all var(--t-fast);
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--surface-variant);
  color: var(--on-surface);
}

.nav-item.active {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-weight: 700;
}

.nav-item .material-symbols-outlined { font-size: 20px; }

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-log-vitals {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.btn-log-vitals:hover { opacity: 0.9; }
.btn-log-vitals:active { transform: scale(0.98); }

/* Mobile nav */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: var(--surface-container-low);
  border-bottom: 1px solid var(--outline-variant);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.mobile-menu-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--surface-container);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-container-low);
  border-top: 1px solid var(--outline-variant);
  z-index: 100;
  padding: 8px 0;
}

.mobile-bottom-nav .nav-items {
  display: flex;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-radius: var(--r-sm);
  color: var(--on-surface-variant);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--t-fast);
}

.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item .material-symbols-outlined { font-size: 22px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-bottom-nav { display: block; }

  .sidebar.mobile-open {
    display: flex;
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 32px 40px 48px;
  flex: 1;
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    padding: 80px 16px 90px;
  }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 15px;
  color: var(--on-surface-variant);
  margin-top: 4px;
}

.date-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-container-high);
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.date-chip .material-symbols-outlined { font-size: 16px; color: var(--primary); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--outline-variant);
}

.glass-card {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid #E9ECEF;
  border-radius: var(--r-lg);
  padding: 24px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-bottom: 20px;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 20px;
  border: 1px solid var(--outline-variant);
  box-shadow: var(--shadow-card);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-icon .material-symbols-outlined { font-size: 20px; }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--on-surface-variant);
  font-weight: 500;
}

.stat-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up { color: var(--secondary); }
.trend-down { color: var(--error); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-container); box-shadow: 0 4px 16px rgba(0,107,47,0.25); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--outline-variant);
  color: var(--on-surface);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost { background: var(--surface-container); color: var(--on-surface); }
.btn-ghost:hover { background: var(--surface-variant); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }

/* ── Progress / Track ─────────────────────────────────────── */
.track {
  height: 10px;
  background: var(--surface-container);
  border-radius: var(--r-full);
  overflow: hidden;
}

.track-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--primary);
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Water Visualiser ─────────────────────────────────────── */
.water-container {
  position: relative;
  width: 180px;
  height: 220px;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 2px solid var(--outline-variant);
  background: rgba(0,107,47,0.04);
  margin: 0 auto;
}

.water-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0,107,47,0.8), rgba(0,107,47,0.4));
  transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 0 8px 8px;
}

.water-fill::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -20%;
  width: 140%;
  height: 18px;
  background: rgba(0,107,47,0.5);
  border-radius: 40%;
  animation: wave 3s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% { transform: translateX(0) rotateZ(0); }
  50% { transform: translateX(-8%) rotateZ(-2deg); }
}

.water-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  z-index: 2;
  text-shadow: 0 1px 4px rgba(255,255,255,0.8);
}

/* Cup buttons */
.cup-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.cup-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--r-md);
  background: var(--surface-container-low);
  border: 2px solid var(--outline-variant);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
}

.cup-btn:hover, .cup-btn.active {
  border-color: var(--primary);
  background: rgba(0,107,47,0.06);
  color: var(--primary);
}

.cup-btn .material-symbols-outlined { font-size: 24px; }

/* ── Ring Chart ───────────────────────────────────────────── */
.ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

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

.ring-bg { fill: none; stroke: var(--surface-container); stroke-width: 10; }
.ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1;
}

.ring-unit {
  font-size: 11px;
  color: var(--on-surface-variant);
  font-weight: 600;
}

/* ── Milestone dots ───────────────────────────────────────── */
.milestone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
}

.milestone-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--on-surface-variant);
  font-weight: 500;
}

.milestone-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  transition: all var(--t-fast);
}

.milestone-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.milestone-dot .material-symbols-outlined { font-size: 20px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--on-surface-variant); margin-bottom: 6px; }

.form-input {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--on-surface);
  background: white;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-input);
}

.form-input::placeholder { color: var(--on-surface-variant); opacity: 0.6; }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233e4a3e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ── Grids ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }

@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ── Pages (shown/hidden) ─────────────────────────────────── */
.app-page { display: none; }
.app-page.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ── Habit Tracker ────────────────────────────────────────── */
.habit-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-variant);
  letter-spacing: 0.05em;
  padding: 4px 0;
}

.day-check {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 2px solid var(--outline-variant);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 14px;
}

.day-check.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.day-check:hover { border-color: var(--primary); }

/* ── Meal Planner ─────────────────────────────────────────── */
.meal-slot {
  background: var(--surface-container-low);
  border: 1.5px dashed var(--outline-variant);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all var(--t-fast);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}

.meal-slot.filled {
  background: white;
  border-color: var(--outline-variant);
  border-style: solid;
  color: var(--on-surface);
}

.meal-slot:hover { border-color: var(--primary); background: rgba(0,107,47,0.03); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  padding: 12px 20px;
  border-radius: var(--r-full);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

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

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline-variant); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* ── Utilities ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: 8px; }
.gap-sm { gap: 12px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.mb-xs { margin-bottom: 8px; }
.mb-sm { margin-bottom: 12px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.mb-xl { margin-bottom: 32px; }
.mt-lg { margin-top: 24px; }
.mt-xl { margin-top: 32px; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.rounded-full { border-radius: var(--r-full); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--on-surface-variant); }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.section-gap { margin-bottom: 32px; }

/* Chip/Badge */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
}

.chip-green { background: var(--secondary-container); color: var(--on-secondary-container); }
.chip-gold  { background: rgba(245,179,53,0.15); color: var(--tertiary); }
.chip-blue  { background: rgba(0,107,47,0.08); color: var(--primary); }

/* Separator */
.sep { height: 1px; background: var(--outline-variant); margin: 20px 0; }

/* DNA dot pattern */
.dna-bg {
  background-image: radial-gradient(circle at 2px 2px, var(--outline-variant) 1px, transparent 0);
  background-size: 24px 24px;
}
