/* ════════════════════════════════════════════════════════
   DTISoft — Fiche Transfert Stock (TransferDetail)
   Préfixe tr- pour éviter collisions namespace.
   ════════════════════════════════════════════════════════ */

.tr-overlay {
    position: fixed; inset: 0; z-index: 9500;
    background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
    display: flex; align-items: stretch; justify-content: stretch;
}
.tr-panel {
    flex: 1; background: #fff;
    display: flex; flex-direction: column; overflow: hidden;
    margin: 16px;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
}

.tr-header {
    display: flex; align-items: center; padding: 10px 16px;
    background: #1e3a8a; color: #fff;
    border-radius: 8px 8px 0 0;
}
.tr-title { flex: 1; font-weight: 700; font-size: 15px; }
.tr-title i { margin-right: 8px; }
.tr-preview-btn, .tr-print-btn, .tr-email-btn, .tr-etiq-btn {
    background: rgba(255,255,255,.15); color: #fff; border: 0;
    width: 30px; height: 30px; border-radius: 4px; cursor: pointer; font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
}
.tr-preview-btn:hover, .tr-print-btn:hover, .tr-email-btn:hover, .tr-etiq-btn:hover:not(:disabled) { background: rgba(255,255,255,.28); }
/* Étiquettes (2026-10-01) : désactivé tant que le transfert n'est pas enregistré (info-bulle). */
.tr-etiq-btn { margin-left: 4px; }
.tr-etiq-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Mode minimisé : ne garder que titre + minimiser + fermer ─────────────
   Le header lui-même est gardé visible par la règle globale de style.css
   (.dti-minimized > *:not(.tr-header)…). Ici on masque juste les boutons
   d'action et le groupe B/I/U, et on compacte le titre. */
