/* ==========================================================================
   EIM Outils — thème Bootstrap 5
   Palette : graphite (navigation), acier (fond), cobalt (actions),
   ambre haute visibilité (signal : page active, environnement hors production).
   ========================================================================== */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("../vendor/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: italic; font-weight: 400; font-display: swap; src: url("../vendor/fonts/barlow-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("../vendor/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("../vendor/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 500; font-display: swap; src: url("../vendor/fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("../vendor/fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
    --eim-graphite: #1e2933;
    --eim-graphite-2: #283642;
    --eim-graphite-3: #3a4a57;
    --eim-graphite-text: #c5ced6;
    --eim-steel: #f3f5f7;
    --eim-line: #dce1e6;
    --eim-ink: #1b2229;
    --eim-muted: #5d6b77;
    --eim-cobalt: #1f5fad;
    --eim-cobalt-dark: #174a88;
    --eim-amber: #f2b10a;
    --eim-red: #c23a2b;
    --eim-green: #2d7a4c;

    --eim-font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --eim-font-cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;

    --eim-sidebar-w: 210px;
    --eim-sidebar-w-collapsed: 52px;
    --eim-topbar-h: 46px;

    /* Bootstrap */
    --bs-body-font-family: var(--eim-font);
    --bs-body-font-size: .875rem;
    --bs-body-color: var(--eim-ink);
    --bs-body-bg: var(--eim-steel);
    --bs-border-color: var(--eim-line);
    --bs-border-radius: .3rem;
    --bs-border-radius-sm: .2rem;
    --bs-border-radius-lg: .45rem;
    --bs-primary: var(--eim-cobalt);
    --bs-primary-rgb: 31, 95, 173;
    --bs-danger: var(--eim-red);
    --bs-danger-rgb: 194, 58, 43;
    --bs-success: var(--eim-green);
    --bs-success-rgb: 45, 122, 76;
    --bs-warning: var(--eim-amber);
    --bs-warning-rgb: 242, 177, 10;
    --bs-link-color: var(--eim-cobalt);
    --bs-link-color-rgb: 31, 95, 173;
    --bs-link-hover-color: var(--eim-cobalt-dark);
    --bs-link-hover-color-rgb: 23, 74, 136;
    --bs-secondary-color: var(--eim-muted);
    --bs-focus-ring-color: rgba(31, 95, 173, .3);
}

body { -webkit-font-smoothing: antialiased; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--eim-font-cond);
    font-weight: 600;
    letter-spacing: .005em;
}
h2, .h2 { font-size: 1.2rem; }
h3, .h3 { font-size: 1.05rem; }
h4, .h4 { font-size: 1rem; }

:focus-visible { outline: 2px solid var(--eim-cobalt); outline-offset: 2px; }

/* --- Boutons ------------------------------------------------------------- */
.btn { font-weight: 500; }
.btn-primary {
    --bs-btn-bg: var(--eim-cobalt);
    --bs-btn-border-color: var(--eim-cobalt);
    --bs-btn-hover-bg: var(--eim-cobalt-dark);
    --bs-btn-hover-border-color: var(--eim-cobalt-dark);
    --bs-btn-active-bg: var(--eim-cobalt-dark);
    --bs-btn-active-border-color: var(--eim-cobalt-dark);
    --bs-btn-disabled-bg: var(--eim-cobalt);
    --bs-btn-disabled-border-color: var(--eim-cobalt);
}
.btn-outline-primary {
    --bs-btn-color: var(--eim-cobalt);
    --bs-btn-border-color: var(--eim-cobalt);
    --bs-btn-hover-bg: var(--eim-cobalt);
    --bs-btn-hover-border-color: var(--eim-cobalt);
    --bs-btn-active-bg: var(--eim-cobalt-dark);
}
.btn-danger { --bs-btn-bg: var(--eim-red); --bs-btn-border-color: var(--eim-red); --bs-btn-hover-bg: #a33023; --bs-btn-hover-border-color: #a33023; }
.btn-success { --bs-btn-bg: var(--eim-green); --bs-btn-border-color: var(--eim-green); --bs-btn-hover-bg: #24633d; --bs-btn-hover-border-color: #24633d; }

/* --- Structure ----------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.app-skip { position: absolute; left: .5rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; }

.app-sidebar {
    flex: 0 0 var(--eim-sidebar-w);
    width: var(--eim-sidebar-w);
    background: var(--eim-graphite);
    color: var(--eim-graphite-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1030;
}
.app-brand { padding: 0 .9rem; height: var(--eim-topbar-h); display: flex; align-items: center; border-bottom: 1px solid var(--eim-graphite-3); }
.app-brand-link { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.app-brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 26px;
    background: var(--eim-amber); color: var(--eim-graphite);
    font-family: var(--eim-font-cond); font-weight: 600; font-size: .85rem;
    border-radius: 3px;
}
.app-brand-name { font-family: var(--eim-font-cond); font-weight: 600; font-size: 1.1rem; }

.app-nav { margin: .5rem 0; padding: 0; flex: 1 1 auto; }
.app-nav-toggle {
    display: flex; align-items: center; gap: .7rem; width: 100%;
    padding: .4rem .85rem;
    background: none; border: 0; border-left: 3px solid transparent;
    color: var(--eim-graphite-text);
    font-family: var(--eim-font-cond); font-weight: 500; font-size: .95rem;
    text-align: left;
}
.app-nav-toggle:hover { background: var(--eim-graphite-2); color: #fff; }
.app-nav-toggle .bi { font-size: 1.05rem; flex: 0 0 auto; }
.app-nav-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-nav-caret { font-size: .7rem !important; transition: transform .15s; }
.app-nav-toggle[aria-expanded="true"] .app-nav-caret { transform: rotate(180deg); }
.app-nav-section.is-active > .app-nav-toggle { color: #fff; border-left-color: var(--eim-amber); }

.app-subnav { margin: 0 0 .35rem; padding: 0; }
.app-subnav-header {
    padding: .4rem .85rem .15rem 2.45rem;
    font-size: .78rem;
    color: #8796a3;
}
.app-subnav-link {
    display: block;
    padding: .22rem .85rem .22rem 2.45rem;
    color: var(--eim-graphite-text);
    text-decoration: none;
    font-size: .85rem;
    line-height: 1.3;
}
.app-subnav-link:hover { color: #fff; background: var(--eim-graphite-2); }
.app-subnav-link.is-current { color: #fff; background: var(--eim-graphite-3); box-shadow: inset 3px 0 0 var(--eim-amber); }
.app-subnav-link.is-action .bi { color: var(--eim-amber); margin-right: .2rem; }

.app-sidebar-collapse {
    display: flex; align-items: center; gap: .7rem;
    padding: .5rem .85rem;
    background: none; border: 0; border-top: 1px solid var(--eim-graphite-3);
    color: #8796a3; font-size: .85rem; text-align: left;
}
.app-sidebar-collapse:hover { color: #fff; }

.app-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    height: var(--eim-topbar-h);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem;
    background: #fff;
    border-bottom: 1px solid var(--eim-line);
}
.app-topbar-title { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: .6rem; }
.app-topbar .breadcrumb { font-size: .8rem; flex-wrap: nowrap; white-space: nowrap; --bs-breadcrumb-divider-color: var(--eim-muted); }
.app-topbar .breadcrumb-item { color: var(--eim-muted); }
/* fil d'Ariane et titre sur la même ligne : « Stock › Inventaire » */
.app-topbar .breadcrumb-item:last-child::after { content: "›"; color: var(--eim-muted); padding-left: .5rem; }
.app-page-title { font-size: 1.15rem; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-topbar-menu { font-size: 1.4rem; padding: .2rem .5rem; }
.app-user .btn { color: var(--eim-ink); }

.app-main { padding: .75rem 1rem 1.5rem; flex: 1 1 auto; }
.app-main:focus { outline: none; }

/* Menu réduit (bureau) */
@media (min-width: 1200px) {
    .sidebar-collapsed .app-sidebar { flex-basis: var(--eim-sidebar-w-collapsed); width: var(--eim-sidebar-w-collapsed); overflow: visible; }
    .sidebar-collapsed .app-sidebar .app-nav-label,
    .sidebar-collapsed .app-sidebar .app-nav-caret,
    .sidebar-collapsed .app-sidebar .app-brand-name,
    .sidebar-collapsed .app-sidebar .app-subnav { display: none !important; }
    .sidebar-collapsed .app-sidebar-collapse .bi { transform: rotate(180deg); }
    .sidebar-collapsed .app-nav-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
}

/* Menu en tiroir (tablettes, mobile) */
@media (max-width: 1199.98px) {
    .app-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; height: 100vh !important;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1050;
    }
    .sidebar-open .app-sidebar { transform: none; }
    .app-sidebar-collapse { display: none; }
    .app-sidebar-backdrop { position: fixed; inset: 0; background: rgba(30, 41, 51, .45); z-index: 1045; }
    .app-topbar { padding: 0 .75rem; }
    .app-main { padding: .6rem .6rem 1.25rem; }
}

/* --- Contenu ------------------------------------------------------------- */
.panel {
    background: #fff;
    border: 1px solid var(--eim-line);
    border-radius: var(--bs-border-radius);
    margin-bottom: .75rem;
}
.panel-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--eim-line);
}
.panel-header > h2, .panel-header > h3 { margin: 0; font-size: 1.02rem; flex: 1 1 auto; }
.panel-body { padding: .65rem .75rem; }
.panel-body-flush { padding: 0; }

/* Barre de filtres au-dessus d'un tableau */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .75rem; }
.filter-bar .form-label { font-size: .78rem; color: var(--eim-muted); margin-bottom: .1rem; }

