/* Bethel Services — feuille de style conforme au Guide d'Identité Visuelle Bethel Group */

:root {
  --vert: #19B000;
  --vert-fonce: #148C00;
  --vert-clair: #E8F8E5;
  --noir: #000000;
  --anthracite: #333333;
  --gris-perle: #F4F4F4;
  --gris-metal: #90A4AE;
  --bleu-glace: #E0F7FA;
  --blanc: #FFFFFF;
  --rouge: #C62828;
  --rouge-clair: #FDECEA;
  --ambre: #B26A00;
  --rayon: 10px;
  --ombre: 0 1px 3px rgba(0, 0, 0, .08), 0 6px 20px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gris-perle);
  color: var(--anthracite);
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3, .logo, .btn, .tab {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

h1 { font-size: 1.5rem; font-weight: 700; color: var(--noir); margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; font-weight: 600; color: var(--noir); margin: 0 0 .75rem; }
a { color: var(--vert-fonce); }

/* --- En-tête --- */
.site-header {
  background: var(--blanc);
  border-bottom: 1px solid #E3E7E9;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: .85rem 1rem .6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .04em;
  text-decoration: none;
  white-space: nowrap;
}
.logo .racine { color: var(--vert); }
.logo .suffixe { color: var(--noir); }

.session { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.session .qui {
  display: flex; flex-direction: column; min-width: 0; text-align: right; line-height: 1.25;
}
.session .qui strong, .session .qui em {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session .qui strong { color: var(--anthracite); font-weight: 600; font-size: .82rem; }
.session .qui em { font-style: normal; color: var(--gris-metal); font-size: .72rem; }
.session form { margin: 0; flex: none; }
.lien-deconnexion {
  background: none; border: 0; padding: .35rem .4rem; cursor: pointer;
  color: var(--gris-metal); font-size: .78rem; text-decoration: underline;
  font-family: inherit; white-space: nowrap;
}
.lien-deconnexion:hover { color: var(--rouge); }

@media (max-width: 430px) {
  .header-inner { padding: .7rem .8rem .5rem; gap: .5rem; }
  .logo { font-size: .98rem; letter-spacing: .02em; }
  .session .qui em { display: none; }
}

/* --- Onglets --- */
.tabs {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 .5rem;
  display: flex;
  gap: .25rem;
  overflow-x: auto;
}
.tab {
  padding: .7rem .95rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gris-metal);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--anthracite); }
.tab.actif { color: var(--noir); border-bottom-color: var(--vert); }

/* --- Contenu --- */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.entete-page { margin-bottom: 1.1rem; }
.entete-page .date { color: var(--gris-metal); font-size: .875rem; }

.carte {
  background: var(--blanc);
  border: 1px solid #E3E7E9;
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.carte + .carte { margin-top: 0; }

/* --- Cartes de contrôle (onglet Gestion) --- */
.grille-controles { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grille-controles { grid-template-columns: 1fr 1fr; } }

.carte-controle { display: flex; flex-direction: column; gap: .85rem; }
.carte-controle .titre { display: flex; align-items: center; gap: .55rem; }
.carte-controle .titre h2 { margin: 0; font-size: 1.15rem; }
.carte-controle .icone { font-size: 1.5rem; line-height: 1; }
.carte-controle .etat { font-size: .9rem; }
.etat-fait { color: var(--vert-fonce); font-weight: 600; }
.etat-attente { color: var(--ambre); font-weight: 600; }
.etat-detail { display: block; color: var(--gris-metal); font-weight: 400; font-size: .85rem; margin-top: .15rem; }

/* --- Compteur d'alertes dans les onglets --- */
.tab .compteur {
  display: inline-block; min-width: 20px; padding: 0 .35rem;
  background: var(--rouge); color: var(--blanc);
  border-radius: 999px; font-size: .72rem; line-height: 20px; text-align: center;
  vertical-align: text-top;
}

/* --- Statuts d'échéance (vidanges) --- */
.pastille {
  width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--gris-metal);
}
.pastille.a_jour { background: var(--vert); }
.pastille.a_prevoir { background: #E8A33D; }
.pastille.en_retard { background: var(--rouge); }
.pastille.inconnu { background: var(--gris-metal); }

.echeance .statut { font-weight: 600; font-size: .95rem; font-family: 'Montserrat', sans-serif; }
.echeance .statut.a_jour { color: var(--vert-fonce); }
.echeance .statut.a_prevoir { color: var(--ambre); }
.echeance .statut.en_retard { color: var(--rouge); }
.echeance .statut.inconnu { color: var(--gris-metal); }

.echeance .details {
  display: grid; grid-template-columns: auto 1fr; gap: .2rem .75rem;
  margin: .6rem 0 0; font-size: .87rem;
}
.echeance .details dt { color: var(--gris-metal); }
.echeance .details dd { margin: 0; font-weight: 600; color: var(--anthracite); }
.echeance .note {
  margin: .6rem 0 0; padding: .5rem .7rem; background: var(--gris-perle);
  border-radius: 8px; font-size: .85rem; color: var(--anthracite);
}

/* --- Entretien : en-tête d'équipement et liste d'opérations --- */
.entete-equipement {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.entete-equipement h2 { margin: 0 0 .15rem; }
.entete-equipement h2 a { color: var(--noir); text-decoration: none; }
.entete-equipement h2 a:hover { color: var(--vert-fonce); text-decoration: underline; }
.entete-equipement .rapport-meta { margin: 0; }

.liste-operations { list-style: none; margin: 0; padding: 0; }
.liste-operations > li {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem 0; border-top: 1px solid var(--gris-perle);
  flex-wrap: wrap;
}
.liste-operations > li:first-child { border-top: 0; }
.liste-operations > li.inactive { opacity: .55; }
.liste-operations .corps { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.liste-operations .intitule-op {
  font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: .93rem; color: var(--noir);
}
.liste-operations .detail-op { font-size: .8rem; color: var(--gris-metal); }
.liste-operations .detail-op .statut { font-weight: 700; font-family: 'Montserrat', sans-serif; }
.liste-operations > li > .btn { flex: none; }

/* --- Fiche machine --- */
.fiche { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; margin: 0; font-size: .9rem; }
.fiche dt { color: var(--gris-metal); }
.fiche dd { margin: 0; font-weight: 600; color: var(--anthracite); }

/* --- Édition du plan d'entretien --- */
.liste-operations.editables > li { align-items: flex-end; }
.ligne-operation {
  display: grid; gap: .5rem; flex: 1 1 100%;
  grid-template-columns: 1fr; align-items: end; margin: 0;
}
@media (min-width: 620px) {
  .ligne-operation { grid-template-columns: 1fr 7rem auto auto; }
  .liste-operations.editables > li { flex-wrap: nowrap; }
}
.ligne-operation .jours { display: flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--gris-metal); }
.ligne-operation .jours input { width: 100%; }
.ligne-operation .case, .filtres .case {
  display: flex; align-items: center; gap: .4rem;
  font-size: .85rem; color: var(--anthracite); min-height: 46px; white-space: nowrap;
}
.ligne-operation .case input, .filtres .case input {
  width: 20px; height: 20px; min-height: 0; accent-color: var(--vert);
}
.etat-operation { margin: 0; flex: none; }

.modifier-fiche { flex: 1 1 100%; margin-top: .5rem; }
.modifier-fiche summary {
  cursor: pointer; font-size: .82rem; color: var(--gris-metal);
  padding: .3rem 0; list-style-position: inside;
}
.modifier-fiche summary:hover { color: var(--anthracite); }
.modifier-fiche[open] summary { margin-bottom: .5rem; }

/* --- Listes d'alertes --- */
.liste-alertes { list-style: none; margin: 0; padding: 0; }
.liste-alertes li { padding: .9rem 0; border-top: 1px solid var(--gris-perle); }
.liste-alertes li:first-child { border-top: 0; }
.liste-alertes .entete {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
}
.liste-alertes .objet {
  font-family: 'Montserrat', sans-serif; font-weight: 600; color: var(--noir); font-size: .95rem;
}
.liste-alertes .contexte { margin: .3rem 0 0; font-size: .82rem; color: var(--gris-metal); }
.liste-alertes .boutons { margin-top: .6rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.liste-alertes .resolution {
  margin: .5rem 0 0; padding: .5rem .7rem; background: var(--vert-clair);
  border-radius: 8px; font-size: .86rem; color: #14610A;
}
.liste-alertes .resoudre {
  margin-top: .65rem; display: grid; gap: .4rem; grid-template-columns: 1fr;
}
.liste-alertes .resoudre .intitule {
  font-size: .8rem; font-weight: 600; color: var(--gris-metal);
}
.liste-alertes .resoudre button { justify-self: start; }
@media (min-width: 620px) {
  .liste-alertes .resoudre { grid-template-columns: 1fr auto; align-items: end; }
  .liste-alertes .resoudre .intitule { grid-column: 1 / -1; margin-bottom: -.2rem; }
}

/* --- Pop-up d'accueil --- */
.popup-alertes {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 100; width: min(420px, calc(100vw - 2rem));
  border: 0; border-top: 5px solid var(--vert); border-radius: var(--rayon);
  padding: 1.3rem; background: var(--blanc);
  box-shadow: 0 12px 48px rgba(0, 0, 0, .25);
}
.popup-alertes::backdrop { background: rgba(0, 0, 0, .45); }
.popup-alertes h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.popup-alertes ul { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: .6rem; }
.popup-alertes li { display: flex; align-items: center; gap: .6rem; font-size: .93rem; }
.popup-alertes strong { font-family: 'Montserrat', sans-serif; font-size: 1.05rem; }
.popup-actions { display: flex; gap: .5rem; }
.popup-actions form { margin: 0; flex: 1; }
.popup-actions .btn { width: 100%; }
.popup-actions > .btn { flex: 1; }

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .85rem 1.15rem;
  border: 0;
  border-radius: var(--rayon);
  background: var(--vert);
  color: var(--blanc);
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 48px;
  transition: background .15s ease;
}
.btn:hover { background: var(--vert-fonce); }
.btn.bloc { width: 100%; }
.btn.sombre { background: var(--noir); }
.btn.sombre:hover { background: var(--anthracite); }
.btn.secondaire { background: var(--blanc); color: var(--anthracite); border: 1px solid var(--gris-metal); }
.btn.secondaire:hover { background: var(--gris-perle); }
.btn.petit { padding: .5rem .75rem; min-height: 38px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.actions .btn { flex: 1 1 200px; }

/* --- Sections de formulaire --- */
.section-form {
  border: 1px solid #E3E7E9;
  border-radius: var(--rayon);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--blanc);
}
.section-form > h2 {
  margin: 0;
  padding: .8rem 1rem;
  background: var(--bleu-glace);
  border-bottom: 1px solid #D3EAEE;
  font-size: .95rem;
  letter-spacing: .02em;
}
.champ { padding: .9rem 1rem; border-top: 1px solid var(--gris-perle); }
.section-form .champ:first-of-type { border-top: 0; }
.champ > label.intitule {
  display: block;
  font-weight: 600;
  font-size: .92rem;
  color: var(--anthracite);
  margin-bottom: .55rem;
}

/* --- Sélecteurs segmentés (gros boutons tactiles) --- */
.options { display: grid; gap: .5rem; grid-template-columns: repeat(4, 1fr); }
.options.binaire { grid-template-columns: repeat(2, 1fr); }
.options input { position: absolute; opacity: 0; width: 0; height: 0; }
.options label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .5rem .3rem;
  border: 2px solid #DDE3E6;
  border-radius: var(--rayon);
  background: var(--blanc);
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: .95rem;
  color: var(--anthracite);
  cursor: pointer;
  text-align: center;
  user-select: none;
  transition: all .12s ease;
}
.options label:hover { border-color: var(--gris-metal); }
.options input:checked + label {
  background: var(--vert);
  border-color: var(--vert);
  color: var(--blanc);
}
.options input:checked + label.alerte {
  background: var(--rouge);
  border-color: var(--rouge);
}
/* Deux degrés : orange pour ce qui se rattrape dans la journée, rouge pour
   ce qui bloque. La règle suit celle du rouge, sa spécificité la fait gagner. */
.options input:checked + label.alerte.attention {
  background: var(--ambre);
  border-color: var(--ambre);
}
.options input:focus-visible + label { outline: 3px solid var(--bleu-glace); outline-offset: 2px; }

textarea, input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], select {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid #DDE3E6;
  border-radius: var(--rayon);
  font-family: inherit;
  font-size: 1rem;
  color: var(--anthracite);
  background: var(--blanc);
  min-height: 46px;
}
textarea { min-height: 90px; resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--vert); border-color: var(--vert); }

