/* =========================================================================
   BuroAmi — Calculateur de temps d'intervention
   Interface pensée pour l'iPad : grandes cibles tactiles, lecture immédiate.
   ========================================================================= */

:root {
  --encre:        #14232B;
  --encre-clair:  #1D3742;
  --canevas:      #EAEFED;
  --carte:        #FFFFFF;
  --accent:       #0E7C6B;
  --accent-fonce: #0A5C50;
  --accent-voile: #E4F0ED;
  --ambre:        #F0A93F;
  --ligne:        #D5DEDB;
  --doux:         #5F7178;
  --alerte:       #B4432F;

  --r-carte: 18px;
  --r-bouton: 14px;
  --cible: 54px;

  --ombre-carte: 0 1px 2px rgba(20, 35, 43, .05), 0 6px 18px rgba(20, 35, 43, .06);
  --ombre-barre: 0 -6px 28px rgba(20, 35, 43, .22);

  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.45;
  color: var(--encre);
  background: var(--canevas);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}

body.ecran-accueil-actif { padding-bottom: env(safe-area-inset-bottom); }
body.dialogue-ouvert { overflow: hidden; }

button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Typographie utilitaire ---------- */
.eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--doux);
  margin: 0 0 2px;
}

.aide {
  font-size: 14px;
  line-height: 1.4;
  color: var(--doux);
  margin: 0 0 16px;
}

/* ---------- Barre d'application ---------- */
.barre-app {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--encre);
  color: #fff;
}

.marque { text-align: center; line-height: 1.1; }
.marque__nom {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .22em;
}
.marque__sous {
  display: block;
  font-size: 11px;
  letter-spacing: .06em;
  color: #9FB4B8;
}

.barre-app__retour,
.barre-app__params {
  min-width: 48px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-bouton);
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.barre-app__params { font-size: 20px; }
.barre-app__retour[hidden] { display: none; }
.barre-app__retour:active,
.barre-app__params:active { background: rgba(255, 255, 255, .22); }

/* ---------- Écrans ---------- */
.ecran { padding: 20px 16px 8px; }
.ecran[hidden] { display: none; }

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  align-items: start;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
}
.grille--params { grid-template-columns: minmax(0, 760px); justify-content: center; }

/* ---------- Accueil ---------- */
.ecran--accueil {
  min-height: calc(100vh - 130px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.accueil { max-width: 560px; width: 100%; padding: 8px 4px 40px; }
.accueil__titre {
  font-size: clamp(34px, 7vw, 52px);
  line-height: 1.05;
  letter-spacing: -.02em;
  font-weight: 800;
  margin: 6px 0 14px;
}
.accueil__texte { color: var(--doux); margin: 0 0 30px; max-width: 42ch; }
.accueil__actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Boutons ---------- */
.bouton {
  min-height: var(--cible);
  padding: 0 22px;
  border: 0;
  border-radius: var(--r-bouton);
  font-size: 17px;
  font-weight: 650;
  transition: transform .08s ease, background-color .15s ease;
}
.bouton:active { transform: scale(.98); }

.bouton--principal { background: var(--accent); color: #fff; }
.bouton--principal:active { background: var(--accent-fonce); }

.bouton--fantome {
  background: transparent;
  color: var(--encre);
  border: 1.5px solid var(--ligne);
}
.bouton--fantome:active { background: rgba(20, 35, 43, .06); }
.bouton--sur-fonce { color: #fff; border-color: rgba(255, 255, 255, .35); }
.bouton--sur-fonce:active { background: rgba(255, 255, 255, .14); }

.bouton--xl { min-height: 64px; font-size: 19px; }

/* ---------- Cartes ---------- */
.carte {
  background: var(--carte);
  border-radius: var(--r-carte);
  box-shadow: var(--ombre-carte);
  overflow: hidden;
}
.carte--pleine { grid-column: 1 / -1; }

.carte__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 66px;
  padding: 14px 18px;
  border: 0;
  background: transparent;
  text-align: left;
}
.carte__entete--fixe { border-bottom: 1px solid var(--ligne); }
.carte__titre { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -.01em; }

.carte__chevron {
  font-size: 18px;
  color: var(--doux);
  transition: transform .18s ease;
}
.carte[data-repliee="false"] .carte__chevron { transform: rotate(180deg); }
.carte--repliable[data-repliee="true"] .carte__corps { display: none; }
.carte--repliable[data-repliee="false"] .carte__entete { border-bottom: 1px solid var(--ligne); }

.carte__corps { padding: 16px 18px 20px; }

/* ---------- Blocs de champs ---------- */
.bloc { margin-bottom: 20px; }
.bloc:last-child { margin-bottom: 0; }
.bloc__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--doux);
  margin: 0 0 8px;
}

.champ { display: block; margin-bottom: 12px; }
.champ span {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--doux);
  margin-bottom: 6px;
}
.champ input,
.champ-unite input {
  width: 100%;
  min-height: var(--cible);
  padding: 0 14px;
  border: 1.5px solid var(--ligne);
  border-radius: var(--r-bouton);
  background: #fff;
}
.champ input:focus,
.champ-unite input:focus { border-color: var(--accent); outline: none; }

