/* ==========================================================================
   AZIMUT PARTNERS — Espace Démonstration : Gestion commerciale
   (assets/css/espace-gestion-commerciale.css)

   Styles propres au tableau de bord commercial et au chiffrage d'une demande. Le thème sombre
   et les panneaux viennent de espace-demonstration.css ; les indicateurs, les tableaux, les actions,
   l'accueil pastel, les pastilles, les constats et la quantité modifiable de espace-tableau-de-bord.css.

   Sommaire
     1. Rangées et éléments masqués
     2. Affaires commerciales (étapes)
     3. Stock de pièces et d'ensembles composés
     4. Blocs numérotés du chiffrage
     5. Bloc 1 : votre besoin (demande, exemples, pièces jointes, croquis)
     6. Bloc 2 : chiffrage (lignes modifiables, ajout)
     7. Bloc 3 : résultat et délai proposé
     8. Aperçu du document (feuille claire)

   Code des couleurs : vert = disponible ; ambre = à surveiller ; rouge = à recommander ou à fabriquer.
   La couleur n'est jamais seule à porter l'information : un texte l'accompagne toujours.
   ========================================================================== */


/* 1. RANGÉES ET ÉLÉMENTS MASQUÉS -------------------------------------------- */

/* Dans cette page, un élément portant l'attribut hidden est toujours masqué, quelle que soit la règle
   d'affichage de sa classe : c'est le seul « !important » de la feuille. */
[data-commerce] [hidden] {
  display: none !important;
}

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

