/* ==========================================================================
   AZIMUT PARTNERS — Espace Démonstration : Production
   (assets/css/espace-production.css)

   Styles propres à l'écran de suivi de production (façon GPAO). Le thème sombre et les
   panneaux viennent de espace-demonstration.css ; les indicateurs, les tableaux, les
   actions, l'accueil pastel et les champs de scénario de espace-tableau-de-bord.css.

   Sommaire
     1. Boutons à deux états du pointage
        (les pastilles d'écart, les constats, les jauges colorées et la quantité modifiable sont dans
         espace-tableau-de-bord.css, partie 10 : la rubrique Gestion commerciale les utilise aussi)
     2. Suivi des affaires
     3. Heures prévues et réalisées
     4. Pointage des heures et alertes de l'atelier
     5. Scénario « Stock et approvisionnements » et réponse de l'assistant
     6. Pièces et matières disponibles
     7. Planning de fabrication (diagramme de Gantt) et légendes
     8. Suivi des marges

   Code des couleurs : vert = conforme ou disponible, rouge = dépassement, déficit ou retard.
   La couleur n'est jamais seule à porter l'information : un texte l'accompagne toujours.
   ========================================================================== */


/* 1. BOUTONS À DEUX ÉTATS DU POINTAGE ---------------------------------------- */

/* Bouton à deux états utilisé hors de la liste des actions (« Relancer », puis « Relancé ») */
.pointeur .action__bouton[aria-pressed="true"] {
  border-color: rgba(61, 220, 151, 0.5);
  background: rgba(61, 220, 151, 0.14);
  color: #7af0bd;
}

.pointeur .action__bouton[aria-pressed="true"] .icone {
  display: block;
}



/* 2. SUIVI DES AFFAIRES ------------------------------------------------------ */

/* Largeur minimale : seulement quand le tableau est un vrai tableau (en dessous de 1000 px, il passe en fiches) */
@media (min-width: 1000px) {
  .tableau--affaires {
    min-width: 820px;
  }
}

.tableau--affaires th,
.tableau--stock th {
  padding: 10px;
}

.affaire__heures {
  margin-right: 10px;
  font-variant-numeric: tabular-nums;
}

.statut--commandee {
  background: rgba(139, 123, 255, 0.2);
  color: #cfc6ff;
}

/* En fiches (moins de 1000 px) : les heures, plus longues, occupent la dernière ligne de la fiche, sur toute sa largeur */
@media (max-width: 999px) {
  .tableau--affaires td:nth-child(5) {
    grid-column: 1 / -1;
    order: 1;
  }
}


/* 3. HEURES PRÉVUES ET RÉALISÉES ---------------------------------------------- */

