/* ULTRAMOV — feuille de style du portail (lot L9, cahier F9.3, F9.4).
 *
 * Aucune police externe, aucun CDN : la pile système suffit et se charge en
 * zéro requête. Tout ce qui relève de la MARQUE d'une société (couleur, logo,
 * nom, pied de page) passe par les variables CSS ci-dessous, jamais par une
 * feuille de style par client : `app/theme.js` écrit `--umv-marque` sur
 * `:root` après `GET /api/v1/portail/marque`.
 *
 * L'attribution de la carte (classe `umv-attribution`, posée par le module
 * carte de L3) n'est JAMAIS stylée ici : elle est volontairement hors de
 * portée de toute feuille de marque (F2.2).
 *
 * Cibles tactiles : 44 px minimum partout (cahier de lot L9, point 9).
 */

/* --- Couleurs : jour par défaut, nuit si le système la demande ------------ */

:root {
  --umv-marque: #1565c0;
  --umv-marque-texte: #ffffff;

  --umv-fond: #f5f6f8;
  --umv-fond-carte: #ffffff;
  --umv-fond-doux: #eceef1;
  --umv-texte: #1a1c1e;
  --umv-texte-doux: #55595e;
  --umv-bord: #d6d9dd;

  --umv-ok: #2e7d32;
  --umv-attention: #a86a00;
  --umv-danger: #c62828;
  --umv-info: #1565c0;

  --umv-rayon: 10px;
  --umv-cible: 44px;
  --umv-ombre: 0 1px 2px rgba(0, 0, 0, .08), 0 2px 8px rgba(0, 0, 0, .04);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="jour"]) {
    --umv-fond: #14171a;
    --umv-fond-carte: #1e2226;
    --umv-fond-doux: #262b30;
    --umv-texte: #eceef1;
    --umv-texte-doux: #a8aeb5;
    --umv-bord: #343a40;
    --umv-ok: #6abf69;
    --umv-attention: #e0a33a;
    --umv-danger: #ef5350;
    --umv-info: #64b5f6;
    --umv-ombre: 0 1px 2px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="nuit"] {
  --umv-fond: #14171a;
  --umv-fond-carte: #1e2226;
  --umv-fond-doux: #262b30;
  --umv-texte: #eceef1;
  --umv-texte-doux: #a8aeb5;
  --umv-bord: #343a40;
  --umv-ok: #6abf69;
  --umv-attention: #e0a33a;
  --umv-danger: #ef5350;
  --umv-info: #64b5f6;
  --umv-ombre: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* --- Base ----------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--umv-fond);
  color: var(--umv-texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.35rem; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: .95rem; margin: .9rem 0 .35rem; }
p  { margin: .4rem 0; }
a  { color: var(--umv-marque); }

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

.doux   { color: var(--umv-texte-doux); }
.petit  { font-size: .85rem; }
.gras   { font-weight: 600; }
.centre { text-align: center; }
.cache  { display: none !important; }

/* --- Mise en page --------------------------------------------------------- */

#coquille {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#entete {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--umv-fond-carte);
  border-bottom: 1px solid var(--umv-bord);
}

.entete-ligne {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
}

.marque {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-weight: 700;
  color: var(--umv-marque);
  white-space: nowrap;
}

.marque img { height: 28px; width: auto; max-width: 120px; }

#vue {
  flex: 1 1 auto;
  padding: .7rem .7rem 5.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

#vue.pleine { padding: 0 0 4.6rem; max-width: none; }

#pied {
  padding: .8rem .7rem 5.5rem;
  color: var(--umv-texte-doux);
  font-size: .8rem;
  text-align: center;
}

/* --- Trois entrées : en bas sur téléphone, à gauche sur ordinateur -------- */

#entrees {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: var(--umv-fond-carte);
  border-top: 1px solid var(--umv-bord);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.entree {
  flex: 1 1 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--umv-texte-doux);
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  position: relative;
}

