/* ============================================================================
   SAISIE D'UNE PIÈCE D'ACHAT — commande, réception, facture fournisseur (.sda-*)
   Shared/DocumentEcranClassique.razor (fragment SaisieAchat), 2026-10-29.

   Le modèle est la pièce de vente (« Nouvelle commande client », ecran-devis.css) : en-tête
   collant aux gestes, colonne du document — fournisseur et conditions, objet, grille,
   notes — et colonne droite collante — contrôles avant validation, totaux. Les valeurs sont
   celles de la vente, mais la classe ne l'est pas : une feuille d'écran ne dépend pas d'une
   autre (« Contrôles avant validation » est le composant partagé DocumentControles, qui
   apporte la sienne). La grille de saisie garde ses champs ; seuls son en-tête et ses
   filets prennent l'ardoise du gabarit.

   AUCUNE COULEUR EN DUR : jetons --et-* seulement, le thème sombre suit.
   ============================================================================ */

.sda { color: var(--et-ink); min-width: 0; }
.sda-mono { font-family: var(--et-font-mono); }

/* ----- En-tête, collant : le numéro et le bouton d'engagement restent atteignables ----- */
.sda-tete {
    position: sticky; top: 0; z-index: 12;
    background: var(--et-surface); border-bottom: 1px solid var(--et-hairline);
    padding: 14px 24px 14px;
}
.sda-tete .mx-fil { margin-bottom: 6px; }
.sda-tete-rang { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.sda-tete-txt { flex: 1 1 320px; min-width: 0; }
.sda-tete-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.sda-numero { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--et-ink); }
.sda-filiation { font-size: 13px; color: var(--et-muted); }
.sda-filiation .bi { margin-right: 4px; }

.sda-corps { padding: 18px 24px 26px; }

/* ----- Deux colonnes : le document, puis ce qu'on lit avant de valider ----- */
.sda-grille-fiche { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.sda-colonne { min-width: 0; }
.sda-laterale { position: sticky; top: 104px; display: flex; flex-direction: column; gap: 12px; }

.sda-bloc { background: var(--et-surface); border: 1px solid var(--et-hairline); margin-bottom: 16px; min-width: 0; }
.sda-laterale .sda-bloc, .sda-laterale .dev-bloc { margin-bottom: 0; }
.sda-bloc-tete {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 16px; border-bottom: 1px solid var(--et-hairline);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--et-muted);
}

/* ----- Le fournisseur ----- */
.sda-resume { display: flex; align-items: flex-start; gap: 18px; padding: 14px 16px; flex-wrap: wrap; }
.sda-tiers { display: flex; align-items: flex-start; gap: 12px; flex: 1 1 420px; min-width: 280px; }
.sda-initiales {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--et-blue); color: var(--et-sur-marine); font-size: 14px; font-weight: 700;
}
.sda-tiers-corps { flex: 1 1 auto; min-width: 0; }
.sda-tiers-corps > .cbr { width: 100%; }
.sda-faits { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 10px; }
.sda-fait { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; }
.sda-fait .mx-input, .sda-fait .mx-select { width: 170px; }
.sda-fait-lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .11em; color: var(--et-faint); }
.sda-fait-val { font-size: 13px; color: var(--et-ink); }

/* ----- Les conditions, à droite du fournisseur ----- */
.sda-conditions {
    flex: 0 1 280px; min-width: 240px; display: flex; flex-direction: column; gap: 6px;
    padding-left: 16px; border-left: 1px solid var(--et-rang);
}
.sda-cond { display: grid; grid-template-columns: minmax(0, 1fr) 130px; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--et-muted); }
.sda-cond .mx-input, .sda-cond .mx-select { width: 100%; }
.sda-avert { font-size: 12px; color: var(--et-avertissement-ink); }

.sda-objet { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--et-rang); }
.sda-objet input { flex: 1 1 320px; min-width: 200px; }

