/* MyTracks — thème sombre, accent orange */
:root {
  --brand: #fc5200;
  --brand-2: #ff7a33;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c232c;
  --line: #262d36;
  --txt-dim: #8b949e;

  /* Alias attendus par le profil altimétrique (assets/js/parcours/profile.js).
     Sans eux, getPropertyValue renvoie une chaîne vide et addColorStop lève
     une exception : le profil ne se dessine pas, et tout ce qui suit dans le
     même rendu est abandonné. */
  --accent: #d95926;
  --muted:  #8b949e;
}

body {
  background: var(--bg);
  color: #e6edf3;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Navigation ---------- */
.app-nav {
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-nav .nav-link { color: var(--txt-dim); font-weight: 500; }
.app-nav .nav-link:hover { color: #fff; }
.app-nav .nav-link.active { color: #fff; }
.app-nav .nav-link {
  display: flex; align-items: center; gap: .45rem; white-space: nowrap;
  border-radius: 8px; padding: .4rem .7rem !important;
}
.app-nav .nav-link:hover { background: rgba(255,255,255,.04); }
.app-nav .nav-link.active { background: rgba(252,82,0,.12); }
.app-nav .nav-link.active .nav-ico { color: var(--brand); opacity: 1; }
.nav-ico { font-size: 1rem; opacity: .8; }
.app-nav .navbar-nav { gap: .15rem; }
/* Actions à droite (Strava, installation, compte) : même gabarit que les liens du menu. */
.nav-action {
  display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .75rem;
  border: 1px solid var(--line); border-radius: 8px; background: transparent;
  color: var(--txt-dim); font-weight: 500; font-size: .9rem; text-decoration: none; white-space: nowrap;
}
.nav-action:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav-action-brand { border: 0; color: #fff; font-weight: 600; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.nav-action-brand:hover { background: linear-gradient(135deg, var(--brand), var(--brand-2)); filter: brightness(1.08); }
.nav-strava { color: var(--brand); }
.nav-sync { color: var(--txt-dim); font-size: .8rem; }
.nav-compte {
  display: inline-flex; align-items: center; gap: .5rem; height: 36px; padding: 0 .65rem 0 4px;
  border: 1px solid var(--line); border-radius: 999px; color: #e6edf3; text-decoration: none; white-space: nowrap;
}
.nav-compte:hover, .nav-compte[aria-expanded="true"] { color: #fff; background: rgba(255,255,255,.04); }
.nav-compte.dropdown-toggle::after { color: var(--txt-dim); margin-left: .1rem; }
.nav-avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  color: #fff; font-weight: 700; font-size: .85rem; object-fit: cover;
}
.nav-compte .badge-admin { font-size: .68rem; font-weight: 700; border-radius: 999px; padding: .25em .6em; }
.nav-menu {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .35rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); min-width: 200px;
}
.nav-menu .dropdown-item { border-radius: 8px; padding: .45rem .7rem; display: flex; align-items: center; gap: .6rem; color: #e6edf3; }
.nav-menu .dropdown-item .bi { color: var(--txt-dim); }
.nav-menu .dropdown-item:hover { background: var(--panel-2); color: #fff; }
.nav-menu .dropdown-item-brand, .nav-menu .dropdown-item-brand .bi { color: var(--brand); }
.nav-menu .dropdown-divider { border-color: var(--line); margin: .3rem 0; }
.app-nav .navbar-brand { font-size: 1.15rem; }
/* Entre 992 et 1400 px, la barre tient sur une ligne : libellés des boutons d'action masqués, icônes gardées. */
@media (min-width: 992px) and (max-width: 1399.98px) {
  .app-nav .nav-btn-label { display: none; }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
  .app-nav .nav-link { padding: .4rem .5rem !important; }
  .app-nav .nav-user { display: none; }
}
/* Menu replié (mobile) : liens en liste confortable, actions en bas. */
@media (max-width: 991.98px) {
  .app-nav .navbar-collapse { padding: .5rem 0 .75rem; }
  .app-nav .nav-link { padding: .6rem .75rem !important; }
  .app-nav .nav-actions { padding-top: .5rem; margin-top: .25rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
}
.brand-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 0 12px var(--brand);
  margin-right: .35rem;
}

.btn-brand {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none; color: #fff; font-weight: 600;
}
.btn-brand:hover { color: #fff; filter: brightness(1.08); }

/* Badge « admin » et « Se déconnecter » : l'orange du site plutôt que le jaune / rouge de Bootstrap. */
.badge-admin { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.dropdown-item-brand { color: var(--brand); }
.nav-menu .dropdown-item-brand:hover, .nav-menu .dropdown-item-brand:focus { color: var(--brand-2); background: rgba(252, 82, 0, .12); }

/* ---------- Cartes / panneaux ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.section-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--txt-dim); font-weight: 700; margin-bottom: .75rem;
}

/* ---------- Tuiles KPI ---------- */
.kpi {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  height: 100%;
}
.kpi .kpi-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--txt-dim); font-weight: 600;
}
.kpi .kpi-value {
  font-size: 1.75rem; font-weight: 700; line-height: 1.15; margin-top: .25rem;
  /* Chasses proportionnelles : tabular-nums fait paraître « 121 » distendu
     en grande taille. Les chasses fixes restent pour les colonnes de
     tableaux et les graduations, où les chiffres s'alignent (.tabnum). */
  font-variant-numeric: proportional-nums;
}
.kpi .kpi-sub { font-size: .8rem; color: var(--txt-dim); }
.kpi-accent { color: var(--brand); }

/* ---------- Badges sport ---------- */
.sport-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  border: 1px solid currentColor; opacity: .95;
}

/* ---------- Listes d'activités ---------- */
.activity-row {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); padding: .85rem 1rem; margin-bottom: .6rem;
  transition: border-color .15s, transform .15s;
}
.activity-row:hover {
  border-color: var(--brand); transform: translateX(2px); color: inherit;
}
.activity-metrics { font-variant-numeric: tabular-nums; }
.activity-metrics .m-label { font-size: .68rem; color: var(--txt-dim); text-transform: uppercase; }
.activity-metrics .m-value { font-weight: 600; }

.mini-map {
  height: 64px; border-radius: 8px; background: #0b0f14;
  border: 1px solid var(--line);
}

/* ---------- Cartes Leaflet ---------- */
.map-box { height: 420px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.map-box-lg { height: calc(100vh - 230px); min-height: 480px; }
.leaflet-container { background: #0b0f14; }
/* Le fond par défaut est déjà sombre : plus de filtre global, qui
   dégradait aussi les fonds clairs et le satellite. On n'assombrit que
   les tuiles claires, à la demande. */
.leaflet-container .leaflet-tile-pane .leaflet-layer:not(.tuiles-sombres) {
  filter: brightness(.86) saturate(.9);
}

/* ---------- Sélecteur de fond de carte (tiles.js) ---------- */
/* Le même sur toutes les cartes : bouton du fond actif, menu déroulant à vignettes. */
.leaflet-control.layer-switch { position: relative; z-index: 801; } /* menu au-dessus des boutons de zoom */
.layer-toggle {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: #e6edf3;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5); font: 600 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.layer-toggle .chevron {
  width: 16px; height: 16px; color: var(--txt-dim); transition: transform .15s;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.layer-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.layer-menu {
  position: absolute; top: calc(100% + 6px); right: 0; width: 240px; padding: 4px;
  display: grid; gap: 2px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.layer-menu[hidden] { display: none; }
.layer-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; text-align: left;
  border: 0; border-radius: 8px; background: transparent; color: #e6edf3; cursor: pointer;
}
.layer-menu button:hover, .layer-menu button[aria-checked="true"] { background: var(--panel-2); }
.layer-menu button[aria-checked="true"] strong { color: var(--brand); }
.layer-text { display: grid; min-width: 0; line-height: 1.25; }
.layer-text strong { font-size: 13px; }
.layer-text small { font-size: 11px; color: var(--txt-dim); }
.swatch { width: 28px; height: 28px; border-radius: 7px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.swatch-plan { background: linear-gradient(135deg, #f2efe9 45%, #aad3df 45% 60%, #f7f6f2 60%); }
.swatch-topo { background: repeating-radial-gradient(circle at 70% 30%, #d9e7c5 0 3px, #c4b48c 3px 4px); }
.swatch-ign { background: linear-gradient(160deg, #f6f1e4 40%, #e8b46a 40% 46%, #f6f1e4 46% 70%, #9ccb7d 70%); }
.swatch-ignphoto { background: linear-gradient(135deg, #7d8a5a, #b3a77d 45%, #4f6b3a 70%, #8c7b5c); }
.swatch-satellite { background: linear-gradient(135deg, #3d5a2c, #6b7a4a 50%, #2e4a5c); }
.swatch-sombre { background: linear-gradient(135deg, #2b2f33 45%, #3d4247 45% 60%, #24272a 60%); }

/* ---------- Heatmap calendrier ---------- */
/* Les cases sont dimensionnées en fraction de colonne : une année entière
   (53 colonnes) tient dans la carte au lieu de déborder. --cols est posé
   en style inline par le gabarit. */
.heat {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  width: 100%;
}
.heat-main { flex: 1 1 auto; min-width: 0; }

/* Colonne des jours, alignée sur les lignes de la grille */
.heat-jours {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 2px;
  font-size: .6rem;
  color: var(--txt-dim);
  padding-top: calc(.68rem + 6px);   /* hauteur de la ligne des mois */
  flex: 0 0 auto;
}
.heat-jours span {
  display: flex;
  align-items: center;
  height: 100%;
  line-height: 1;
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 53), minmax(0, 1fr));
  grid-template-rows: repeat(7, auto);
  grid-auto-flow: column;
  gap: 2px;
  width: 100%;
}
.heat-cell {
  aspect-ratio: 1 / 1;
  min-height: 7px;          /* repli si aspect-ratio n'est pas supporté */
  border-radius: 2px;
  background: #1b222b;
}
.heat-vide { visibility: hidden; }
.heat-1 { background: #3a1a08; }
.heat-2 { background: #7a3208; }
.heat-3 { background: #c24a06; }
.heat-4 { background: var(--brand); }
.heat-5 { background: #ff8c4d; }

.heat-months {
  display: grid;
  grid-template-columns: repeat(var(--cols, 53), minmax(0, 1fr));
  gap: 2px;
  font-size: .68rem;
  line-height: 1;
  color: var(--txt-dim);
  margin-bottom: 6px;
  width: 100%;
}
.heat-months > div {
  white-space: nowrap;
  overflow: hidden;
}

.heat-legende {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-top: .75rem;
  font-size: .75rem;
  color: var(--txt-dim);
}
.heat-legende .heat-cell {
  width: 11px;
  aspect-ratio: auto;
  height: 11px;
  flex: 0 0 11px;
}

/* En dessous de ~560 px, une année entière devient illisible : on bascule
   sur des cases de taille fixe et un défilement horizontal. */
@media (max-width: 560px) {
  .heat-main { overflow-x: auto; }
  .heat-grid, .heat-months {
    grid-template-columns: repeat(var(--cols, 53), 10px);
    width: max-content;
  }
  .heat-cell { aspect-ratio: auto; height: 10px; }
}

/* ---------- Météo ---------- */
.weather-chip {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .4rem .7rem;
}
.weather-chip .wx-ico { font-size: 1.25rem; }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: #e6edf3; }
.table > :not(caption) > * > * { border-color: var(--line); }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--txt-dim); font-weight: 700;
}
.tabnum { font-variant-numeric: tabular-nums; }

/* ---------- Zones FC ---------- */
.zone-bar { height: 22px; border-radius: 5px; min-width: 2px; }

/* ---------- Divers ---------- */
.app-footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.form-control, .form-select {
  background: var(--panel-2); border-color: var(--line); color: #e6edf3;
}
.form-control:focus, .form-select:focus {
  background: var(--panel-2); color: #e6edf3;
  border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(252, 82, 0, .18);
}
.chart-box { position: relative; height: 260px; }
.chart-box-sm { position: relative; height: 180px; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--txt-dim); }
.empty-state .es-ico { font-size: 2.5rem; opacity: .5; }
/* Pictogramme de sport (sport_icon) : se comporte comme un caractère. */
.sport-ico { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -.18em; }
svg.sport-ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--brand-2); }
a:hover { color: var(--brand); }

/* ---------- Flux global ---------- */
.feed-row { cursor: default; }
.feed-row:hover { transform: none; border-color: var(--line); }
.feed-row a:hover .fw-semibold { color: var(--brand-2); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  /* flex-basis sur « auto » : une taille imposée en ligne reste ronde,
     là où une base fixe de 34px écrasait l'aperçu en ovale. */
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.mates-line { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.mate-chip {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .05rem .5rem; font-size: .72rem;
}

/* ---------- En direct ---------- */
.live-card {
  background: linear-gradient(160deg, #221014, var(--panel-2));
  border: 1px solid #5a2330;
}
.live-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; margin-right: .35rem;
  animation: pulse-live 1.6s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); }
  50%      { opacity: .55; box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* ---------- Barres des tours au kilomètre ---------- */
/* Normalisées sur l'amplitude réelle des tours, pas sur zéro : sinon des
   kilomètres réguliers donnent des barres toutes identiques. */
.split-bar {
  height: 7px;
  border-radius: 4px;
  background: #222a33;
  overflow: hidden;
}
.split-bar > div {
  height: 100%;
  border-radius: 4px;
  min-width: 3px;
  transition: width .2s ease;
}

/* ---------- Bulles d'aide ---------- */
.aide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--txt-dim);
  font-size: .62rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  margin-left: .15rem;
}
.aide:hover, .aide:focus {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  outline: none;
}
.tooltip-inner {
  max-width: 320px;
  text-align: left;
  font-size: .78rem;
  line-height: 1.45;
}

/* ---------- Choix de couleur d'avatar ---------- */
.pastille {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.pastille:hover, .pastille:focus-visible {
  transform: scale(1.12);
  border-color: #fff;
  outline: none;
}

/* ---------- Éditeur de parcours ---------- */
/* Bornes kilométriques posées le long de la trace. */
.borne-km {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--panel);
  border: 1.5px solid var(--brand);
  color: var(--brand);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.borne-km::after {
  content: "km";
  font-size: .45rem;
  font-weight: 700;
  margin-top: -1px;
}

/* Profil altimétrique : le canvas se dimensionne sur son conteneur, et
   l'infobulle le survole sans décaler la mise en page. */
.profil-wrap { position: relative; height: 190px; }
.profil-wrap canvas { width: 100%; height: 100%; display: block; }
.profil-infobulle {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .15rem .5rem;
  font-size: .72rem;
  pointer-events: none;
  white-space: nowrap;
}
