/* =========================================================================
   LAHOUEL PERFORMANCE — système de design
   Palette "parquet de nuit" : bois sombre + orange cuir de ballon + ambre
   tableau d'affichage. Toutes les couleurs et polices dérivent des tokens.
   ========================================================================= */

:root {
  /* Couleurs */
  --court: #17110c;
  --paint: #241a12;
  --paint-2: #2e2116;
  --paint-3: #38281a;
  --line: rgba(243, 237, 228, 0.08);
  --line-strong: rgba(243, 237, 228, 0.16);
  --net: #f3ede4;
  --net-dim: #b8aa98;
  --net-mute: #7d7264;
  --ball: #d8571c;
  --ball-bright: #f2703a;
  --ball-glow: rgba(216, 87, 28, 0.45);
  --amber: #f2a93d;
  --amber-glow: rgba(242, 169, 61, 0.45);
  --success: #7fa26d;
  --danger: #c1584a;

  /* Typographie */
  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-data: 'IBM Plex Mono', ui-monospace, monospace;

  /* Forme */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Ombres */
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 26px -12px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 24px 64px -16px rgba(0, 0, 0, 0.7);

  --nav-h: 64px;
  --bottomnav-h: 68px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--court);
  color: var(--net);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; }
img { max-width: 100%; display: block; }

/* Texture "grain cuir" très discrète en fond */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(216, 87, 28, 0.08), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.012) 0px, rgba(255, 255, 255, 0.012) 1px, transparent 1px, transparent 3px);
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- Structure ---------- */
#app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(23, 17, 12, 0.86);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-word { font-family: var(--font-display); font-size: 22px; letter-spacing: 0.04em; line-height: 1; color: var(--net); }
.brand-tag { display: block; font-family: var(--font-body); font-size: 9px; letter-spacing: 0.24em; color: var(--ball-bright); text-transform: uppercase; margin-top: 2px; }

.nav-desktop { display: none; gap: 4px; }
.nav-desktop a {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--net-dim); text-decoration: none; padding: 8px 14px; border-radius: var(--radius-sm);
  transition: color .15s ease, background .15s ease;
}
.nav-desktop a:hover { color: var(--net); background: var(--line); }
.nav-desktop a.active { color: var(--court); background: var(--amber); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottomnav-h);
  display: flex; z-index: 30;
  background: rgba(23, 17, 12, 0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: none; color: var(--net-mute); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; padding: 6px 0 4px; position: relative;
}
.bottom-nav button svg { width: 21px; height: 21px; stroke: currentColor; }
.bottom-nav button.active { color: var(--amber); }
.bottom-nav button.active::before {
  content: ''; position: absolute; top: 0; width: 28px; height: 2.5px; border-radius: 2px; background: var(--amber);
}

main#view-root { flex: 1; max-width: 980px; width: 100%; margin: 0 auto; padding: 20px 16px 100px; }
@media (min-width: 860px) {
  .nav-desktop { display: flex; }
  .bottom-nav { display: none; }
  main#view-root { padding: 36px 24px 64px; }
}

.view { display: none; animation: viewIn .35s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 22px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ball-bright); }
.page-title { font-size: 30px; margin-top: 4px; }
.page-sub { color: var(--net-dim); font-size: 14px; margin-top: 4px; }

/* Séparateur "ligne de terrain" avec point central */
.court-divider { border: none; border-top: 1px solid var(--line); position: relative; margin: 28px 0; }
.court-divider::after {
  content: ''; position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--court);
}

/* ---------- Cartes / surfaces ---------- */
.card {
  background: var(--paint);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.card-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--net-dim); }

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

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 13.5px; letter-spacing: 0.02em; text-transform: uppercase;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  padding: 12px 18px; transition: transform .12s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ball); color: #fff9f2; box-shadow: 0 10px 24px -8px var(--ball-glow); }
.btn-primary:hover { background: var(--ball-bright); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--net); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(193, 88, 74, 0.12); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--paint-2);
  border: 1px solid var(--line-strong); color: var(--net-dim); display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--net); border-color: var(--net-mute); }