/* Tableaux de données */
.data-table { font-size: .8125rem; font-variant-numeric: tabular-nums; }
.data-table > thead > tr > th {
    font-family: var(--eim-font-cond);
    font-weight: 600;
    font-size: .8rem;
    color: var(--eim-muted);
    background: #f7f9fa;
    white-space: nowrap;
    vertical-align: bottom;
}
.data-table > tbody > tr > td { vertical-align: middle; }
.data-table .col-num { text-align: right; white-space: nowrap; }
.data-table .col-tight { width: 1%; white-space: nowrap; }
.data-table.table-sm > :not(caption) > * > * { padding: .2rem .4rem; }
.table-responsive > .data-table { margin-bottom: 0; }

/* DataTables 2 */
div.dt-container { font-size: .8125rem; }
/* un tableau plus large que l'écran défile dans sa zone, pas la page entière */
div.dt-container .dt-layout-table { overflow-x: auto; }
div.dt-container .dt-search input { min-width: 16rem; }
div.dt-container div.dt-layout-row { margin: .35rem 0; }
div.dt-container .dt-paging .page-link { padding: .2rem .55rem; }
table.dataTable > thead > tr > th.dt-orderable-asc:hover, table.dataTable > thead > tr > th.dt-orderable-desc:hover { outline: none; color: var(--eim-ink); }