.champ-unite { display: flex; align-items: center; gap: 10px; max-width: 220px; }
.champ-unite input { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.champ-unite span { font-weight: 700; color: var(--doux); }

/* ---------- Segments (choix uniques) ---------- */
.segments { display: flex; flex-wrap: wrap; gap: 8px; }
.segments--colonne { flex-direction: column; }

.segments button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-height: var(--cible);
  padding: 0 16px;
  border: 1.5px solid var(--ligne);
  border-radius: var(--r-bouton);
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  justify-content: center;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.segments--compact button { flex: 0 1 auto; font-size: 15px; padding: 0 14px; }
.segments--colonne button { width: 100%; justify-content: space-between; }

.segments button em {
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
  color: var(--doux);
  font-variant-numeric: tabular-nums;
}
.segments button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.segments button[aria-pressed="true"] em { color: rgba(255, 255, 255, .8); }
.segments button sup { font-size: .65em; }

/* ---------- Compteurs ---------- */
.groupe-compteurs { margin-bottom: 18px; }
.groupe-compteurs:last-child { margin-bottom: 0; }
.groupe-compteurs__titre {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--doux);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ligne);
}

.ligne-compteur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
}
.ligne-compteur--active .ligne-compteur__nom { color: var(--accent-fonce); }

.ligne-compteur__texte { min-width: 0; }
.ligne-compteur__nom {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}
.ligne-compteur__min {
  font-size: 13px;
  color: var(--doux);
  font-variant-numeric: tabular-nums;
}