.btn-icon svg { width: 17px; height: 17px; }
.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottomnav-h) + 18px); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; background: var(--ball); color: #fff;
  border: none; box-shadow: 0 14px 30px -8px var(--ball-glow); display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 26px; height: 26px; }
@media (min-width: 860px) { .fab { display: none; } }

/* ---------- Formulaires ---------- */
label.field-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--net-dim); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--paint-2); border: 1px solid var(--line-strong); color: var(--net);
  border-radius: var(--radius-sm); padding: 12px 13px; font-size: 15px; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--ball); box-shadow: 0 0 0 3px rgba(216, 87, 28, 0.22); }
.input::placeholder { color: var(--net-mute); }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-text { font-size: 12px; color: var(--net-mute); margin-top: 5px; }

.stepper { display: flex; align-items: stretch; background: var(--paint-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button { width: 40px; flex: none; background: var(--paint-3); border: none; color: var(--amber); font-size: 18px; font-weight: 700; }
.stepper button:active { background: var(--line-strong); }
.stepper input { flex: 1; min-width: 0; text-align: center; background: transparent; border: none; color: var(--net); font-family: var(--font-data); font-size: 16px; padding: 10px 2px; }
.stepper input:focus { outline: none; }

/* ---------- Tableau de bord : scoreboard ---------- */
.scoreboard {
  background: linear-gradient(180deg, var(--paint-3), var(--paint));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), var(--shadow-card);
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.scoreboard-cell { padding: 16px 10px; text-align: center; position: relative; }
.scoreboard-cell + .scoreboard-cell::before {
  content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px;
  background: repeating-linear-gradient(180deg, var(--line-strong) 0 4px, transparent 4px 8px);
}
.scoreboard-label { font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--net-mute); }
.scoreboard-value {
  font-family: var(--font-data); font-size: 26px; font-weight: 600; color: var(--amber);
  text-shadow: 0 0 18px var(--amber-glow); margin-top: 6px; font-variant-numeric: tabular-nums;
}
@media (min-width: 480px) { .scoreboard-value { font-size: 32px; } }
.scoreboard-delta { font-size: 11px; margin-top: 3px; color: var(--net-mute); }
.scoreboard-delta.up { color: var(--success); }
.scoreboard-delta.down { color: var(--danger); }

.hero-greet { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hero-greet h1 { font-size: 30px; }
.hero-greet p { color: var(--net-dim); font-size: 14px; margin-top: 2px; }

/* Cartes d'action rapide */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.quick-action {
  background: var(--paint); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px 14px; text-align: left; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: border-color .15s ease, transform .12s ease;
}
.quick-action:hover { border-color: var(--ball); }
.quick-action:active { transform: scale(0.98); }
.quick-action svg { width: 22px; height: 22px; color: var(--ball-bright); }
.quick-action-label { font-weight: 800; font-size: 14px; }
.quick-action-sub { font-size: 12px; color: var(--net-mute); }

/* ---------- Listes (historique) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--paint); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer;
  transition: border-color .15s ease;
}
.list-item:hover { border-color: var(--line-strong); }
.li-date { font-family: var(--font-data); font-size: 11px; color: var(--net-mute); text-transform: uppercase; }
.li-title { font-weight: 700; font-size: 15px; margin-top: 2px; }
.li-meta { font-size: 12px; color: var(--net-dim); margin-top: 2px; }
.li-right { text-align: right; flex: none; }
.li-stat { font-family: var(--font-data); color: var(--amber); font-size: 15px; }

.tag {
  display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 4px 9px; border-radius: var(--radius-pill); background: var(--paint-3); color: var(--net-dim);
  border: 1px solid var(--line-strong);
}
.tag-basket { color: var(--ball-bright); border-color: var(--ball); background: rgba(216, 87, 28, 0.12); }

/* ---------- Bannière de record (fanion suspendu) ---------- */
.pennant {
  position: relative; background: linear-gradient(135deg, var(--ball), #a8430f);
  color: #fff9f2; padding: 12px 20px 16px; border-radius: 6px 6px 0 0;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 50% 100%, 0 78%);
  text-align: center; box-shadow: var(--shadow-card);
}
.pennant-eyebrow { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.85; }
.pennant-title { font-family: var(--font-display); font-size: 20px; margin-top: 2px; }
.pennant-value { font-family: var(--font-data); font-size: 15px; margin-top: 4px; opacity: 0.95; }
.trophy-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px 14px; }
@media (min-width: 640px) { .trophy-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Graphiques ---------- */
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label { font-family: var(--font-data); font-size: 9.5px; fill: var(--net-mute); }
.chart-dot { fill: var(--court); stroke-width: 2; cursor: pointer; }
.chart-dot { stroke: var(--ball-bright); }
.chart-tooltip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--paint-3);
  border: 1px solid var(--line-strong); color: var(--net); font-family: var(--font-data); font-size: 11px;
  padding: 5px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-pop);
}
.chart-empty { padding: 30px 10px; text-align: center; color: var(--net-mute); font-size: 13px; }