.dti-minimized .tr-preview-btn,
.dti-minimized .tr-print-btn,
.dti-minimized .tr-email-btn,
.dti-minimized .tr-etiq-btn,
.dti-minimized .tr-save-btn,
.dti-minimized .tr-fmt-grp { display: none !important; }
.dti-minimized .tr-header { padding: 6px 10px !important; }
.dti-minimized .tr-title {
    font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Mini-toolbar B / I / U (mise en forme de la ligne — DocItems.Style) ──── */
.tr-fmt-grp { display: inline-flex; gap: 2px; margin: 0 6px; }
.tr-fmt-btn {
    width: 28px; height: 30px; padding: 0; font-size: 13px; line-height: 1;
    background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.28);
    border-radius: 4px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.tr-fmt-btn:hover:not(:disabled) { background: rgba(255,255,255,.3); }
.tr-fmt-btn.tr-fmt-on { background: #fff; color: #1e3a8a; border-color: #fff; }
.tr-fmt-btn:disabled { opacity: .4; cursor: default; }

/* Effet visuel du masque Style appliqué à la ligne */
.tr-item-row.tr-fmt-b td, .tr-item-row.tr-fmt-b .tr-cell-inp { font-weight: 700; }
.tr-item-row.tr-fmt-i td, .tr-item-row.tr-fmt-i .tr-cell-inp { font-style: italic; }
.tr-item-row.tr-fmt-u td, .tr-item-row.tr-fmt-u .tr-cell-inp { text-decoration: underline; }
/* Le Libellé marker devient un input : garder l'aspect « provenance » discret. */
.tr-marker-libinp { color: #64748b; font-size: 12px; background: transparent; }
.tr-save-btn {
    background: #2563eb; color: #fff; border: 0;
    padding: 6px 14px; border-radius: 4px; font-size: 13px; font-weight: 600;
    cursor: pointer; margin-right: 8px;
}
.tr-save-btn:hover:not(:disabled) { background: #1d4ed8; }
.tr-save-btn:disabled, .tr-save-btn-saved { background: #64748b; cursor: default; }
.tr-min-btn, .tr-close-btn {
    background: rgba(255,255,255,.15); color: #fff; border: 0;
    width: 32px; height: 28px; border-radius: 4px; cursor: pointer;
    margin-left: 4px; font-size: 13px;
}
.tr-min-btn:hover, .tr-close-btn:hover { background: rgba(255,255,255,.3); }

/* Header form */
.tr-head-form {
    padding: 12px 16px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}
.tr-fld { display: flex; flex-direction: column; }
.tr-fld label {
    font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .3px;
    margin-bottom: 2px;
}
.tr-fld input, .tr-fld select {
    padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 4px;
    font-size: 13px; background: #fff;
}
.tr-fld input[readonly] { background: #f1f5f9; color: #475569; }
.tr-fld-wide { grid-column: span 2; }

/* Barre de navigation dans la chaîne doc-suite (comme journaux clients) */
.tr-chain-bar {
    display: flex; gap: 4px; align-items: center; justify-content: flex-end;
    padding: 4px 16px 0;
}
.tr-chain-bar:empty { display: none; }
.tr-chain-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; font-size: 12px; line-height: 1.4;
    background: #fff; color: #374151;
    border: 1px solid #cbd5e1; border-radius: 3px;
    cursor: pointer; white-space: nowrap;
}
.tr-chain-btn:hover { background: #f8fafc; border-color: #94a3b8; color: #111827; }
.tr-chain-btn:active { background: #f1f5f9; }
.tr-chain-btn[hidden] { display: none; }
.tr-chain-btn i { font-size: 11px; color: #64748b; }
.tr-chain-btn:hover i { color: #374151; }
.tr-chain-lbl { font-weight: 500; }

/* Grid */
.tr-grid-wrap {
    flex: 1; overflow: auto;
    padding: 0 16px;
    min-height: 0;
}
.tr-grid {
    width: 100%; border-collapse: collapse;
    font-size: 12.5px;
    margin-top: 12px;
}
.tr-grid th, .tr-grid td {
    padding: 4px 6px; border: 1px solid #e5e7eb; text-align: left;
    vertical-align: middle;
}
.tr-grid th {
    background: #f1f5f9; color: #475569; font-weight: 600; font-size: 11px;
    position: sticky; top: 0; z-index: 1;
}
.tr-th-num { width: 36px; text-align: center; }
.tr-th-ref { width: 130px; }
.tr-th-stk { width: 90px; }
.tr-th-cas { width: 100px; }
.tr-th-lot { width: 90px; }
.tr-th-qu  { width: 70px;  text-align: right; }
.tr-th-pu  { width: 80px;  text-align: right; }
.tr-th-tot { width: 80px;  text-align: right; }
.tr-th-rem { width: 140px; }
.tr-th-x   { width: 26px; }

/* ── Colonnes déplaçables / redimensionnables (js/grid-cols.js) ─────────
   Mêmes repères que la fiche document : poignée à droite de l'en-tête, curseur
   « grab », trait d'insertion bleu du côté où la colonne va atterrir. */
.gc-col-resize {
    position: absolute; top: 0; right: -2px; width: 5px; height: 100%;
    cursor: col-resize; z-index: 2;
}
.gc-col-resize:hover { background: var(--primary); opacity: .3; }
.tr-grid thead th.tr-th-draggable        { cursor: grab; }
.tr-grid thead th.tr-th-draggable:active { cursor: grabbing; }
.tr-grid thead th.tr-th-dragging         { opacity: .45; }
.tr-grid thead th.tr-th-drop             { box-shadow: inset 3px 0 0 0 #2563eb; }
/* ⚠️ Une largeur imposée à la souris ne doit pas être débordée par un libellé
   long : sans cela, la colonne « repousse » et le geste semble sans effet. */
.tr-grid thead th { overflow: hidden; text-overflow: ellipsis; }

.tr-td-num { text-align: center; color: #64748b; font-variant-numeric: tabular-nums; cursor: pointer; user-select: none; }
.tr-td-num:hover { background: #e2e8f0; }
.tr-new-row .tr-td-num { cursor: default; }
.tr-new-row .tr-td-num:hover { background: transparent; }
.tr-row-sel td { background: rgba(59, 130, 246, .12) !important; }
.tr-cell-tot { text-align: right; font-variant-numeric: tabular-nums; padding-right: 8px; color: #1e3a8a; }
.tr-cell-inp {
    width: 100%; box-sizing: border-box;
    border: 0; background: transparent;
    padding: 3px 4px; font-size: 12.5px; font-family: inherit;
    outline: none;
}
.tr-cell-inp:focus { background: #eff6ff; outline: 1px solid #2563eb; }
.tr-cell-inp.tr-cell-qu, .tr-cell-inp.tr-cell-pu { text-align: right; font-variant-numeric: tabular-nums; }
.tr-cell-na { color: #cbd5e1; padding-left: 6px; }
.tr-cell-ref { font-weight: 600; }

/* Case Référence avec flèche → sélecteur d'article (comme journaux clients/stock) */
.tr-ref-wrap { position: relative; width: 100%; display: flex; align-items: center; }
.tr-ref-wrap .tr-cell-ref { flex: 1; min-width: 0; }
.tr-ref-arrow {
    border: none; background: none; cursor: pointer; color: #94a3b8;
    font-size: 10px; padding: 0 3px; flex-shrink: 0;
}
.tr-ref-arrow:hover { color: var(--primary, #2563eb); }

.tr-item-row:hover { background: #f8fafc; }
.tr-new-row { background: #fafafa; opacity: .8; }

/* Marqueur de provenance (transfert consolidé) : rendu comme dans les journaux
   clients — une ligne normale, réf vide, provenance dans la colonne Libellé. Pas
   de bandeau : seul le texte est légèrement grisé pour se lire comme une méta-ligne. */
.tr-marker-lib { color: #64748b; font-size: 12px; }
.tr-new-row .tr-cell-inp { font-style: italic; color: #94a3b8; }
.tr-new-row .tr-cell-inp:focus { font-style: normal; color: #111827; }

.tr-row-del {
    background: transparent; border: 0; cursor: pointer;
    color: #cbd5e1; font-size: 12px; padding: 2px 4px;
}
.tr-row-del:hover { color: #dc2626; }

/* ── Menu contextuel (copier / coller / supprimer) — clic droit sur # ── */
.tr-ctx-menu {
    position: fixed; z-index: 12000;
    background: #fff; border: 1px solid #cbd5e1; border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    padding: 4px 0; min-width: 180px;
}
.tr-ctx-menu button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: transparent; border: 0; padding: 8px 14px; text-align: left;
    cursor: pointer; font-size: 12px; color: #374151;
}
.tr-ctx-menu button:hover:not(:disabled) { background: #f1f5f9; }
.tr-ctx-menu button:disabled { color: #9ca3af; cursor: not-allowed; }
.tr-ctx-menu .tr-ctx-danger { color: #dc2626; }
.tr-ctx-menu .tr-ctx-danger:hover:not(:disabled) { background: #fee2e2; }

/* Footer */
.tr-footer {
    padding: 8px 16px; border-top: 1px solid #e5e7eb;
    display: flex; justify-content: space-between; align-items: center;
    background: #f8fafc;
    font-size: 12px;
}
.tr-totals { display: flex; gap: 24px; }
.tr-totals b { color: #1e3a8a; }
.tr-audit { color: #94a3b8; font-size: 11px; font-style: italic; }

/* Notes */
.tr-notes-wrap {
    padding: 8px 16px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}
.tr-notes-wrap label {
    display: block; font-size: 11px; color: #64748b;
    text-transform: uppercase; letter-spacing: .3px; margin-bottom: 4px;
}
.tr-notes-wrap textarea {
    width: 100%; padding: 6px 10px; border: 1px solid #cbd5e1;
    border-radius: 4px; font-family: inherit; font-size: 13px;
    box-sizing: border-box; resize: vertical;
}

/* Responsive ajustement form */
@media (max-width: 900px) {
    .tr-head-form { grid-template-columns: repeat(2, 1fr); }
    .tr-fld-wide { grid-column: span 2; }
}
