/* ------------------------------------------------------------------
   BikeBook — carnet d'entretien vélo pour le club CrossBike
   Palette : acier froid, pétrole profond, signalisation routière.
------------------------------------------------------------------ */
:root {
  --petrole:      #0E2A35;
  --petrole-clair:#164253;
  --acier:        #E7EBEC;
  --surface:      #FFFFFF;
  --trait:        #C6D0D4;
  --encre:        #10222B;
  --encre-douce:  #5A6E77;
  --signal:       #E0952B;
  --alerte:       #B23A1E;
  --valide:       #2C7A62;
  --rayon:        3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--acier);
  color: var(--encre);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: "Barlow Condensed", "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: .02em;
  margin: 0 0 .4em;
  line-height: 1.1;
}
h1 { font-size: 2.15rem; text-transform: uppercase; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }

a { color: var(--petrole-clair); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.saut {
  position: absolute; left: -9999px;
  background: var(--petrole); color: #fff; padding: .6rem 1rem;
}
.saut:focus { left: .5rem; top: .5rem; z-index: 10; }

/* -------------------------------------------------------- Structure */
.cadre { display: flex; min-height: 100vh; align-items: stretch; }

.rail {
  width: 232px; flex: 0 0 232px;
  background: var(--petrole);
  color: #D6E3E8;
  display: flex; flex-direction: column;
  padding: 1.6rem 1.2rem;
}
.marque {
  display: flex; align-items: center; gap: .7rem;
  text-decoration: none; color: #fff; margin-bottom: 2rem;
}
.marque-icone { border-radius: var(--rayon); flex-shrink: 0; }
.marque-nom {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.5rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.marque-sous {
  display: block; font-size: .72rem; letter-spacing: .18em;
  text-transform: uppercase; color: #7FA3AF;
}
.rail-liens { list-style: none; margin: 0; padding: 0; flex: 1; }
.rail-liens a {
  display: block; padding: .55rem .7rem; margin-bottom: .15rem;
  color: #C3D5DC; text-decoration: none; border-radius: var(--rayon);
  border-left: 3px solid transparent;
}
.rail-liens a:hover { background: rgba(255,255,255,.07); color: #fff; }
.rail-liens a[aria-current="page"] {
  background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--signal);
}
.rail-pied { border-top: 1px solid rgba(255,255,255,.14); padding-top: 1rem; font-size: .85rem; }
.rail-user { margin: 0 0 .5rem; color: #E7F0F3; }
.etiquette {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7FA3AF;
}
.lien-discret { color: #9FC0CA; font-size: .85rem; }

.contenu { flex: 1; min-width: 0; padding: 2.2rem clamp(1rem, 4vw, 3rem); max-width: 1180px; }
.pied-page { text-align: center; margin-top: 2.5rem; font-size: .78rem; color: var(--encre-douce); }
.pied-page--flottant { position: fixed; left: 0; right: 0; bottom: 1rem; margin-top: 0; }

/* ------------------------------------------------------------ Blocs */
.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.2rem;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.grille { display: grid; gap: 1rem; }
.grille--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grille--3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.entete-page {
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: flex-end; justify-content: space-between; margin-bottom: 1.6rem;
}
.surtitre {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--encre-douce); margin: 0 0 .3rem;
}

/* Compteur : chiffres façon tableau de bord */
.compteur {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.6rem; font-weight: 500; letter-spacing: -.01em;
}
.compteur--petit { font-size: 1.15rem; }
.mono { font-family: "IBM Plex Mono", monospace; }

/* Jauge d'échéance — élément signature */
.jauge {
  position: relative; height: 8px; border-radius: 99px;
  background: #DCE3E5; overflow: hidden; margin: .45rem 0 .3rem;
}
.jauge span { display: block; height: 100%; background: var(--valide); }
.jauge--proche span   { background: var(--signal); }
.jauge--depassee span { background: var(--alerte); }

.pastille {
  display: inline-block; padding: .12rem .5rem; border-radius: 99px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
  border: 1px solid currentColor;
}
.pastille--ok       { color: var(--valide); }
.pastille--proche   { color: #9A6410; }
.pastille--depassee { color: var(--alerte); }

/* --------------------------------------------------------- Tableaux */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
caption { text-align: left; color: var(--encre-douce); font-size: .85rem; padding-bottom: .5rem; }
th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--encre-douce); font-weight: 600;
  border-bottom: 1px solid var(--trait); padding: .5rem .6rem;
}
td { padding: .55rem .6rem; border-bottom: 1px solid #EDF1F2; vertical-align: top; }
tbody tr:hover { background: #F6F9FA; }

.num { text-align: right; font-family: "IBM Plex Mono", monospace; white-space: nowrap; }

/* Cellules « actions » : un ou plusieurs liens/mini-formes, jamais une valeur simple. */
td.actions { text-align: left !important; white-space: normal !important; }
td.actions form { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
td.actions > * + * { margin-top: .4rem; }
td.actions form input, td.actions form select { flex: 1 1 130px; min-width: 0; width: auto; }

/* ------------------------------------------------------ Formulaires */
label { display: block; font-size: .8rem; font-weight: 500; margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; color: inherit;
  background: #fff; border: 1px solid var(--trait); border-radius: var(--rayon);
}
textarea { min-height: 72px; resize: vertical; }
.champs { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.champ--large { grid-column: 1 / -1; }

.bouton {
  display: inline-block; padding: .55rem 1.1rem; border: 1px solid var(--petrole);
  background: var(--petrole); color: #fff; border-radius: var(--rayon);
  font: 500 .92rem "IBM Plex Sans", sans-serif; cursor: pointer; text-decoration: none;
  text-transform: uppercase; letter-spacing: .03em;
}
.bouton:hover { background: var(--petrole-clair); }
.bouton--secondaire { background: transparent; color: var(--petrole); }
.bouton--secondaire:hover { background: #DDE5E8; }
.bouton--petit { padding: .3rem .6rem; font-size: .8rem; }

/* Couleurs par nature d'action, pour reconnaître le niveau de risque d'un coup d'œil. */
.bouton--modifier      { background: #2F6F83; border-color: #2F6F83; color: #FFFFFF; }
.bouton--modifier:hover      { background: #35809A; border-color: #35809A; }
.bouton--admin          { background: #415A6B; border-color: #415A6B; color: #FFFFFF; }
.bouton--admin:hover         { background: #4C6A7D; border-color: #4C6A7D; }
.bouton--important      { background: #D09947; border-color: #D09947; color: #FFFFFF; }
.bouton--important:hover     { background: #DBA95E; border-color: #DBA95E; }
.bouton--avertissement  { background: #8A6A2F; border-color: #8A6A2F; color: #FFFFFF; }
.bouton--avertissement:hover { background: #9C7935; border-color: #9C7935; }
.bouton--archiver       { background: #D09947; border-color: #D09947; color: #FFFFFF; }
.bouton--archiver:hover      { background: #DBA95E; border-color: #DBA95E; }
.bouton--danger         { background: #A6403F; border-color: #A6403F; color: #FFFFFF; }
.bouton--danger:hover        { background: #B94E4D; border-color: #B94E4D; }

details.bloc-form { margin-bottom: 1.2rem; }
details.bloc-form > summary {
  cursor: pointer; font-family: "Barlow Condensed", sans-serif;
  font-size: 1.15rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .5rem .8rem; background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon);
}
details.bloc-form[open] > summary { border-bottom-color: transparent; }
details.bloc-form .carte { border-top: 0; margin-top: 0; }

.flash {
  padding: .7rem 1rem; border-radius: var(--rayon); margin: 0 0 1.2rem;
  border-left: 4px solid var(--valide); background: #E6F2EE;
}
.flash--erreur { border-left-color: var(--alerte); background: #F8E9E5; }

.vide { color: var(--encre-douce); font-style: italic; }
.onglets { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.2rem; }
.onglets a {
  padding: .4rem .9rem; text-decoration: none; color: var(--encre-douce);
  border: 1px solid var(--trait); border-radius: 99px; background: var(--surface);
  font-size: .88rem;
}
.onglets a[aria-current="page"] { background: var(--petrole); color: #fff; border-color: var(--petrole); }

/* ------------------------------------------------------------ Carte */
.plan-commandes { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; }
.plan {
  height: 62vh; min-height: 340px; width: 100%;
  border: 1px solid var(--trait); border-radius: var(--rayon);
  background: #DCE3E5;
  /* Les contrôles Leaflet montent à z-index 1000 : on les garde dans la carte. */
  position: relative; z-index: 0;
}
.plan--saisie { cursor: crosshair; outline: 2px solid var(--signal); outline-offset: 2px; }
.plan-etat { min-height: 1.4em; margin: .4rem 0 1rem; font-size: .85rem; color: var(--encre-douce); }
.plan-filtres { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin-bottom: .8rem; }
.plan-filtres label {
  display: flex; align-items: center; gap: .4rem; margin: 0;
  font-size: .88rem; font-weight: 400; cursor: pointer;
}
.plan-filtres input { width: auto; }
.aide-plan { margin-top: 0; font-size: .88rem; color: var(--encre-douce); }

.puce { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; flex-shrink: 0; }
.puce--reparation { background: #2C7A62; }
.puce--gonflage   { background: #D08420; }
.puce--eau        { background: #2B6CB0; }
.puce--osm        { background: #fff; border: 2px solid var(--encre-douce); }

.repere {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid #fff; color: #fff;
  box-shadow: 0 1px 4px rgba(16,34,43,.45);
}
.repere svg { width: 17px; height: 17px; fill: currentColor; }
.repere--reparation { background: #2C7A62; }
.repere--gonflage   { background: #D08420; }
.repere--eau        { background: #2B6CB0; }
/* Point OpenStreetMap : même couleur, en contour, pour le distinguer du club. */
.repere--osm { background: #fff; border-width: 2px; }
.repere--osm.repere--reparation { color: #2C7A62; border-color: #2C7A62; }
.repere--osm.repere--gonflage   { color: #D08420; border-color: #D08420; }
.repere--osm.repere--eau        { color: #2B6CB0; border-color: #2B6CB0; }
.repere--attente { opacity: .6; border-style: dashed; }
.repere--neuf { outline: 3px solid var(--signal); outline-offset: 1px; }

.bulle { font: .88rem/1.45 "IBM Plex Sans", sans-serif; min-width: 180px; }
.bulle strong { font-size: .95rem; }
.bulle-type { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--encre-douce); }
.bulle-attente { margin-top: .3rem; color: #9A6410; font-size: .8rem; }
.bulle p { margin: .4rem 0 0; }
.bulle-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; }
.bulle-actions form { margin: 0; }

.proches-liste { margin: 0; padding: 0; list-style: none; }
.proches-liste li {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .55rem 0; border-bottom: 1px solid #EDF1F2;
}
.proches-liste li:last-child { border-bottom: 0; }
.proches-liste .mono { margin-left: auto; }
.lien-bouton {
  background: none; border: 0; padding: 0; font: inherit; color: var(--petrole-clair);
  text-decoration: underline; cursor: pointer; text-align: left;
}

.identifiants { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.identifiants .carte { width: min(420px, 100%); }

@media (max-width: 780px) {
  .cadre { flex-direction: column; }
  .rail { width: 100%; flex: none; flex-direction: row; flex-wrap: wrap;
          align-items: center; gap: .8rem; padding: 1rem; }
  .marque { margin: 0; flex: 1 1 100%; }
  .rail-liens { display: flex; flex-wrap: wrap; gap: .3rem; flex: 1 1 auto; }
  .rail-pied { border-top: 0; padding: 0; }
  .contenu { padding: 1.4rem 1rem; }

  /* Tableaux : une fiche empilée par ligne plutôt qu'un défilement horizontal */
  table.tableau-mobile thead { display: none; }
  table.tableau-mobile, table.tableau-mobile caption, table.tableau-mobile tbody,
  table.tableau-mobile tr, table.tableau-mobile td { display: block; width: 100%; }
  table.tableau-mobile tr {
    border: 1px solid var(--trait); border-radius: var(--rayon);
    padding: .3rem .8rem; margin-bottom: .8rem;
  }
  table.tableau-mobile td {
    display: flex; justify-content: space-between; align-items: baseline; gap: .8rem;
    border-bottom: 1px solid #EDF1F2; padding: .5rem 0; text-align: right;
  }
  table.tableau-mobile td:last-child { border-bottom: 0; }
  table.tableau-mobile td::before {
    content: attr(data-label); font-size: .72rem; text-transform: uppercase;
    letter-spacing: .1em; color: var(--encre-douce); text-align: left; flex-shrink: 0;
  }
  table.tableau-mobile td.vide {
    text-align: left; border-bottom: 0;
  }
  table.tableau-mobile td.vide::before { content: none; }

  /* Cellules « riches » (lien + texte + badge…) : regroupées dans un seul bloc,
     pour ne pas laisser chaque élément se disputer la ligne indépendamment. */
  table.tableau-mobile td.cellule-riche { text-align: left; }
  table.tableau-mobile td.cellule-riche > div {
    flex: 1; min-width: 0; max-width: 100%; text-align: left;
    overflow-wrap: anywhere; word-break: break-word;
  }
  table.tableau-mobile td.cellule-riche > div a { overflow-wrap: anywhere; word-break: break-word; }

  /* Cellules d'actions (un ou plusieurs formulaires) : pleine largeur, empilées,
     pas la mise en page « étiquette + valeur » des autres colonnes. */
  table.tableau-mobile td.actions {
    display: block !important; text-align: left; padding-top: .7rem;
  }
  table.tableau-mobile td.actions::before { content: none; }
  table.tableau-mobile td.actions > a.bouton { display: block; width: 100%; text-align: center; margin-top: .5rem; }
  table.tableau-mobile td.actions form {
    display: flex; flex-direction: column; align-items: stretch; gap: .4rem;
    width: 100%; margin-top: .5rem;
  }
  table.tableau-mobile td.actions form > * { width: 100%; flex: none; text-align: center; }
  table.tableau-mobile td.actions > :first-child { margin-top: 0; }

  /* Cibles tactiles plus grandes : les boutons "petit" restent lisibles à la
     souris, mais deviennent difficiles à toucher précisément au doigt. */
  table.tableau-mobile td.actions .bouton--petit,
  table.tableau-mobile td.actions select,
  table.tableau-mobile td.actions input {
    padding: .7rem 1.1rem; font-size: .92rem;
  }
}

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