/* ═══════════════════════════════════════════════════════════
   DTISoft — Module Magasinage
   ═══════════════════════════════════════════════════════════ */
.mg-wrap { padding: 0; }

.mg-toolbar {
    display: flex; align-items: center; gap: 16px;
    padding: 8px 12px; border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.mg-tabs { display: flex; gap: 4px; }
.mg-tab {
    background: transparent; border: 0; padding: 8px 14px;
    cursor: pointer; font-size: 13px; color: var(--gray-700);
    border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 8px;
}
.mg-tab:hover { background: var(--gray-100); }
.mg-tab-active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.mg-tab-badge {
    background: #e5e7eb; color: var(--gray-700); border-radius: 10px;
    padding: 1px 8px; font-size: 11px; font-weight: 700; min-width: 18px; text-align: center;
}
.mg-tab-badge:empty { display: none; }
.mg-tab-badge-hot { background: #dc2626; color: white; }

.mg-toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.mg-cov-label { font-size: 12px; color: var(--gray-700); display: inline-flex; align-items: center; gap: 6px; }
.mg-cov-label input { padding: 2px 6px; border: 1px solid var(--gray-300); border-radius: 4px; }

.mg-btn {
    background: #2563eb; color: white; border: 0; padding: 6px 12px;
    border-radius: 4px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.mg-btn:hover { background: #1d4ed8; }
.mg-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.mg-btn-refresh { background: var(--gray-600); }
.mg-btn-refresh:hover { background: var(--gray-700); }

/* Le .module-wrap partagé (articles.css) est height:100% + overflow:hidden
   (pensé pour les listes virtualisées à scroller interne). Le contenu
   magasinage n'en a pas → .mg-content DOIT être le scroller, sinon les
   longues listes (ex. Vider un casier GEN/BOSCH1) sont coupées sans
   scrollbar et le bouton d'exécution du bas est inatteignable. */
.mg-content { padding: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.mg-loading, .mg-error, .mg-empty {
    text-align: center; padding: 40px 20px; color: var(--gray-600); font-size: 14px;
}
.mg-error { color: #dc2626; }
.mg-empty-icon { font-size: 48px; color: #10b981; margin-bottom: 12px; }
.mg-empty-sub { font-size: 12px; color: var(--gray-500); margin-top: 8px; }

.mg-summary {
    padding: 8px 12px; margin-bottom: 8px; background: #fef3c7; color: #92400e;
    border-radius: 4px; font-size: 13px;
}

.mg-grid {
    width: 100%; border-collapse: collapse; font-size: 12px; background: white;
}
.mg-grid th, .mg-grid td {
    padding: 6px 8px; border-bottom: 1px solid var(--gray-200); text-align: left; vertical-align: top;
}
.mg-grid th { background: var(--gray-100); font-weight: 600; color: var(--gray-700); font-size: 11px; position: sticky; top: 0; }
.mg-grid .mg-r { text-align: right; }
.mg-grid .mg-c { text-align: center; }
.mg-grid tbody tr:hover { background: #f9fafb; }

.mg-row.mg-urgence-hot  .mg-urgence-icon { color: #dc2626; }
.mg-row.mg-urgence-warm .mg-urgence-icon { color: #f59e0b; }
.mg-row.mg-urgence-mild .mg-urgence-icon { color: #10b981; }
.mg-row.mg-urgence-hot  { background: #fef2f2; }
.mg-row.mg-urgence-hot:hover { background: #fee2e2; }
.mg-urgence-icon { font-size: 14px; }
.mg-sub { color: var(--gray-500); font-size: 10px; }
.mg-srcs { font-family: monospace; font-size: 11px; color: var(--gray-700); }
.mg-info { color: var(--gray-400); margin-left: 4px; font-size: 10px; cursor: help; }
.mg-info:hover { color: #2563eb; }

/* ── Split button + menu actions ────────────────────────────── */
.mg-summary { display: flex; justify-content: space-between; align-items: center; }
.mg-summary-actions { display: flex; gap: 8px; }
.mg-btn-bulk { background: #dc2626; }
.mg-btn-bulk:hover { background: #b91c1c; }

.mg-action-cell { position: relative; white-space: nowrap; }
.mg-split-btn { display: inline-flex; }
.mg-split-btn .mg-do-mvt { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mg-split-btn .mg-action-menu-btn {
    border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 6px 8px;
    border-left: 1px solid rgba(255,255,255,.3);
}

.mg-action-menu {
    display: none; position: absolute; right: 0; top: 100%;
    background: white; border: 1px solid var(--gray-300); border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    min-width: 220px; z-index: 100; padding: 4px 0;
}
.mg-action-menu-open { display: block; }
.mg-act {
    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: var(--gray-700);
}
.mg-act:hover { background: var(--gray-100); }
.mg-act-danger { color: #dc2626; }
.mg-act-danger:hover { background: #fee2e2; }
.mg-act i { width: 14px; text-align: center; color: var(--gray-500); }
.mg-act-danger i { color: #dc2626; }

/* ── Bulk actions bar (apparaît quand >0 sélectionnés) ───────── */
.mg-bulkbar {
    display: none; align-items: center; justify-content: space-between;
    padding: 8px 14px; margin: 0 0 8px;
    background: #1e3a8a; color: white; border-radius: 4px;
    box-shadow: 0 2px 8px rgba(30, 58, 138, .25);
    animation: mgBulkSlide .15s ease-out;
}
.mg-bulkbar-active { display: flex; }
.mg-bulkbar-count { font-size: 13px; }
.mg-bulkbar-count strong { font-size: 16px; margin: 0 4px; }
.mg-bulkbar-btns { display: flex; gap: 6px; }
.mg-bulkbar .mg-btn { background: rgba(255,255,255,.18); color: white; font-size: 12px; }
.mg-bulkbar .mg-btn:hover { background: rgba(255,255,255,.30); }
.mg-bulk-do { background: #16a34a !important; }
.mg-bulk-do:hover { background: #15803d !important; }
.mg-bulk-reset { background: #dc2626 !important; }
.mg-bulk-reset:hover { background: #b91c1c !important; }
.mg-bulk-deselect { background: rgba(255,255,255,.10) !important; }

@keyframes mgBulkSlide {
    from { transform: translateY(-4px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.mg-row-selected { background: #eff6ff !important; }
.mg-row-selected.mg-urgence-hot { background: #fee2e2 !important; }
.mg-row-chk { cursor: pointer; }

/* ── Onglet Réorganiser ─────────────────────────────────────── */
.mg-reorg-modes {
    display: flex; gap: 4px; margin-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}
.mg-reorg-mode {
    background: transparent; border: 0; padding: 10px 16px; cursor: pointer;
    font-size: 13px; color: var(--gray-700);
    border-bottom: 2px solid transparent;
    display: inline-flex; align-items: center; gap: 8px;
}
.mg-reorg-mode:hover { background: var(--gray-50); }
.mg-reorg-mode-active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

.mg-reorg-form {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
    padding: 10px 12px; background: var(--gray-50); border-radius: 4px;
    flex-wrap: wrap;
}
.mg-reorg-form label { font-size: 12px; color: var(--gray-700); display: inline-flex; align-items: center; gap: 6px; }
.mg-reorg-form input { padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 12px; }

.mg-reorg-info {
    padding: 8px 12px; margin-bottom: 8px;
    background: #eff6ff; color: #1e40af; border-radius: 4px; font-size: 13px;
}

.mg-reorg-actions { margin-top: 12px; }

.mg-cd-form {
    display: flex; align-items: center; gap: 6px; margin: 12px 0;
    padding: 10px 12px; background: var(--gray-50); border-radius: 4px;
    font-size: 13px; color: var(--gray-700); flex-wrap: wrap;
}
.mg-cd-form input { padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 12px; }

.mg-select {
    padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px;
    font-size: 12px; background: white; min-width: 140px; cursor: pointer;
}
.mg-select:hover { border-color: var(--gray-400); }
.mg-select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

/* ── Searchable select (composant inline) ───────────────────── */
.mg-ss { position: relative; display: inline-block; }
.mg-ss-inp {
    padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px;
    font-size: 12px; min-width: 160px; background: white;
}
.mg-ss-inp:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.mg-ss-list {
    position: absolute; left: 0; top: calc(100% + 2px); margin: 0; padding: 4px 0;
    list-style: none; background: white;
    border: 1px solid var(--gray-300); border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
    max-height: 260px; overflow-y: auto;
    min-width: 100%; width: max-content; max-width: 360px;
    z-index: 100; font-size: 12px;
}
.mg-ss-opt {
    padding: 6px 10px; cursor: pointer; white-space: nowrap;
    border-bottom: 1px solid var(--gray-100);
}
.mg-ss-opt:last-child { border-bottom: 0; }
.mg-ss-opt:hover { background: #eff6ff; }
.mg-ss-opt[hidden] { display: none; }
.mg-ss-opt strong { color: var(--gray-900); }
.mg-ss-hint { color: var(--gray-500); font-size: 11px; margin-left: 6px; }

.mg-cons-target-row { background: #f0fdf4 !important; }
.mg-cons-target-row td { color: var(--gray-600); }
.mg-cons-target-row em { color: #16a34a; font-style: normal; font-weight: 600; font-size: 11px; }

/* ── Badge sidebar (compteur d'urgences) ───────────── */
.sidebar-badge {
    display: inline-block; background: #dc2626; color: white;
    border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 700;
    margin-left: 6px; min-width: 16px; text-align: center;
}

/* ── Popup overlay de confirmation (bouton « Faire » & co) ── */
.mg-confirm-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
    z-index: 9600; display: flex; align-items: center; justify-content: center;
}
.mg-confirm-box {
    background: #fff; border-radius: 10px; width: 440px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden;
    animation: mgConfirmIn .12s ease-out;
}
@keyframes mgConfirmIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mg-confirm-title {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; font-size: 14px; font-weight: 700;
    background: #eff6ff; color: #1d4ed8; border-bottom: 1px solid #dbeafe;
}
.mg-confirm-danger .mg-confirm-title { background: #fef2f2; color: #b91c1c; border-bottom-color: #fecaca; }
.mg-confirm-body { padding: 16px; font-size: 13px; color: #111827; line-height: 1.5; }
.mg-confirm-ref { margin-bottom: 10px; font-size: 13px; }
.mg-confirm-move {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px 12px;
}
.mg-confirm-qty { font-size: 15px; }
.mg-confirm-cell { font-family: monospace; background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; padding: 2px 8px; }
.mg-confirm-dest { border-color: #86efac; background: #f0fdf4; }
.mg-confirm-btns {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 10px 16px; border-top: 1px solid #e5e7eb; background: #fafafa;
}
.mg-confirm-ok { background: #2563eb; color: #fff; border-color: #2563eb; font-weight: 600; }
.mg-confirm-ok:hover { background: #1d4ed8; }
.mg-confirm-danger .mg-confirm-ok { background: #dc2626; border-color: #dc2626; }
.mg-confirm-danger .mg-confirm-ok:hover { background: #b91c1c; }

/* ── Prévisualisation « après transfert » dans le popup ── */
.mg-confirm-preview { margin-top: 12px; }
.mg-confirm-preview-head {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: #64748b; margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.mg-confirm-preview-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.mg-confirm-preview-grid td { padding: 5px 8px; border-top: 1px solid #f1f5f9; }
.mg-confirm-preview-grid td.mg-r { text-align: right; white-space: nowrap; }
.mg-confirm-preview-grid td.mg-c { text-align: center; color: #94a3b8; width: 26px; }
.mg-confirm-preview-seuil { margin-top: 8px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.mg-confirm-preview-seuil.mg-ok   { color: #16a34a; }
.mg-confirm-preview-seuil.mg-warn { color: #d97706; }

/* ── Récap bulk dans le popup (liste scrollable) ── */
.mg-confirm-bulk-wrap { max-height: 45vh; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 6px; }
.mg-confirm-bulk-wrap .mg-confirm-preview-grid td { padding: 4px 8px; font-size: 12px; }
.mg-confirm-bulk-head td { font-weight: 700; color: #64748b; font-size: 11px !important;
    text-transform: uppercase; letter-spacing: .3px; background: #f8fafc; border-top: none; }

.mg-confirm-wide { width: 640px; }

/* ── Bouton (i) aide de l'outil ── */
.mg-help-btn {
    background: #eff6ff; border: 1px solid #bfdbfe; color: #2563eb;
    border-radius: 50px; padding: 2px 8px; cursor: pointer; font-size: 13px;
    margin-right: 8px; vertical-align: middle;
}
.mg-help-btn:hover { background: #dbeafe; }
.mg-confirm-body p, .mg-confirm-body ul, .mg-confirm-body ol { text-align: left; }

/* Bouton Liste de transfert avec panier non vide */
.mg-btn-basket { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; font-weight: 700; }
.mg-btn-basket:hover { background: #dbeafe; }

/* Bandeau apprentissage conso à sec */
.mg-conso-warn {
    margin: 12px 0; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5;
    background: #fffbeb; border: 1px solid #fde68a; border-left: 5px solid #f59e0b; color: #78350f;
}
.mg-conso-warn i { color: #d97706; margin-right: 6px; }
.mg-conso-warn .mg-sub { display: block; margin-top: 4px; }