.entree[aria-current="page"] { color: var(--umv-marque); font-weight: 600; }
.entree .icone { font-size: 1.25rem; line-height: 1; }

.pastille {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--umv-danger);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

@media (min-width: 860px) {
  /* Grille et non flex à retour de ligne : avec « flex-wrap », l'espace vertical
     libre était réparti ENTRE les lignes et laissait une grande bande blanche
     sous l'en-tête dès que l'écran était plus haut que le contenu (constaté au
     premier démarrage réel, 3 septembre 2026). */
  #coquille {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    align-content: start;
  }
  #entete { grid-column: 1 / -1; grid-row: 1; }
  #entrees {
    grid-column: 1;
    grid-row: 2;
    position: sticky;
    top: 0;
    align-self: start;
    flex-direction: column;
    height: auto;
    border-top: 0;
    border-right: 1px solid var(--umv-bord);
    padding: .5rem 0;
  }
  .entree { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: .6rem; padding: 0 1rem; font-size: .95rem; }
  .pastille { position: static; margin-left: auto; }
  #vue { grid-column: 2; grid-row: 2; padding-bottom: 1.5rem; }
  #pied { grid-column: 1 / -1; grid-row: 3; padding-bottom: 1rem; }
}

/* --- Barre de recherche unique ------------------------------------------- */

#recherche { position: relative; flex: 1 1 auto; min-width: 0; }

#recherche input {
  width: 100%;
  min-height: var(--umv-cible);
  padding: .5rem .75rem;
  border: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon);
  background: var(--umv-fond);
  color: var(--umv-texte);
  font: inherit;
}

#suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 50;
  max-height: 65vh;
  overflow-y: auto;
  background: var(--umv-fond-carte);
  border: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon);
  box-shadow: var(--umv-ombre);
  list-style: none;
  margin: 0;
  padding: 4px;
}

#suggestions li { margin: 0; }

#suggestions button {
  display: block;
  width: 100%;
  min-height: var(--umv-cible);
  padding: .5rem .6rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--umv-texte);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

#suggestions button:hover { background: var(--umv-fond-doux); }

/* --- Bannière santé du parc ---------------------------------------------- */

#sante {
  padding: .45rem .7rem;
  font-size: .88rem;
  background: var(--umv-fond-doux);
  border-top: 1px solid var(--umv-bord);
  color: var(--umv-texte);
}

#sante.attention { background: #fff4e0; color: #6b4a00; }
#sante.souci     { background: #fdecec; color: #7d1d1d; }

:root[data-theme="nuit"] #sante.attention,
:root:not([data-theme="jour"]) #sante.attention { background: #3a2c10; color: #f0d49a; }
:root[data-theme="nuit"] #sante.souci,
:root:not([data-theme="jour"]) #sante.souci { background: #3a1b1b; color: #f5b5b5; }

/* --- Cartes, listes, boutons --------------------------------------------- */

.carte {
  background: var(--umv-fond-carte);
  border: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon);
  padding: .7rem .8rem;
  margin-bottom: .6rem;
  box-shadow: var(--umv-ombre);
}

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { margin-bottom: .5rem; }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: var(--umv-cible);
  min-width: var(--umv-cible);
  padding: .5rem .9rem;
  border: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon);
  background: var(--umv-fond-carte);
  color: var(--umv-texte);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.bouton:hover { background: var(--umv-fond-doux); }
.bouton[disabled] { opacity: .5; cursor: not-allowed; }

.bouton.principal {
  background: var(--umv-marque);
  border-color: var(--umv-marque);
  color: var(--umv-marque-texte);
  font-weight: 600;
}

.bouton.danger { color: var(--umv-danger); border-color: var(--umv-danger); }
.bouton.large  { width: 100%; }

.boutons { display: flex; flex-wrap: wrap; gap: .5rem; }

label { display: block; margin: .55rem 0 .2rem; font-size: .9rem; color: var(--umv-texte-doux); }