.heures {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.heure {
  display: grid;
  gap: 6px;
}

.heure__titre {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  line-height: 1.3;
}

.heure__titre span {
  color: var(--doux);
  font-size: 0.875rem;
}

/* Barre : la partie pleine montre les heures réalisées ; le repère, les heures prévues ; les hachures, le dépassement */
.heure__barre {
  position: relative;
  height: 14px;
  margin: 4px 0;
  border-radius: 5px;
  background: rgba(104, 152, 255, 0.2);
}

.heure__realise,
.heure__depassement {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  transition: width 0.9s var(--courbe);
}

.heure__realise {
  left: 0;
  border-radius: 5px 0 0 5px;
  background: linear-gradient(90deg, #14b8c4, #5ef0f8);
}

.heure__depassement {
  border-radius: 0 5px 5px 0;
  background: repeating-linear-gradient(135deg, #ff8f8f 0 6px, #d94f4f 6px 12px);
  transition-delay: 0.6s;
}

.heure__repere {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--clair);
}

.heure__chiffres {
  color: var(--doux);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.heure__etat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}

.heure__etat--bon {
  color: #7af0bd;
}

.heure__etat--alerte {
  color: #ffb0b0;
}

.heure__etat--neutre {
  color: #c5d2f2;
}


/* 4. POINTAGE DES HEURES ET ALERTES DE L'ATELIER ------------------------------ */

.pointage {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Un salarié : avatar, nom et poste, état du pointage ; dessous, les heures, puis le rappel éventuel */
.pointeur {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--trait);
}

.pointeur:first-child {
  padding-top: 0;
  border-top: 0;
}

.pointeur__avatar {
  display: grid;
  grid-row: 1 / span 2;
  grid-column: 1;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(46, 230, 240, 0.4);
  border-radius: 50%;
  background: rgba(46, 230, 240, 0.1);
  color: var(--cyan-demo);
  font-size: 0.8125rem;
  font-weight: 700;
}

.pointeur__nom {
  grid-row: 1;
  grid-column: 2;
  font-weight: 600;
  line-height: 1.25;
}

.pointeur__poste {
  grid-row: 2;
  grid-column: 2;
  color: var(--doux);
  font-size: 0.8125rem;
  line-height: 1.3;
}

.pointeur > .statut {
  grid-row: 1 / span 2;
  grid-column: 3;
}

.pointeur__heures {
  display: grid;
  grid-row: 3;
  grid-column: 2 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.pointeur__manque {
  display: flex;
  grid-row: 4;
  grid-column: 2 / -1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-top: 6px;
  color: #ffb0b0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
}

/* Alertes de l'atelier : les titres sont longs, le bouton passe toujours sous le texte */
[data-alertes] .action {
  grid-template-columns: 40px minmax(0, 1fr);
}

[data-alertes] .action__bouton {
  grid-column: 2;
  justify-self: start;
}

[data-alertes] .action > span:nth-child(2) {
  hyphens: manual;
}


/* 5. SCÉNARIO « STOCK ET APPROVISIONNEMENTS » --------------------------------- */

.rangee--stock {
  scroll-margin-top: calc(var(--hauteur-bandeau) + 16px);
}

/* Côte à côte sur très grand écran seulement : le tableau du scénario a besoin de place */
@media (min-width: 1700px) {
  .rangee--stock {
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
    align-items: start;
  }
}

.stock__ordre {
  max-width: 460px;
}

.stock__objet {
  color: var(--doux);
  font-size: 0.875rem;
}

@media (min-width: 1000px) {
  .tableau--stock {
    min-width: 780px;
  }
}

.tableau--stock td strong {
  display: block;
  font-weight: 600;
}

.article__unite,
.contact span {
  color: var(--doux);
  font-size: 0.8125rem;
}

.tableau--stock .besoin {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.est-deficit .quantite {
  border-color: rgba(255, 128, 128, 0.75);
}

.stock__boutons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.stock__boutons .bouton-demo {
  padding: 0 18px;
  font-size: 0.9688rem;
}

/* Réponse de l'assistant : toujours signalée comme simulée */
.reponse {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid rgba(139, 123, 255, 0.45);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(34, 28, 92, 0.62), rgba(12, 24, 58, 0.78));
}

.reponse[hidden] {
  display: none;
}

.reponse__entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.reponse .assistant__bulle {
  align-items: start;
  font-weight: 500;
  line-height: 1.45;
}

.reponse__note {
  color: var(--doux);
  font-size: 0.8125rem;
}

/* En fiches (moins de 1000 px) : les pastilles gardent leur largeur, le contact occupe toute la fiche */
@media (max-width: 999px) {
  .tableau--fiches .ecart-heures,
  .tableau--fiches .ecart-stock,
  .tableau--stock .quantite {
    justify-self: start;
  }

  .tableau--stock td.contact {
    grid-column: 1 / -1;
  }
}

/* Téléphone : la seconde colonne de la fiche prend la largeur de la quantité modifiable */
@media (max-width: 519px) {
  .tableau--stock tr {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}


/* 6. PIÈCES ET MATIÈRES DISPONIBLES ------------------------------------------- */

.disponibles {
  display: grid;
  gap: 16px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 700px) and (max-width: 1699px) {
  .disponibles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) and (max-width: 1699px) {
  .disponibles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.disponible {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
}

.disponible__nom {
  font-weight: 600;
  line-height: 1.3;
}

.disponible .jauge,
.disponible__chiffres {
  grid-column: 1 / -1;
}

.disponible__chiffres {
  color: var(--doux);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}


/* 7. PLANNING DE FABRICATION (DIAGRAMME DE GANTT) ------------------------------ */
/* Une ligne par affaire, une colonne par jour ouvré. --jours et --semaines sont donnés par espace-production.js.
   Sur petit écran, le diagramme défile de côté dans son cadre ; la colonne des affaires reste visible. */

.gantt-cadre {
  overflow-x: auto;
  border: 1px solid var(--trait);
  border-radius: 14px;
  background: rgba(8, 18, 48, 0.55);
}

.gantt {
  --largeur-affaire: 184px;
  --jours: 20;
  --semaines: 4;
  min-width: 940px;
}

@media (max-width: 699px) {
  .gantt {
    --largeur-affaire: 118px;
    min-width: 900px;
  }
}

.gantt__entete,
.gantt__ligne {
  display: grid;
  grid-template-columns: var(--largeur-affaire) minmax(0, 1fr);
}

.gantt__entete {
  border-bottom: 1px solid var(--trait);
}

.gantt__coin,
.gantt__affaire {
  position: sticky;
  left: 0;
  z-index: 3;
  border-right: 1px solid var(--trait);
  background: var(--surface-pleine);
}

.gantt__coin {
  display: grid;
  grid-row: 1 / span 2;
  align-content: end;
  padding: 10px 14px;
  color: var(--doux);
  font-size: 0.8125rem;
  font-weight: 600;
}

.gantt__semaines,
.gantt__jours,
.gantt__piste {
  display: grid;
  grid-column: 2;
}

.gantt__semaines {
  grid-template-columns: repeat(var(--semaines), minmax(0, 1fr));
}

.gantt__semaine {
  display: grid;
  padding: 8px 10px 2px;
  border-left: 1px solid var(--trait);
  line-height: 1.3;
}

.gantt__semaine:first-child,
.gantt__jour:first-child {
  border-left: 0;
}

.gantt__semaine strong {
  font-size: 0.8125rem;
}

.gantt__semaine span {
  color: var(--doux);
  font-size: 0.75rem;
}

.gantt__jours,
.gantt__piste {
  grid-template-columns: repeat(var(--jours), minmax(0, 1fr));
}

.gantt__jour {
  padding: 4px 0 6px;
  color: var(--doux);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.gantt__jour.est-lundi {
  border-left: 1px solid var(--trait);
}

.gantt__jour.est-aujourdhui {
  border-radius: 6px 6px 0 0;
  background: var(--cyan-demo);
  color: #03131f;
}

.gantt__corps {
  position: relative;
}

.gantt__ligne + .gantt__ligne {
  border-top: 1px solid var(--trait);
}

.gantt__affaire {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 2px;
  padding: 10px 14px;
  line-height: 1.25;
}

.gantt__affaire strong {
  font-variant-numeric: tabular-nums;
}

.gantt__affaire > span:not(.statut) {
  color: var(--doux);
  font-size: 0.8125rem;
}

.gantt__affaire .statut {
  margin-top: 4px;
  padding: 2px 9px;
  font-size: 0.75rem;
}

/* Piste d'une affaire : un trait par semaine, un trait plus léger par jour */
.gantt__piste {
  position: relative;
  align-items: center;
  min-height: 80px;
  background:
    linear-gradient(90deg, var(--trait) 1px, transparent 1px) 0 0 / calc(100% / var(--semaines)) 100%,
    linear-gradient(90deg, rgba(104, 152, 255, 0.09) 1px, transparent 1px) 0 0 / calc(100% / var(--jours)) 100%;
}

/* Tâche : une barre à la couleur de sa phase, qui se déploie à l'affichage */
.gantt__tache {
  z-index: 1;
  grid-row: 1;
  height: 30px;
  margin: 0 2px;
  padding: 0 7px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(3, 19, 31, 0.2);
  color: #03131f;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 30px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.7s var(--courbe);
}

.gantt.est-pret .gantt__tache {
  transform: none;
}

/* Tâche d'une seule journée : nom abrégé, centré */
.gantt__tache--courte {
  padding: 0 2px;
  text-align: center;
  text-overflow: clip;
}

/* Jours travaillés après la livraison prévue */
.gantt__retard {
  grid-row: 1;
  height: 46px;
  border: 1px dashed rgba(255, 128, 128, 0.85);
  border-radius: 10px;
  background: repeating-linear-gradient(135deg, rgba(255, 128, 128, 0.3) 0 6px, rgba(255, 128, 128, 0.08) 6px 12px);
}

/* Livraison prévue : un trait pointillé en fin de journée, surmonté d'un losange ; rouge quand elle est dépassée */
.gantt__jalon {
  position: relative;
  z-index: 2;
  grid-row: 1;
  align-self: stretch;
  justify-self: end;
  width: 0;
  border-left: 2px dashed rgba(241, 245, 255, 0.75);
  color: var(--clair);
}

.gantt__jalon::before {
  content: "";
  position: absolute;
  top: 5px;
  left: -7.5px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--nuit);
  border-radius: 3px;
  background: currentColor;
  transform: rotate(45deg);
}

.gantt__jalon--depasse {
  border-left-color: var(--alerte-demo);
  color: var(--alerte-demo);
}

/* La fabrication continue après la période affichée */
.gantt__suite {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 2;
  color: #03131f;
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1;
  transform: translateY(-54%);
}

/* Jour repère : un trait vertical sur toute la hauteur du planning */
.gantt__aujourdhui {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--largeur-affaire) + (100% - var(--largeur-affaire)) * var(--position));
  z-index: 2;
  width: 2px;
  margin-left: -1px;
  background: var(--cyan-demo);
  box-shadow: 0 0 12px rgba(46, 230, 240, 0.7);
  pointer-events: none;
}

.gantt__aujourdhui span {
  position: absolute;
  bottom: 5px;
  left: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--cyan-demo);
  color: #03131f;
  font-size: 0.6875rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Légendes du planning et des marges */
.gantt-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  color: var(--doux);
  font-size: 0.8438rem;
  list-style: none;
}

.gantt-legende li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pastille {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.pastille--jalon {
  width: 11px;
  height: 11px;
  margin: 0 2px;
  border-radius: 2px;
  background: var(--clair);
  transform: rotate(45deg);
}

.pastille--retard,
.pastille--depassement {
  background: repeating-linear-gradient(135deg, #ff8f8f 0 3px, #d94f4f 3px 6px);
}

.pastille--retard {
  border: 1px dashed rgba(255, 128, 128, 0.85);
  background: repeating-linear-gradient(135deg, rgba(255, 128, 128, 0.45) 0 3px, rgba(255, 128, 128, 0.1) 3px 6px);
}

.pastille--repere {
  width: 3px;
  margin: 0 5px;
  border-radius: 2px;
  background: var(--cyan-demo);
}

.pastille--matiere {
  background: #5b7fc4;
}

.pastille--heures {
  background: #8b7bff;
}

.pastille--marge {
  background: #3ddc97;
}


/* 8. SUIVI DES MARGES ---------------------------------------------------------- */

.marges-synthese {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

@media (min-width: 1000px) {
  .marges-synthese {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.marges-synthese__chiffre {
  padding: 12px 16px;
  border: 1px solid var(--trait);
  border-radius: 14px;
  background: rgba(8, 18, 48, 0.7);
}

.marges-synthese dt {
  color: var(--doux);
  font-size: 0.8125rem;
  font-weight: 600;
}

.marges-synthese dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  margin: 0;
}

.marges-synthese dd strong {
  font-family: var(--police-titre);
  font-size: clamp(1.25rem, 1rem + 0.8vw, 1.625rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.marges-synthese dd span {
  color: var(--doux);
  font-size: 0.875rem;
}

.marges-synthese__chiffre.est-alerte strong {
  color: #ffb0b0;
}

.marges-synthese__chiffre.est-bon strong {
  color: #7af0bd;
}

.marges {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Une affaire : son nom, la barre de décomposition du prix de vente, le détail, puis le résultat */
.marge {
  display: grid;
  gap: 6px 24px;
  padding: 16px 0;
  border-top: 1px solid var(--trait);
}

.marge:last-child {
  padding-bottom: 0;
}

@media (min-width: 1000px) {
  .marge {
    grid-template-columns: minmax(0, 12rem) minmax(0, 1fr) minmax(0, 17rem);
    align-items: center;
  }

  .marge__titre,
  .marge__resultat {
    grid-row: 1 / span 2;
  }

  .marge__barre,
  .marge__detail {
    grid-column: 2;
  }

  .marge__resultat {
    grid-column: 3;
  }
}

.marge__titre {
  display: grid;
  line-height: 1.25;
}

.marge__titre span {
  color: var(--doux);
  font-size: 0.875rem;
}

.marge__barre {
  display: flex;
  height: 20px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(104, 152, 255, 0.2);
}

.marge__segment {
  height: 100%;
  box-shadow: inset -2px 0 0 var(--surface-pleine);
}

.marge__segment:last-child {
  box-shadow: none;
}

.marge__segment--matiere {
  background: #5b7fc4;
}

.marge__segment--heures {
  background: #8b7bff;
}

.marge__segment--depassement {
  background: repeating-linear-gradient(135deg, #ff8f8f 0 6px, #d94f4f 6px 12px);
}

.marge__segment--marge {
  background: #3ddc97;
}

.marge__detail {
  color: var(--doux);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.marge__resultat {
  display: grid;
  justify-items: start;
  gap: 4px;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.marge__prevue {
  color: var(--doux);
}


@media (prefers-reduced-motion: reduce) {
  .heure__realise,
  .heure__depassement,
  .gantt__tache,
  .quantite__bouton {
    transition: none;
  }

  .gantt__tache {
    transform: none;
  }
}