.compteur {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: var(--r-bouton);
  background: var(--canevas);
}
.compteur button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 35, 43, .12);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--encre);
}
.compteur button:active { background: var(--accent); color: #fff; }
.compteur button:disabled { opacity: .35; box-shadow: none; }
.compteur output {
  min-width: 46px;
  text-align: center;
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.compteur--actif output { color: var(--accent-fonce); }

/* ---------- Pied de formulaire ---------- */
.pied-formulaire {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 8px 0 24px;
}

/* ---------- Barre résultat (élément signature) ---------- */
.resultat {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--encre);
  color: #fff;
  box-shadow: var(--ombre-barre);
  padding-bottom: env(safe-area-inset-bottom);
}
.resultat[hidden] { display: none; }

.resultat__barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
}
.resultat__temps { line-height: 1.05; }
.resultat__temps .eyebrow { color: #9FB4B8; }
.resultat__temps strong {
  display: block;
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ambre);
  font-variant-numeric: tabular-nums;
}
.resultat__minutes { font-size: 12px; color: #9FB4B8; font-variant-numeric: tabular-nums; }
.resultat__actions { display: flex; gap: 10px; flex: 0 0 auto; }

.resultat__detail {
  max-height: min(52vh, 460px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  padding: 4px 16px 12px;
}
.resultat__detail[hidden] { display: none; }

.detail__entete {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 10px;
  background: var(--encre);
}
.detail__entete h3 { margin: 0; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.bouton-fermer {
  width: 40px; height: 40px;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 16px;
}

.detail-tableau { max-width: 1148px; margin: 0 auto; }
.detail-groupe {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9FB4B8;
  margin: 14px 0 4px;
}
.detail-ligne {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 15px;
}
.detail-ligne span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-ligne--total {
  border-bottom: 0;
  border-top: 2px solid rgba(255, 255, 255, .35);
  margin-top: 10px;
  padding-top: 12px;
  font-size: 18px;
  font-weight: 800;
}
.detail-ligne--total span:last-child { color: var(--ambre); }
.detail-vide { color: #9FB4B8; font-size: 15px; padding: 10px 0 4px; }

/* ---------- Paramètres ---------- */
.params-section { margin-bottom: 26px; }
.params-section h3 {
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--doux);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ligne);
}
.params-ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
}
.params-ligne label { font-size: 16px; font-weight: 600; }
.params-ligne .champ-unite { max-width: 150px; flex: 0 0 auto; }
.params-ligne .champ-unite input { min-height: 48px; text-align: center; }
.params-ligne .champ-unite span { font-size: 14px; }

/* ---------- Temps prédéfinis (lecture seule) ---------- */
.params-section--fixe h3 {
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: none;
  font-weight: 800;
  color: var(--encre);
}
.params-section--fixe .aide { margin-bottom: 0; }

.params-lecture {
  border-bottom: 1px solid var(--ligne);
  padding: 4px 0;
}
.params-lecture:last-child { border-bottom: 0; }
.params-lecture__ligne {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 2px;
}
.params-lecture__nom { font-size: 16px; font-weight: 600; }
.params-lecture__min {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 800;
  color: var(--accent-fonce);
}

/* ---------- Détail des actions (paramètres + résultat) ---------- */
.actions { margin: 0 0 6px; }
.actions > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.actions > summary::-webkit-details-marker { display: none; }
.actions > summary::after {
  content: '▾';
  font-size: 12px;
  transition: transform .15s ease;
}
.actions[open] > summary::after { transform: rotate(180deg); }
.actions[open] > summary { color: var(--doux); }

.actions__liste {
  padding: 10px 14px 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--accent-voile);
}
.actions__sous-titre {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-fonce);
}
.actions__ligne {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 14px;
  color: var(--encre);
}
.actions__ligne span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions__ligne--total {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(14, 124, 107, .3);
  font-weight: 800;
}
.actions__note {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--doux);
}

/* Le même bloc, posé sur le fond sombre de la barre résultat */
.resultat .actions > summary { color: #9FB4B8; padding-left: 2px; }
.resultat .actions[open] > summary { color: #C9D8DB; }
.resultat .actions__liste { background: rgba(255, 255, 255, .07); }
.resultat .actions__ligne { color: #E7EFF0; }
.resultat .actions__sous-titre { color: var(--ambre); }
.resultat .actions__ligne--total { border-top-color: rgba(255, 255, 255, .25); }
.resultat .actions__note { color: #9FB4B8; }

/* ---------- Voile / dialogue ---------- */
.voile {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 35, 43, .55);
}
.voile[hidden] { display: none; }
.dialogue {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--r-carte);
  padding: 24px;
}
.dialogue h3 { margin: 0 0 8px; font-size: 20px; }
.dialogue p { margin: 0 0 20px; color: var(--doux); }
.dialogue__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Alerte de validation ---------- */
.alerte {
  position: fixed;
  left: 50%;
  bottom: calc(160px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  width: calc(100% - 32px);
  max-width: 520px;
  background: #fff;
  border-left: 5px solid var(--alerte);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 35, 43, .2);
  padding: 14px 16px;
}
.alerte[hidden] { display: none; }
.alerte h4 { margin: 0 0 6px; font-size: 15px; color: var(--alerte); }
.alerte ul { margin: 0; padding-left: 18px; font-size: 15px; }
.alerte li { margin-bottom: 4px; }

/* ---------- iPhone / petits écrans ---------- */
@media (max-width: 430px) {
  body { font-size: 16px; }
  .ecran { padding: 14px 12px 4px; }
  .carte__corps { padding: 14px 14px 18px; }
  .resultat__actions .bouton { padding: 0 16px; }
  .compteur button { width: 44px; height: 44px; }
  .segments--compact button { flex: 1 1 45%; }
}

/* ---------- iPad paysage : deux colonnes confortables ---------- */
@media (min-width: 1024px) {
  .ecran { padding: 24px 24px 8px; }
}

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

@media print {
  .barre-app, .resultat__actions, .pied-formulaire { display: none; }
}