.aide { font-size: .8rem; color: var(--gris-metal); margin: .35rem 0 0; }

/* --- Messages --- */
.message {
  padding: .85rem 1rem;
  border-radius: var(--rayon);
  margin-bottom: 1rem;
  font-size: .9rem;
  border-left: 4px solid;
}
.message.success { background: var(--vert-clair); border-color: var(--vert); color: #14610A; }
.message.error { background: var(--rouge-clair); border-color: var(--rouge); color: #8A1F19; }
.message.info { background: var(--bleu-glace); border-color: var(--gris-metal); color: #2C4A50; }
.message.warn { background: #FFF6E5; border-color: #E8A33D; color: #7A4B00; }
.message strong { font-weight: 700; }
.message code {
  display: inline-block;
  background: var(--blanc);
  border: 1px solid var(--gris-metal);
  border-radius: 6px;
  padding: .15rem .45rem;
  font-size: .95rem;
  letter-spacing: .06em;
}

/* --- Récapitulatif & détail rapport --- */
.recap { border: 1px solid #E3E7E9; border-radius: var(--rayon); overflow: hidden; background: var(--blanc); }
.recap-section { border-top: 1px solid #E3E7E9; }
.recap-section:first-child { border-top: 0; }
.recap-section > h3 {
  margin: 0; padding: .65rem 1rem; background: var(--gris-perle);
  font-family: 'Montserrat', sans-serif; font-size: .85rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--anthracite);
}
.ligne {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; border-top: 1px solid var(--gris-perle); font-size: .93rem;
}
.recap-section > .ligne:first-of-type { border-top: 0; }
.ligne .valeur { font-weight: 700; font-family: 'Montserrat', sans-serif; white-space: nowrap; }
.ligne.ko { background: var(--rouge-clair); }
.ligne.ko .valeur { color: var(--rouge); }
.ligne.ko.attention { background: #FFF6E5; }
.ligne.ko.attention .valeur { color: var(--ambre); }
.ligne.ok .valeur { color: var(--vert-fonce); }
.observations { padding: .8rem 1rem; border-top: 1px solid var(--gris-perle); font-size: .92rem; }
.observations .intitule { font-weight: 600; display: block; margin-bottom: .2rem; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; font-family: 'Montserrat', sans-serif;
  letter-spacing: .02em; white-space: nowrap;
}
.badge.vert { background: var(--vert-clair); color: #14610A; }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge.gris { background: var(--gris-perle); color: var(--gris-metal); }
.badge.bleu { background: var(--bleu-glace); color: #2C4A50; }
.badge.ambre { background: #FFF6E5; color: #7A4B00; }

/* --- Listes / historique --- */
.filtres { display: grid; gap: .6rem; grid-template-columns: 1fr 1fr; align-items: end; }
@media (min-width: 700px) { .filtres { grid-template-columns: repeat(4, 1fr) auto; } }
.filtres label { display: block; font-size: .8rem; font-weight: 600; color: var(--gris-metal); margin-bottom: .25rem; }
.filtres .case { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--anthracite); min-height: 46px; }
.filtres .case input { width: 20px; height: 20px; min-height: 0; accent-color: var(--vert); }

.liste-rapports { list-style: none; margin: 0; padding: 0; }
.liste-rapports li { border-top: 1px solid var(--gris-perle); }
.liste-rapports li:first-child { border-top: 0; }
.liste-rapports a {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .85rem .25rem; text-decoration: none; color: inherit;
}
.liste-rapports a:hover { background: var(--gris-perle); }
.rapport-titre { font-weight: 600; color: var(--noir); font-family: 'Montserrat', sans-serif; font-size: .95rem; }
.rapport-meta { font-size: .8rem; color: var(--gris-metal); }
.rapport-badges { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }

.vide { text-align: center; color: var(--gris-metal); padding: 2rem 1rem; font-size: .92rem; }

/* --- Liste des utilisateurs --- */
.liste-utilisateurs { list-style: none; margin: 0; padding: 0; }
.liste-utilisateurs li {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between;
  padding: .9rem 0; border-top: 1px solid var(--gris-perle);
}
.liste-utilisateurs li:first-child { border-top: 0; }
.liste-utilisateurs .identite { display: flex; flex-direction: column; gap: .25rem; min-width: 0; flex: 1 1 220px; }
.liste-utilisateurs .nom { font-family: 'Montserrat', sans-serif; font-weight: 600; color: var(--noir); }
.liste-utilisateurs .meta { font-size: .82rem; color: var(--gris-metal); }
.liste-utilisateurs .etiquettes { display: flex; flex-wrap: wrap; gap: .3rem; }
.liste-utilisateurs .boutons { display: flex; flex-wrap: wrap; gap: .4rem; flex: 0 0 auto; }
.liste-utilisateurs .boutons form { margin: 0; }
@media (max-width: 620px) {
  .liste-utilisateurs li { flex-direction: column; align-items: stretch; }
}

/* --- Tableaux admin --- */
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th {
  text-align: left; background: var(--noir); color: var(--blanc);
  font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em; padding: .6rem .7rem;
}
.tableau td { padding: .6rem .7rem; border-top: 1px solid var(--gris-perle); vertical-align: middle; }
.tableau tbody tr:nth-child(even) { background: #FAFBFB; }
.tableau .actions-cellule { display: flex; gap: .4rem; flex-wrap: wrap; }
.tableau form { margin: 0; }
.table-scroll { overflow-x: auto; }

/* --- Connexion --- */
.page-connexion {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1rem;
}
.page-connexion .message { width: 100%; max-width: 380px; }
.boite-connexion { width: 100%; max-width: 380px; }
.boite-connexion .marque { text-align: center; margin-bottom: 1.5rem; }
.boite-connexion .marque .logo { font-size: 1.6rem; }
.boite-connexion .marque p {
  margin: .35rem 0 0; font-size: .82rem; color: var(--gris-metal);
  text-transform: uppercase; letter-spacing: .12em;
}
.boite-connexion .champ-simple { margin-bottom: .9rem; }
.boite-connexion label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }

/* --- Pied de page « ancrage vert » (charte) --- */
.site-footer {
  background: var(--vert);
  color: var(--blanc);
  padding: .9rem 1rem;
  text-align: center;
  font-size: .78rem;
  letter-spacing: .03em;
}
.site-footer strong { font-family: 'Montserrat', sans-serif; font-weight: 700; }

@media print {
  .site-header, .site-footer, .actions, .tabs { display: none; }
  body { background: var(--blanc); }
}