@media (min-width: 1000px) {
  .rangee--stocks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

/* L'indicateur « Chiffrage en cours » affiche un montant : il est écrit un peu plus petit que les autres */
[data-chiffre="chiffrage"] .chiffre__valeur strong {
  font-size: clamp(1.5rem, 1.1rem + 1vw, 1.875rem);
}

/* Prochaines actions : pas de coupure de mots dans les textes */
[data-actions] .action > span:nth-child(2) {
  hyphens: manual;
}

/* Affaires et prochaines actions côte à côte sur grand écran */
@media (min-width: 1400px) {
  .rangee--commerce {
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
    align-items: start;
  }
}


/* 2. AFFAIRES COMMERCIALES --------------------------------------------------- */

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

.tableau--commerce th,
.tableau--chiffrage th {
  padding: 10px;
}

.tableau--commerce td.montant,
.tableau--chiffrage td.montant {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Étape d'une affaire : un segment allumé par étape franchie, puis le nom de l'étape */
.etape {
  display: grid;
  gap: 6px;
}

.etape__points {
  display: grid;
  grid-template-columns: repeat(4, 22px);
  gap: 4px;
}

.etape__points i {
  height: 5px;
  border-radius: 3px;
  background: rgba(104, 152, 255, 0.24);
}

.etape__points i.est-atteint {
  background: var(--cyan-demo);
}

/* En fiches (moins de 1000 px), les pastilles gardent leur largeur */
@media (max-width: 999px) {
  .tableau--fiches .etape {
    justify-items: start;
  }

  .tableau--fiches .ecart-stock,
  .tableau--fiches .origine {
    justify-self: start;
  }
}


/* 3. STOCK DE PIÈCES ET D'ENSEMBLES COMPOSÉS --------------------------------- */

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

/* Un article : son nom et son état ; dessous, le niveau du stock, les quantités, puis le détail */
.stock-ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
}

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

.stock-ligne .jauge,
.stock-ligne__chiffres,
.stock-ligne__detail {
  grid-column: 1 / -1;
}

.stock-ligne__chiffres {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.stock-ligne__detail {
  color: var(--doux);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.jauge__niveau--ambre {
  background: linear-gradient(90deg, #d98a1f, #ffc266);
}


/* 4. BLOCS NUMÉROTÉS DU CHIFFRAGE -------------------------------------------- */

.bloc {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding-top: 22px;
  border-top: 1px solid var(--trait);
}

.bloc__titre {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--police-titre);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.bloc__numero {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cyan-demo);
  color: #03131f;
  font-size: 1rem;
  font-weight: 800;
}


/* 5. BLOC 1 : VOTRE BESOIN ---------------------------------------------------- */

.besoin {
  display: grid;
  gap: 20px;
}

@media (min-width: 1000px) {
  .besoin {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
  }
}

.besoin__saisie {
  display: grid;
  gap: 8px;
}

.besoin__saisie label,
.exemples > span,
.jointes__titre {
  color: #c5d2f2;
  font-size: 0.875rem;
  font-weight: 600;
}

.besoin__saisie textarea {
  width: 100%;
  min-height: 168px;
  padding: 14px 16px;
  border: 1px solid var(--trait);
  border-radius: 14px;
  background: var(--surface-pleine);
  color: var(--clair);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.besoin__saisie textarea:hover {
  border-color: rgba(46, 230, 240, 0.6);
}

.besoin__compte {
  color: var(--doux);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.exemples {
  display: grid;
  gap: 8px;
}

.exemples__liste {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Demande d'exemple : une pastille de 44 px de haut ; celle qui est affichée est mise en évidence */
.exemple {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--trait);
  border-radius: 999px;
  background: rgba(104, 152, 255, 0.1);
  color: var(--clair);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.exemple:hover {
  border-color: var(--cyan-demo);
}

.exemple[aria-pressed="true"] {
  border-color: var(--cyan-demo);
  background: rgba(46, 230, 240, 0.16);
  color: #9ff6fb;
}

/* Pièces jointes : le croquis d'exemple, puis le bouton (simulé) pour en joindre d'autres */
.jointes {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px dashed rgba(104, 152, 255, 0.5);
  border-radius: 16px;
  background: rgba(8, 18, 48, 0.55);
}

.jointes__titre {
  display: flex;
  align-items: center;
  gap: 8px;
}

.croquis {
  display: grid;
  gap: 8px;
  margin: 0;
}

.croquis__dessin {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.croquis figcaption,
.jointes__vide {
  color: var(--doux);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.croquis figcaption strong {
  color: var(--clair);
  font-weight: 600;
}

.jointes .bouton-demo--sobre {
  justify-self: start;
  margin-top: 0;
}

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

/* Le libellé du bouton est long : il peut passer sur deux lignes sur un petit écran */
.besoin__action .bouton-demo {
  flex: 0 1 auto;
  min-width: 0;
  padding: 8px 20px;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
}

/* Interprétation en cours : le bouton patiente */
.bouton-demo.est-en-cours {
  cursor: progress;
  filter: saturate(0.6);
  opacity: 0.85;
}

/* Constat d'attente (ambre) : la demande a changé, ou rien n'a été reconnu */
.constat--attente {
  border-color: rgba(255, 182, 72, 0.6);
  background: rgba(255, 182, 72, 0.1);
}

.constat--attente > .icone {
  color: var(--ambre-demo);
}


/* 6. BLOC 2 : CHIFFRAGE -------------------------------------------------------- */

@media (min-width: 1000px) {
  .tableau--chiffrage {
    min-width: 840px;
  }
}

.tableau--chiffrage td {
  vertical-align: top;
}

.tableau--chiffrage td.montant {
  padding-top: 22px;
  white-space: nowrap;
}

.produit strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  white-space: normal;
}

/* Origine du produit : bibliothèque (pièce achetée) ou produit composé (fabriqué) */
.origine {
  display: inline-flex;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.origine--bibliotheque {
  background: rgba(104, 152, 255, 0.18);
  color: #c5d2f2;
}

.origine--compose {
  background: rgba(139, 123, 255, 0.22);
  color: #d7ceff;
}

/* Alerte de stock d'une ligne */
.ligne-chiffrage__alerte {
  max-width: 300px;
  margin-top: 6px;
  color: #ffb0b0;
  font-size: 0.8438rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
}

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

/* Saisie suivie de son unité (€, %) */
.saisie-unite {
  display: inline-grid;
  grid-template-columns: 92px auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--trait);
  border-radius: 12px;
  background: var(--surface-pleine);
}

.saisie-unite input {
  width: 100%;
  height: 44px;
  padding: 0 4px 0 10px;
  border: 0;
  background: none;
  color: var(--clair);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
}

.saisie-unite input::-webkit-outer-spin-button,
.saisie-unite input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.saisie-unite > span {
  padding: 0 12px 0 4px;
  color: var(--doux);
  font-weight: 600;
}

.demo .saisie-unite :focus-visible {
  outline-offset: -3px;
}

/* Retrait d'une ligne */
.retirer {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--doux);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.retirer:hover {
  border-color: rgba(255, 128, 128, 0.6);
  color: #ffb0b0;
}

/* Juste après l'interprétation, les lignes apparaissent l'une après l'autre */
.ligne-chiffrage.est-nouvelle {
  animation: ligne-entree 0.45s var(--courbe) both;
}

@keyframes ligne-entree {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.ajout {
  grid-template-columns: minmax(0, 1fr);
  max-width: 560px;
}

.ajout__ligne {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* La liste se réduit à la largeur disponible, même si un nom de produit est long */
.ajout__ligne select {
  flex: 1 1 240px;
  width: auto;
  min-width: 0;
  max-width: 100%;
}

.ajout__ligne .bouton-demo--sobre {
  margin-top: 0;
}

.bouton-demo:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

/* En fiches (moins de 1000 px) : le bouton de retrait se place en haut à droite de la fiche */
@media (max-width: 999px) {
  .tableau--chiffrage tr {
    position: relative;
  }

  .tableau--chiffrage td.produit {
    padding-right: 48px;
  }

  .tableau--chiffrage td.retrait {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0;
  }

  .tableau--chiffrage td.montant {
    padding-top: 0;
  }

  .tableau--chiffrage .quantite,
  .tableau--chiffrage .saisie-unite {
    justify-self: start;
  }

  .ligne-chiffrage__alerte {
    max-width: none;
  }
}

/* Téléphone : la quantité et le montant occupent toute la largeur ; prix et remise restent côte à côte */
@media (max-width: 519px) {
  .tableau--chiffrage td:nth-child(2),
  .tableau--chiffrage td.montant {
    grid-column: 1 / -1;
  }

  .saisie-unite {
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }
}


/* 7. BLOC 3 : RÉSULTAT ET DÉLAI PROPOSÉ ---------------------------------------- */

.resultat {
  display: grid;
  gap: 20px;
}

@media (min-width: 1000px) {
  .resultat {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
    align-items: start;
  }
}

.totaux,
.delai {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--trait);
  border-radius: 16px;
  background: rgba(8, 18, 48, 0.7);
}

.totaux {
  display: grid;
  gap: 10px;
}

.totaux__ligne {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-variant-numeric: tabular-nums;
}

.totaux dt {
  color: var(--doux);
}

.totaux dd {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}

.totaux__ligne--total {
  padding-top: 12px;
  border-top: 1px solid var(--trait);
}

.totaux__ligne--total dt {
  color: var(--clair);
  font-weight: 700;
}

.totaux__ligne--total dd {
  color: var(--cyan-demo);
  font-family: var(--police-titre);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.delai {
  display: grid;
  gap: 12px;
  scroll-margin-top: calc(var(--hauteur-bandeau) + 16px);
}

.delai__titre {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

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

.delai__etape {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--trait);
  line-height: 1.4;
}

.delai__etape strong {
  display: block;
  font-weight: 600;
}

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

.delai__valeur {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.delai__calcule {
  padding-top: 10px;
  border-top: 1px solid var(--trait);
  font-weight: 600;
}

/* Le délai raisonnable proposé : la conclusion du chiffrage */
.delai__propose {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 14px 18px;
  border: 1px solid rgba(61, 220, 151, 0.55);
  border-radius: 14px;
  background: rgba(61, 220, 151, 0.1);
  font-weight: 600;
}

.delai__propose strong {
  color: #7af0bd;
  font-family: var(--police-titre);
  font-size: clamp(1.375rem, 1.1rem + 0.9vw, 1.75rem);
  font-weight: 800;
}

.delai.est-vide .delai__propose {
  border-color: var(--trait);
  background: none;
  color: var(--doux);
  font-weight: 400;
}

.delai.est-vide .delai__calcule,
.delai.est-vide .delai__etapes {
  display: none;
}

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

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


/* 8. APERÇU DU DOCUMENT ---------------------------------------------------------- */
/* Une feuille claire, comme un document imprimé, posée sur le fond sombre */

.demo .feuille {
  display: grid;
  gap: 18px;
  max-width: 760px;
  padding: clamp(20px, 4vw, 36px);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  color: #14233d;
  line-height: 1.45;
}

.feuille__entete {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #14233d;
  color: #46557a;
  font-size: 0.875rem;
}

.feuille__titre {
  color: #0b2545;
  font-family: var(--police-titre);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.feuille__client {
  text-align: right;
}

.feuille__client strong {
  color: #0b2545;
  font-size: 1rem;
}

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

.feuille__ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid #dfe5ef;
}

.feuille__ligne strong {
  display: block;
  color: #0b2545;
  font-weight: 600;
}

.feuille__ligne span span {
  color: #46557a;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.feuille__montant {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.feuille__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  color: #0b2545;
  font-weight: 700;
}

.feuille__total strong {
  font-family: var(--police-titre);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.feuille__delai {
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef3fa;
}

.feuille__mention {
  color: #5d6b88;
  font-size: 0.8125rem;
}


@media (prefers-reduced-motion: reduce) {
  .ligne-chiffrage.est-nouvelle {
    animation: none;
  }

  .exemple,
  .retirer {
    transition: none;
  }
}