.gauges-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 10px; text-align: center; }
@media (min-width: 480px) { .gauges-row { grid-template-columns: repeat(4, 1fr); } }
.gauge { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.gauge-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.gauge-value { font-family: var(--font-data); font-size: 16px; font-weight: 600; }
.gauge-label { font-size: 11px; color: var(--net-dim); margin-top: 6px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.gauge-arc { transition: stroke-dasharray .5s ease; }

.heat-svg { display: block; }
.heat-cell { fill: var(--paint-2); }
.heat-cell.heat-1 { fill: var(--ball); opacity: 0.55; }
.heat-cell.heat-2 { fill: var(--amber); }
.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--net-mute); margin-top: 8px; }
.heat-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Exercices dans le formulaire de séance ---------- */
.exo-block { background: var(--paint-2); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px; }
.exo-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.exo-name { font-weight: 800; font-size: 15px; }
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.set-index { font-family: var(--font-data); color: var(--net-mute); font-size: 12px; text-align: center; }
.set-row-head { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--net-mute); font-weight: 700; }
.pr-flag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; color: var(--amber); text-transform: uppercase; margin-left: 6px; }

/* ---------- Sélecteur d'exercice (autocomplete) ---------- */
.autocomplete { position: relative; }
.autocomplete-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--paint-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto;
  z-index: 40; box-shadow: var(--shadow-pop);
}
.autocomplete-item { padding: 10px 13px; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; }
.autocomplete-item:hover, .autocomplete-item.hl { background: var(--line); }
.autocomplete-item small { color: var(--net-mute); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 7, 4, 0.72); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100; padding: 0;
}
.modal {
  background: var(--court); border: 1px solid var(--line-strong); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-pop);
  animation: modalUp .25s ease;
}
@keyframes modalUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--court); z-index: 2; }
.modal-title { font-size: 20px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--court); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; padding: 0 16px; }
.toast {
  background: var(--paint-3); border: 1px solid var(--line-strong); color: var(--net); padding: 11px 18px;
  border-radius: var(--radius-pill); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-pop);
  animation: toastIn .25s ease; display: flex; align-items: center; gap: 8px; max-width: 92vw;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- États vides ---------- */
.empty-state { text-align: center; padding: 46px 20px; color: var(--net-dim); }
.empty-state svg { width: 42px; height: 42px; color: var(--net-mute); margin: 0 auto 14px; }
.empty-state h3 { font-size: 18px; color: var(--net); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }

/* ---------- Réglages ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); gap: 14px; }
.settings-row:last-child { border-bottom: none; }
.settings-label { font-weight: 700; font-size: 14px; }
.settings-sub { font-size: 12px; color: var(--net-mute); margin-top: 2px; }
.storage-bar { height: 6px; border-radius: 3px; background: var(--paint-2); overflow: hidden; margin-top: 8px; }
.storage-bar-fill { height: 100%; background: var(--ball); }

/* ---------- Utilitaires ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-dim { color: var(--net-dim); }
.text-mute { color: var(--net-mute); }
.text-center { text-align: center; }
.data-num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.section-title { font-size: 19px; margin-bottom: 12px; }
.hidden { display: none !important; }