input, select, textarea {
  width: 100%;
  min-height: var(--umv-cible);
  padding: .5rem .6rem;
  border: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon);
  background: var(--umv-fond-carte);
  color: var(--umv-texte);
  font: inherit;
}

textarea { min-height: 88px; }

/* Interrupteur des règles : une case à cocher de 44 px, sans image. */
.interrupteur { display: flex; align-items: center; gap: .7rem; cursor: pointer; }
.interrupteur input { width: 26px; height: 26px; min-height: 26px; flex: 0 0 auto; accent-color: var(--umv-marque); }
.interrupteur span { flex: 1 1 auto; }

.onglets { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .7rem; }

.onglet {
  min-height: var(--umv-cible);
  padding: .45rem .8rem;
  border: 1px solid var(--umv-bord);
  border-radius: 999px;
  background: var(--umv-fond-carte);
  color: var(--umv-texte);
  font: inherit;
  cursor: pointer;
}

.onglet[aria-selected="true"] {
  background: var(--umv-marque);
  border-color: var(--umv-marque);
  color: var(--umv-marque-texte);
  font-weight: 600;
}

.puce {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.etiquette {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--umv-fond-doux);
  color: var(--umv-texte-doux);
}

.etiquette.critique { background: #fdecec; color: #7d1d1d; }
.etiquette.attention { background: #fff4e0; color: #6b4a00; }
.etiquette.ok { background: #e7f4e8; color: #1e5c22; }

.rangee { display: flex; align-items: center; gap: .6rem; }
.rangee .grandit { flex: 1 1 auto; min-width: 0; }

.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th, .tableau td { padding: .45rem .4rem; border-bottom: 1px solid var(--umv-bord); text-align: left; }
.tableau th { color: var(--umv-texte-doux); font-weight: 600; }
.defile { overflow-x: auto; }

.message { padding: .6rem .8rem; border-radius: var(--umv-rayon); margin-bottom: .6rem; }
.message.erreur { background: #fdecec; color: #7d1d1d; }
.message.succes { background: #e7f4e8; color: #1e5c22; }

/* --- Carte et fiche véhicule --------------------------------------------- */

#zone-carte { position: relative; width: 100%; height: calc(100vh - 190px); min-height: 320px; }

@media (min-width: 860px) { #zone-carte { height: calc(100vh - 130px); } }

.fiche {
  position: fixed;
  left: 0; right: 0; bottom: 56px;
  z-index: 45;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--umv-fond-carte);
  border-top: 1px solid var(--umv-bord);
  border-radius: var(--umv-rayon) var(--umv-rayon) 0 0;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, .18);
  padding: .8rem;
}

@media (min-width: 860px) {
  .fiche {
    left: auto; right: 0; top: 0; bottom: 0;
    width: 380px;
    max-height: none;
    border-radius: 0;
    border-left: 1px solid var(--umv-bord);
  }
}

.fiche h2 { margin-top: 0; }
.fiche dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; margin: .5rem 0; font-size: .92rem; }
.fiche dt { color: var(--umv-texte-doux); }
.fiche dd { margin: 0; }

/* --- Tiroir Réglages ------------------------------------------------------ */

#tiroir {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .35);
  display: flex;
  justify-content: flex-end;
}

#tiroir .panneau {
  width: min(560px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--umv-fond);
  padding: .8rem .8rem 3rem;
}

/* --- Impression : les rapports sortent en PDF par le navigateur ---------- */

@media print {
  #entete, #entrees, #pied, .fiche, .sans-impression { display: none !important; }
  #vue { padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 12px; }
  .carte { border: 0; box-shadow: none; padding: 0; margin-bottom: .5cm; break-inside: avoid; }
  .tableau th, .tableau td { border-bottom: 1px solid #999; }
  a[href]::after { content: ""; }
  @page { margin: 1.5cm; }
}