/* États (remplacent les couleurs codées en dur) */
.text-stock-out { color: var(--eim-red); font-weight: 600; }
.text-stock-low { color: #9a6b00; font-weight: 600; }
.row-attention > td { background: #fff8e1 !important; }

/* Chargement global */
.app-loading { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(243, 245, 247, .7); }
.app-loading[hidden] { display: none; }
.app-loading-box { background: #fff; border: 1px solid var(--eim-line); border-radius: var(--bs-border-radius); padding: .75rem 1.25rem; box-shadow: 0 6px 24px rgba(30, 41, 51, .12); }

/* Toasts */
.toast { font-size: .9rem; }
.toast-container { z-index: 2100; }

/* SweetAlert2 aux couleurs de l'application */
div:where(.swal2-container) div:where(.swal2-popup) { font-family: var(--eim-font); border-radius: var(--bs-border-radius-lg); }
div:where(.swal2-container) h2:where(.swal2-title) { font-family: var(--eim-font-cond); font-weight: 600; font-size: 1.35rem; color: var(--eim-ink); }

/* --- Accueil ------------------------------------------------------------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; align-items: start; }
.home-module { margin: 0; padding: .6rem .75rem .75rem; }
.home-module-title { font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.home-module-title .bi { color: var(--eim-muted); }
.home-links li + li { margin-top: .3rem; }
.home-links a { text-decoration: none; }
.home-links a:hover { text-decoration: underline; }

/* --- Layout bare ---------------------------------------------------------- */
.bare-main { padding: .6rem; }

/* --- Layout tablette (kiosk) --------------------------------------------- */
.kiosk { --bs-body-font-size: 1rem; }
.kiosk-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: stretch; gap: .5rem;
    min-height: 52px;
    padding: 0 .6rem;
    background: var(--eim-graphite);
    color: #fff;
}
.kiosk-brand { display: flex; align-items: center; padding-right: .5rem; text-decoration: none; }
.kiosk-tabs { display: flex; align-items: stretch; gap: .25rem; flex: 1 1 auto; }
.kiosk-tab {
    display: flex; align-items: center; gap: .5rem;
    min-height: 48px; padding: 0 1rem;
    color: var(--eim-graphite-text);
    font-family: var(--eim-font-cond); font-weight: 600; font-size: 1.1rem;
    text-decoration: none;
    border-bottom: 4px solid transparent;
}
.kiosk-tab:hover { color: #fff; }
.kiosk-tab.is-current { color: #fff; border-bottom-color: var(--eim-amber); }
.kiosk-tools { display: flex; align-items: center; gap: .75rem; }
.kiosk-user { color: var(--eim-graphite-text); font-size: .95rem; white-space: nowrap; }
.kiosk-main { padding: .6rem .75rem; }
/* place réservée sous le contenu uniquement quand une barre d'actions fixe est affichée */
.kiosk.has-actionbar .kiosk-main { padding-bottom: 5.5rem; }
.kiosk-actionbar[hidden] { display: none; }
/* bouton d'outil dans la barre du haut sombre (ex. afficher / masquer les commandes comptoir) */
.kiosk-tool-btn { color: var(--eim-graphite-text); border: 1px solid var(--eim-graphite-3); }
.kiosk-tool-btn:hover, .kiosk-tool-btn:focus-visible { color: #fff; border-color: var(--eim-graphite-text); }
.kiosk-tool-btn[aria-pressed="true"] { color: var(--eim-graphite); background: var(--eim-amber); border-color: var(--eim-amber); }

.kiosk .btn, .kiosk .form-control, .kiosk .form-select { min-height: 48px; }
/* Boutons à hauteur minimale imposée (tablette, barre d'actions, pavé numérique) : contenu centré verticalement.
   Indispensable pour <a class="btn"> et <label class="btn"> qui, contrairement à <button>, ne centrent pas leur contenu. */
.kiosk .btn, .kiosk-actionbar .btn, .numpad-grid .btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.kiosk .btn-sm { min-height: 40px; }
.kiosk .data-table { font-size: 1rem; }
.kiosk .data-table > :not(caption) > * > * { padding: .4rem .5rem; }
.kiosk div.dt-container { font-size: 1rem; }
.kiosk div.dt-container .dt-search input { min-height: 48px; font-size: 1.1rem; min-width: 20rem; }
.kiosk div.dt-container .dt-paging .page-link { min-width: 48px; min-height: 48px; display: flex; align-items: center; justify-content: center; }

.kiosk-actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020;
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
    padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--eim-line);
    box-shadow: 0 -4px 16px rgba(30, 41, 51, .08);
}
.kiosk-actionbar .btn { min-height: 52px; padding-left: 1.25rem; padding-right: 1.25rem; font-size: 1rem; }

/* Pavé numérique tactile (App.numpad) */
.numpad-display { font-size: 2rem; font-variant-numeric: tabular-nums; text-align: right; min-height: 64px; }
.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.numpad-grid .btn { min-height: 64px; font-size: 1.5rem; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
    .app-sidebar, .app-topbar, .kiosk-topbar, .kiosk-actionbar, .toast-container { display: none !important; }
    .app-main, .kiosk-main { padding: 0; }
    body { background: #fff; }
}