/* ----- La grille ----- */
.sda-grille-barre { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--et-hairline); }
.sda-grille-titre { font-size: 13px; font-weight: 600; }
.sda-compte { font-size: 12px; color: var(--et-muted); }
.sda-ajout { padding: 10px 16px; border-bottom: 1px solid var(--et-hairline); background: var(--et-surface-2); }
/* L'ajout d'un article (2026-10-30) : le champ prend la place, les trois gestes à sa suite ; les
   suggestions s'ouvrent dessous, la rangée survolée au fond teinté — comme la grille de vente. */
.sda-ajout-rang { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sda-champ-article {
    flex: 1 1 320px; min-width: 220px; display: flex; align-items: center; gap: 8px;
    height: var(--et-h-champ); padding: 0 10px;
    background: var(--et-surface); border: 1px solid var(--et-bord-champ);
}
.sda-champ-article:focus-within { border-color: var(--et-form-blue); box-shadow: 0 0 0 1px var(--et-form-blue); }
.sda-champ-article > .bi { color: var(--et-muted); }
.sda-champ-article > input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--et-ink); font: inherit; font-size: 13px; }
.sda-suggestions {
    margin-top: 6px; max-height: 280px; overflow-y: auto;
    background: var(--et-surface); border: 1px solid var(--et-hairline); box-shadow: var(--et-ombre-flottant);
}
.sda-sugg-tete { padding: 6px 12px; font-size: 12px; color: var(--et-muted); border-bottom: 1px solid var(--et-hairline); }
.sda-suggestion {
    display: grid; grid-template-columns: 120px minmax(0, 1fr) auto 110px; align-items: center; gap: 12px;
    width: 100%; padding: var(--et-menu-item-py) 12px; border: 0; border-bottom: 1px solid var(--et-rang);
    background: transparent; color: var(--et-ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.sda-suggestion:last-child { border-bottom: 0; }
.sda-suggestion.est-survolee { background: var(--et-tint); }
.sda-sugg-code { font-family: var(--et-font-mono); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sda-sugg-lib { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sda-sugg-stock { font-size: 12px; color: var(--et-muted); white-space: nowrap; }
.sda-sugg-prix { font-family: var(--et-font-mono); text-align: right; white-space: nowrap; }
.sda-grille > thead > tr > th {
    padding: var(--et-cellule-tete-y) 12px; white-space: nowrap; border: 0;
    background: var(--et-table-head); color: var(--et-sur-ardoise-plein); font-size: 12px; font-weight: 600;
}
.sda-grille > tbody > tr > td { padding: var(--et-cellule-y) 6px; border-bottom: 1px solid var(--et-hairline); color: var(--et-ink); }
/* Les montants se lisent en entier dans leur case : 24 000, et non « 2400( ». */
.sda-grille > tbody > tr > td input[type=number] { padding-left: 6px; padding-right: 6px; -moz-appearance: textfield; appearance: textfield; }
.sda-grille > tbody > tr > td input[type=number]::-webkit-inner-spin-button,
.sda-grille > tbody > tr > td input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ----- Notes ----- */
.sda-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 12px 16px 14px; }
.sda-notes label { display: flex; flex-direction: column; gap: 6px; margin: 0; }

/* ----- Totaux ----- */
.sda-totaux { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; margin: 0; padding: 12px 16px 8px; font-size: 13px; }
.sda-totaux dt { color: var(--et-muted); font-weight: 400; }
.sda-totaux dd { margin: 0; text-align: right; font-family: var(--et-font-mono); color: var(--et-ink); }
.sda-totaux .est-fort { color: var(--et-ink); font-weight: 600; }
.sda-ttc {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    margin: 0 16px; padding: 12px 0 14px; border-top: 2px solid var(--et-ink);
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
}
.sda-ttc strong { font-family: var(--et-font-mono); font-size: 24px; letter-spacing: 0; }

/* ----- Largeurs : la colonne droite passe sous le document sous 1100 px ----- */
@media (max-width: 1100px) {
    .sda-grille-fiche { grid-template-columns: minmax(0, 1fr); }
    .sda-laterale { position: static; }
}
@media (max-width: 1024px) {
    .sda-champ-article { height: 44px; }
    .sda-suggestion { min-height: 44px; }
    .sda-tete { position: static; }
    .sda-tete .mx-btn, .sda-origine { min-height: 44px; }
}
@media (max-width: 720px) {
    .sda-tete { padding: 12px 14px; }
    .sda-corps { padding: 14px 14px 22px; }
    .sda-conditions { padding-left: 0; border-left: 0; flex-basis: 100%; }
    .sda-notes { grid-template-columns: minmax(0, 1fr); }
    .sda-fait, .sda-fait .mx-input, .sda-fait .mx-select { width: 100%; }
    .sda-numero { font-size: 20px; }
    .sda-suggestion { grid-template-columns: minmax(0, 1fr) auto; }
    .sda-sugg-lib, .sda-sugg-stock { display: none; }
}

/* ----- D'où naît la commande (2026-11-04) : les cinq origines d'une commande neuve ----- */
.sda-origines {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--et-outils-gap);
    margin-top: 10px;
}
.sda-origines-lbl { font-size: 13px; color: var(--et-muted); margin-right: 4px; }
.sda-origine {
    display: inline-flex; align-items: center; gap: var(--et-btn-ico-gap);
    min-height: var(--et-outil-h); padding: 0 var(--et-btn-px);
    border: 1px solid var(--et-bord-champ); background: var(--et-surface); color: var(--et-ink);
    font-size: 13px; cursor: pointer;
}
.sda-origine:hover:not(:disabled) { border-color: var(--et-form-blue); color: var(--et-lien); }
.sda-origine.est-actif {
    border-color: var(--et-form-blue); background: var(--et-form-blue); color: var(--et-sur-aplat);
}
.sda-origine:disabled { cursor: default; opacity: 1; color: var(--et-faint); }
.sda-origine-choix {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--et-outils-gap) 10px;
    margin-top: 8px;
}
.sda-origine-choix > label { margin: 0; font-size: 13px; color: var(--et-ink); }
.sda-origine-champ { flex: 0 1 360px; min-width: 220px; }
.sda-origine-champ > .cbr { width: 100%; }

/* ----- Une ligne en colis (2026-11-06) : le nombre de colis sous la désignation ----- */
.sda-colis, .md-card .sda-colis {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--et-coche-gap);
    margin-top: 2px; font-size: 13px; color: var(--et-muted);
}
.sda-colis input { width: 84px; flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   LES LOTS D'UNE RÉCEPTION (2026-11-26) — composant Shared/Achat/LotsReceptionAchat :
   le résumé du panneau latéral et la grille de la fenêtre de saisie.
   --------------------------------------------------------------------------- */
/* LA FENÊTRE DES LOTS VIT DANS LA COLONNE COLLANTE : position: sticky crée un contexte
   d'empilement, et le voile (z-index 2100) y restait sous l'en-tête de la page. Tant
   qu'une fenêtre est ouverte, la colonne reprend le flux — le voile couvre tout de toute façon. */
.sda-laterale:has(.mx-voile) { position: static; }
.lra-pastille { margin-left: auto; text-transform: none; letter-spacing: 0; }
.lra-corps { padding: var(--et-carte-corps-py) 16px; }
.lra-resume { list-style: none; margin: 0 0 var(--et-actions-mt); padding: 0; font-size: 13px; }
.lra-resume li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 2px 0; }
.lra-ouvrir { width: 100%; justify-content: center; }
.lra-compte { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--et-danger-ink); }
.lra-compte.est-couvert { color: var(--et-succes-ink); }
.lra-numeros { flex-basis: 100%; color: var(--et-faint); font-size: var(--et-fs-cell, 13px); }
.lra-ligne-tete { display: flex; flex-wrap: wrap; align-items: center; gap: var(--et-outils-gap); margin-bottom: 6px; }
.lra-grille td { vertical-align: middle; }
/* Cinq champs par lot : sous cette largeur le numéro se réduisait à un caractère. La grille
   garde sa largeur utile et défile dans son cadre, la fenêtre jamais. */
.lra-grille { min-width: 820px; }
.lra-grille th:first-child { min-width: 160px; }
.lra-ajouter { margin: var(--et-actions-mt) 0 var(--et-sect-ecart); }
