/* FitTrack — thème sombre "salle de muscu"
   Accents inspirés du code couleur des disques olympiques :
   rouge 25 kg = Séance · bleu 20 kg = Planning · jaune 15 kg = Nutrition */

:root {
  --bg: #101318;
  --surface: #1a1f27;
  --surface-2: #242b35;
  --border: #2f3844;
  --text: #edf1f5;
  --muted: #8a94a3;
  --red: #e04046;
  --blue: #3d7de0;
  --yellow: #f0b429;
  --green: #43a35a;
  --accent: var(--red);
  --radius: 14px;
}

body.page-seance   { --accent: var(--red); }
body.page-planning { --accent: var(--blue); }
body.page-nutrition{ --accent: var(--yellow); }
body.page-mesures  { --accent: var(--green); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Archivo", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 90px;
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; margin: 18px 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }

/* ---- Navigation (barre en bas, façon app mobile) ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
  max-width: 760px;
  margin: 0 auto;
}
.brand {
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
.plates { display: inline-flex; gap: 3px; align-items: center; }
.plates i {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}
.plates i:nth-child(1){ background: var(--red); }
.plates i:nth-child(2){ background: var(--blue); }
.plates i:nth-child(3){ background: var(--yellow); }
.plates i:nth-child(4){ background: var(--green); }

.userbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.userbar-name { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.userbar a { text-decoration: none; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: color-mix(in srgb, var(--surface) 92%, black);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(10px, env(safe-area-inset-bottom));
  z-index: 50;
}
.tabbar a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 18px;
  border-radius: 10px;
}
.tabbar a .dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.tabbar a.active { color: var(--text); }
.tabbar a.active .dot { background: var(--accent); }

/* ---- Composants ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

button, .btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.05s ease, filter 0.15s ease;
}
button:active { transform: scale(0.97); }
.btn-accent { background: var(--accent); color: #0d0f13; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--border); }
.btn-big { width: 100%; padding: 18px; font-size: 1.1rem; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }

input, select, textarea {
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label { font-size: 0.82rem; color: var(--muted); font-weight: 700; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .meta { color: var(--muted); font-size: 0.85rem; }

.badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.done { background: color-mix(in srgb, var(--green) 25%, transparent); color: var(--green); }

.empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 0.92rem; }

/* ---- Mode séance / timer ---- */
#workout-screen { text-align: center; }
.wk-exercise { font-size: 1.6rem; font-weight: 900; margin: 8px 0 2px; }
.wk-detail { color: var(--muted); font-weight: 700; }

.timer-wrap { position: relative; width: min(280px, 70vw); margin: 24px auto; }
.timer-wrap svg { width: 100%; transform: rotate(-90deg); }
.timer-wrap .ring-bg { stroke: var(--surface-2); }
.timer-wrap .ring-fg { stroke: var(--accent); transition: stroke-dashoffset 0.2s linear; }
.timer-value {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 3.4rem; font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.timer-value small { font-size: 0.85rem; color: var(--muted); font-weight: 700; }

.go-flash {
  animation: goflash 0.6s ease 3;
}
@keyframes goflash {
  0%, 100% { color: var(--text); }
  50% { color: var(--accent); }
}

.serie-dots { display: flex; gap: 8px; justify-content: center; margin: 14px 0; }
.serie-dots i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
}
.serie-dots i.done { background: var(--accent); border-color: var(--accent); }

/* ---- Planning ---- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.day {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.day:last-child { border-bottom: none; }
.day .day-head { font-weight: 800; font-size: 0.9rem; display: flex; justify-content: space-between; }
.day.today .day-head { color: var(--accent); }
.plan-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}
.plan-chip .actions { display: flex; gap: 6px; }
.plan-chip button { padding: 5px 9px; font-size: 0.8rem; border-radius: 8px; }
.plan-chip.done { opacity: 0.65; text-decoration: line-through; }

.chart-box svg { width: 100%; height: auto; }
.chart-box text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-box .line { stroke: var(--accent); fill: none; stroke-width: 2.5; }
.chart-box .pt { fill: var(--accent); }
.chart-box .grid { stroke: var(--border); stroke-dasharray: 3 4; }

/* ---- Nutrition ---- */
.macro-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.macro b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.macro span { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.macro .bar {
  height: 4px; border-radius: 2px; background: var(--border);
  margin-top: 6px; overflow: hidden;
}
.macro .bar i { display: block; height: 100%; background: var(--accent); }
.macro.over .bar i { background: var(--red); }

.search-results { margin-top: 8px; }
.search-results .list-item { cursor: pointer; }
.search-results .list-item:hover { background: var(--surface-2); border-radius: 8px; }

/* Sélecteur de repas (segmenté) */
.meal-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.meal-picker button {
  padding: 10px 4px;
  font-size: 0.85rem;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.meal-picker button.active {
  background: var(--accent);
  color: #0d0f13;
}

.meal-section { margin-bottom: 4px; }
.meal-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 0 2px;
  border-bottom: 1px solid var(--border);
}
.meal-head .meal-kcal { color: var(--muted); font-size: 0.82rem; font-weight: 700; }

#scan-modal, .modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow: auto;
}
#scan-reader { width: 100%; border-radius: 10px; overflow: hidden; }
.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ---- Mesures : hydratation ---- */
.water-total { font-size: 1.3rem; margin: 10px 0 6px; }
.water-total b { font-variant-numeric: tabular-nums; }
.water-bar {
  height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden;
}
.water-bar i {
  display: block; height: 100%; width: 0;
  background: var(--accent); transition: width 0.3s ease;
}
.water-bar i.done { background: var(--blue); }
.water-buttons {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px;
}
.water-buttons button { padding: 10px 4px; font-size: 0.85rem; line-height: 1.25; }
.water-buttons small { color: var(--muted); font-weight: 700; }
.water-week {
  display: flex; gap: 8px; align-items: flex-end; margin-top: 14px;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.water-week .wcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.water-week .wcol i {
  width: 100%; max-width: 26px; border-radius: 4px 4px 0 0;
  background: var(--surface-2); display: block;
}
.water-week .wcol i.done { background: var(--accent); }
.water-week .wcol span { font-size: 0.7rem; color: var(--muted); font-weight: 700; }

/* ---- Mesures : sélecteur de période ---- */
.period-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.period-picker button {
  padding: 8px 12px; font-size: 0.82rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.period-picker button.active { background: var(--accent); color: #0d0f13; }
