/* ==========================================================================
   Recette V6 — formulaire du document de vente (envois, bon de commande
   compact, classement des lignes, barre d'actions) et fiche client
   (code postal → villes, commentaires).
   ========================================================================== */

/* ---------- F5 : bon de commande compact ----------
   Mode de règlement, code ILN et compte client retirés, les champs se rangent
   en grille serrée : deux rangées au lieu de quatre (plus le séparateur) sur un
   écran 1920 × 1080 comme 1440 × 900. Les lignes d'articles, l'essentiel du
   document, gagnent autant de place. */
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.4rem, 1fr));
    gap: .3rem .5rem;
    margin: 0;
    align-items: start;
}
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > * {
    width: auto; max-width: none; min-width: 0; margin-top: 0; padding: 0;
}
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-champ-large { grid-column: span 2; }
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-rangee { grid-column: 1 / -1; }
/* Le séparateur « Commande & livraison » coûtait une ligne à lui seul. */
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-sep { display: none; }
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .form-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Cellules étroites : la valeur choisie tient sur une ligne (« Bon de commande »
   passait sur deux et rehaussait toute la rangée). */
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .ts-control { flex-wrap: nowrap; padding-right: 1.7rem !important; }
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .ts-control > .item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Les valeurs longues — type « Bon de commande », client « DECATHLON
   VILLEFRANCHE SUR SAONE », « VIREMENT 60 JOURS » — ne se relisaient plus
   qu'en ouvrant la liste. Leurs cellules s'élargissent dès que la grille a la
   place de le faire SANS ajouter de rangée (seuils = nombre de colonnes de la
   grille : 9 colonnes de 7,4rem à partir de 70,6rem, 10 à partir de 78,5rem).
   En deçà, et partout, la valeur complète reste en info-bulle
   (document_form_controller#infobulles). */
.doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body { container-type: inline-size; }
@container (min-width: 70.6rem) {
    .doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-champ-type { grid-column: span 2; }
    .doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-champ-client { grid-column: span 3; }
}
@container (min-width: 78.5rem) {
    .doc-form[data-doc-type="BON_COMMANDE"] .doc-bandeau .card-body > .row > .doc-champ-conditions { grid-column: span 2; }
}

/* ---------- F1 : envois « nombre × type » ---------- */
.envois-entete { display: flex; align-items: baseline; justify-content: space-between; gap: .4rem; min-width: 0; }
.envois-entete .form-label { display: block; margin-bottom: .1rem; }
.envois-liste { display: flex; flex-direction: column; gap: .2rem; }
.envoi-ligne {
    display: grid; grid-template-columns: 3.4rem auto minmax(0, 1fr) 1.7rem; align-items: center; gap: .3rem;
}
.envoi-ligne .envoi-qte { text-align: right; padding-right: .3rem; }
.envoi-ligne .envoi-type { min-width: 0; }
.envoi-fois { font-weight: 700; color: var(--v1); font-size: .9rem; }
.envoi-retirer {
    display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem;
    border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-faint);
    transition: color .15s, border-color .15s, background .15s;
}
.envoi-retirer:hover { color: #e11d48; border-color: rgba(225,29,72,.35); background: rgba(225,29,72,.06); }
.envois-ajouter {
    flex-shrink: 0; padding: 0 .5rem; border-radius: 999px; font-size: .68rem; font-weight: 600; line-height: 1.4;
    color: var(--v1); background: var(--grad-soft); border: 1px dashed rgba(124,92,255,.45);
}
.envois-ajouter:hover { border-style: solid; box-shadow: var(--ring); }
.envois .invalid-feedback { display: block; }
.doc-bandeau .envoi-ligne .form-control, .doc-bandeau .envoi-ligne .form-select { padding-top: .2rem; padding-bottom: .2rem; }

/* ---------- F9 / recette V7 : rappel « fiche incomplète pour la facturation
   électronique ». Plus un blocage : un simple rappel, discret. ---------- */
.bc-exigences {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    margin: .15rem 0; padding: .3rem .7rem; border-radius: var(--r-md);
    background: rgba(124,92,255,.05);
    border: 1px dashed rgba(124,92,255,.28);
    color: var(--ink-soft); font-size: .8rem;
}
.bc-exigences__icone { font-size: 1rem; color: var(--ink-soft); }
.bc-exigences__corps { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; flex: 1; min-width: 14rem; }
.bc-exigences__liste { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.bc-exigences__note { font-style: italic; opacity: .8; }
.bc-pill { padding: .04rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; color: var(--ink-soft); background: rgba(124,92,255,.1); }
.bc-exigences__lien { font-size: .78rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.bc-exigences__lien:hover { text-decoration: underline; }

/* ---------- F7 : classement des lignes ----------
   Une colonne de poignée en tête, et « insérer / supprimer » en fin de ligne. */
.lignes-tableau {
    --lignes-cols:
        2.6rem                /* poignée, monter / descendre */
        minmax(8rem, 14rem)   /* article      */
        minmax(9rem, 1fr)     /* désignation  */
        minmax(3.6rem, 4.6rem)
        minmax(4.6rem, 6.4rem)
        minmax(4rem, 5.4rem)
        minmax(4rem, 5.2rem)
        minmax(4.4rem, 6.2rem)
        4.4rem;               /* insérer, supprimer */
}
@media (max-width: 767.98px) {
    .lignes-tableau { --lignes-cols: repeat(auto-fit, minmax(6.5rem, 1fr)); }
}
.lignes-tableau .lg-ordre { display: flex; align-items: center; gap: .1rem; }
.lg-poignee {
    display: inline-flex; align-items: center; justify-content: center; width: 1.1rem; height: 1.9rem;
    color: var(--ink-faint); cursor: grab; border-radius: 6px;
}
.lg-poignee:hover { color: var(--v1); background: var(--grad-soft); }
.lg-poignee:active { cursor: grabbing; }
.lg-fleches { display: flex; flex-direction: column; }
.lg-fleche {
    display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; height: .95rem; padding: 0;
    border: 0; background: transparent; color: var(--ink-faint); font-size: .72rem; line-height: 1; border-radius: 5px;
}
.lg-fleche:hover, .lg-fleche:focus-visible { color: var(--v1); background: var(--grad-soft); outline: none; }
.lignes-tableau .lg-cell.lg-actions { gap: .25rem; }
.lignes-tableau .lg-inserer { --bs-btn-padding-x: .4rem; --bs-btn-padding-y: .05rem; line-height: 1.15; border-radius: 8px; }

.ligne-row { transition: box-shadow .15s ease, opacity .15s ease; }
.ligne-row.is-glissee { opacity: .45; }
.ligne-row.is-depot-avant { box-shadow: inset 0 3px 0 var(--v1); }
.ligne-row.is-depot-apres { box-shadow: inset 0 -3px 0 var(--v1); }
.ligne-row.is-deplacee { animation: ligneDeplacee .6s ease; }
@keyframes ligneDeplacee {
    from { background: rgba(124,92,255,.16); }
    to { background: #fafaff; }
}
@media (max-width: 767.98px) {
    .lignes-tableau .lg-ordre { grid-column: 1 / -1; justify-content: flex-start; }
    .lg-fleches { flex-direction: row; gap: .3rem; }
    .lg-fleche { width: 1.9rem; height: 1.6rem; font-size: .9rem; }
}

/* ---------- F6 : barre d'actions du document enregistré ---------- */
.doc-actions { flex-wrap: wrap; }
.doc-actions-alerte {
    margin-right: auto; padding: .2rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
    color: #b45309; background: rgba(245,158,11,.14);
}
.doc-actions-alerte a { color: inherit; }

/* ---------- F10 : code postal → villes ---------- */
.cp-villes-hote { position: relative; }
.cp-villes {
    position: absolute; z-index: 30; top: 100%; left: 0; right: 0; min-width: 13rem; margin-top: .2rem;
    max-height: 15rem; overflow-y: auto; padding: .3rem;
    background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
    border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-md);
}
.cp-villes__titre { padding: .15rem .5rem .3rem; font-size: .64rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.cp-villes__option {
    display: block; width: 100%; padding: .32rem .55rem; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink); font-size: .84rem; font-weight: 500; text-align: left;
}
.cp-villes__option:hover, .cp-villes__option.is-active { background: var(--grad-soft); color: var(--v1); }
.cp-villes__option.is-choisie { font-weight: 700; }

/* ---------- F11 : commentaires de la fiche client ---------- */
.client-commentaires {
    display: flex; align-items: flex-start; gap: .9rem; padding: .9rem 1.1rem;
    border-radius: var(--r-lg);
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        var(--grad) border-box;
    border: 2px solid transparent;
    box-shadow: var(--sh-md);
}
.client-commentaires__icone {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 2.4rem; height: 2.4rem; border-radius: 50%; color: #fff; background: var(--grad); box-shadow: var(--sh-glow); font-size: 1.1rem;
}
.client-commentaires__corps { flex: 1; min-width: 0; }
.client-commentaires__titre { font-family: var(--font-display); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--v1); }
.client-commentaires__texte { color: var(--ink); font-size: .95rem; white-space: normal; overflow-wrap: anywhere; }
.client-commentaires__modifier { color: var(--ink-faint); border-radius: 50%; }
.client-commentaires__modifier:hover { color: var(--v1); background: var(--grad-soft); }
.client-commentaires--vide {
    align-items: center; gap: .55rem; padding: .5rem .9rem; box-shadow: none; font-size: .86rem; color: var(--ink-faint);
    background: rgba(255,255,255,.6); border: 1px dashed var(--line);
}
.client-commentaires--vide a { font-weight: 600; color: var(--v1); }
.client-commentaires-saisie .card-header { display: flex; align-items: center; gap: .45rem; color: var(--v1); }
.client-commentaires-saisie textarea { background: linear-gradient(135deg, rgba(124,92,255,.04), rgba(34,211,238,.04)); }
