/* =====================================================================
   TLM Motor — Thème UX/UI global
   Surcouche Bootstrap 5 : header, sidebar, KPI, avatars, mode sombre.
   ===================================================================== */

:root {
    --tlm-primary: #0d4d8c;       /* bleu FAW */
    --tlm-primary-dark: #08365f;
    --tlm-accent: #e30613;        /* rouge accent */
    --tlm-header-h: 58px;
    --tlm-sidebar-w: 248px;
    --tlm-bg: #f4f6fa;
    --tlm-sidebar-bg: #ffffff;
    --tlm-border: #e7ebf2;
}

body.tlm-app {
    background: var(--tlm-bg);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ----- Thème sombre ----- */
[data-bs-theme="dark"] {
    --tlm-bg: #0f1623;
    --tlm-sidebar-bg: #18212f;
    --tlm-border: #263247;
}
[data-bs-theme="dark"] body.tlm-app { background: var(--tlm-bg); }
[data-bs-theme="dark"] .card { background: #18212f; }

/* ===== HEADER ===== */
.tlm-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--tlm-header-h);
    background: linear-gradient(90deg, var(--tlm-primary-dark), var(--tlm-primary));
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.tlm-brand img { object-fit: contain; }
.btn-tlm-app {
    background: rgba(255,255,255,.14);
    color: #fff;
    border: 1px solid rgba(255,255,255,.18);
}
.btn-tlm-app:hover { background: rgba(255,255,255,.25); color: #fff; }
.tlm-search-input {
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
}
.tlm-search-input::placeholder { color: rgba(255,255,255,.6); }
.tlm-search-input:focus {
    background: rgba(255,255,255,.2);
    color: #fff;
    box-shadow: none;
}
.tlm-notif-menu { min-width: 280px; }
.tlm-search-results { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; max-height: 440px; overflow-y: auto; }
.tlm-search-results .dropdown-item small { display: block; font-size: .72rem; }

/* ===== AVATAR ===== */
.tlm-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--tlm-accent);
    color: #fff;
    font-weight: 600;
    font-size: .8rem;
}
.tlm-avatar-sm { width: 26px; height: 26px; font-size: .68rem; }

/* ===== BODY / SIDEBAR ===== */
.tlm-body { padding-top: var(--tlm-header-h); }
.tlm-sidebar {
    width: var(--tlm-sidebar-w);
    min-width: var(--tlm-sidebar-w);
    background: var(--tlm-sidebar-bg);
    border-right: 1px solid var(--tlm-border);
    min-height: calc(100vh - var(--tlm-header-h));
    position: sticky;
    top: var(--tlm-header-h);
    height: calc(100vh - var(--tlm-header-h));
    overflow-y: auto;
}
.tlm-sidebar-title {
    padding: 1rem 1.25rem .5rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8a94a6;
}
.tlm-nav { padding: .25rem .5rem 1rem; }
.tlm-nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .85rem;
    margin-bottom: 2px;
    border-radius: .5rem;
    color: #3a465c;
    text-decoration: none;
    font-size: .9rem;
    transition: all .15s ease;
}
.tlm-nav-link i { width: 18px; text-align: center; color: #8a94a6; }
.tlm-nav-link:hover { background: #eef3fa; color: var(--tlm-primary); }
.tlm-nav-link:hover i { color: var(--tlm-primary); }
.tlm-nav-link.active {
    background: var(--tlm-primary);
    color: #fff;
}
.tlm-nav-link.active i { color: #fff; }
.tlm-nav-link.disabled { opacity: .55; pointer-events: none; }
[data-bs-theme="dark"] .tlm-nav-link { color: #c3ccda; }
[data-bs-theme="dark"] .tlm-nav-link:hover { background: #1e2a3c; }

/* RTL (arabe) */
[dir="rtl"] .tlm-sidebar { border-right: none; border-left: 1px solid var(--tlm-border); }

/* ===== CONTENU ===== */
.tlm-content { min-width: 0; }
.tlm-breadcrumb {
    background: #fff;
    border-bottom: 1px solid var(--tlm-border);
    padding: .6rem 1.25rem;
    font-size: .82rem;
}
[data-bs-theme="dark"] .tlm-breadcrumb { background: #18212f; }
.tlm-content-inner { min-height: calc(100vh - var(--tlm-header-h) - 120px); }
.tlm-footer { border-top: 1px solid var(--tlm-border); }

/* ===== KPI ===== */
.tlm-kpi { border-radius: .75rem; transition: transform .15s ease, box-shadow .15s ease; }
.tlm-kpi:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.2rem rgba(13,77,140,.12) !important; }
.tlm-kpi-icon {
    width: 52px; height: 52px;
    border-radius: .65rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.tlm-kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.tlm-kpi-label { margin-top: .15rem; }

/* ===== AUTH ===== */
.tlm-auth-body {
    background: linear-gradient(135deg, #eef3fa 0%, #dde7f3 100%);
}
.tlm-auth-card { max-width: 880px; width: 100%; border-radius: 1rem; overflow: hidden; }
.tlm-auth-brand {
    background: linear-gradient(150deg, var(--tlm-primary), var(--tlm-primary-dark));
}

/* Boutons primaires alignés sur la charte */
.btn-primary {
    --bs-btn-bg: var(--tlm-primary);
    --bs-btn-border-color: var(--tlm-primary);
    --bs-btn-hover-bg: var(--tlm-primary-dark);
    --bs-btn-hover-border-color: var(--tlm-primary-dark);
    --bs-btn-active-bg: var(--tlm-primary-dark);
}
a, .text-primary { color: var(--tlm-primary); }

/* Sidebar responsive */
@media (max-width: 991.98px) {
    .tlm-sidebar {
        position: fixed;
        left: 0; top: var(--tlm-header-h);
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 1029;
        box-shadow: 0 0 30px rgba(0,0,0,.15);
    }
    .tlm-sidebar.show { transform: translateX(0); }
}

/* ===== KANBAN (pipeline Vente) ===== */
.tlm-kanban {
    display: flex;
    gap: .85rem;
    overflow-x: auto;
    padding-bottom: .75rem;
    align-items: flex-start;
}
.tlm-kanban-col {
    flex: 0 0 260px;
    background: #eef1f6;
    border-radius: .65rem;
    max-height: calc(100vh - 220px);
    display: flex;
    flex-direction: column;
}
[data-bs-theme="dark"] .tlm-kanban-col { background: #1a2333; }
.tlm-kanban-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .75rem;
    border-top: 3px solid;
    border-radius: .65rem .65rem 0 0;
    background: var(--tlm-sidebar-bg);
}
.tlm-kanban-body { padding: .6rem; overflow-y: auto; }
.tlm-kanban-card {
    display: block;
    background: var(--tlm-sidebar-bg);
    border: 1px solid var(--tlm-border);
    border-radius: .55rem;
    padding: .65rem .75rem;
    margin-bottom: .55rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: transform .12s ease, box-shadow .12s ease;
}
.tlm-kanban-card:hover { transform: translateY(-2px); box-shadow: 0 .4rem .9rem rgba(13,77,140,.14); }
.tlm-kanban-card { cursor: grab; }
.tlm-kanban-card:active { cursor: grabbing; }

/* ===== PLANNING ATELIER ===== */
.tlm-plan-card { cursor: grab; font-size: .75rem; }
.tlm-plan-card:active { cursor: grabbing; }
.tlm-plan-cell { transition: background-color .12s; min-width: 70px; }
.tlm-kanban-ghost { opacity: .4; border: 2px dashed var(--tlm-primary); }

/* ===== TIMELINE (activités lead) ===== */
.tlm-timeline-icon {
    flex: 0 0 34px;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--tlm-bg);
    border: 1px solid var(--tlm-border);
    display: flex; align-items: center; justify-content: center;
    color: var(--tlm-primary);
    font-size: .8rem;
}
.tlm-timeline > li { position: relative; }

/* ===== WORKFLOW STEPPER (commandes) ===== */
.tlm-workflow { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: .25rem; }
.tlm-wf-step { flex: 1 1 0; min-width: 90px; text-align: center; position: relative; padding-top: 6px; }
.tlm-wf-step:not(:last-child)::after { content: ''; position: absolute; top: 22px; left: 50%; width: 100%; height: 3px; background: var(--tlm-border); z-index: 0; }
.tlm-wf-step.done:not(:last-child)::after { background: var(--tlm-primary); }
.tlm-wf-dot { position: relative; z-index: 1; width: 34px; height: 34px; margin: 0 auto 6px; border-radius: 50%; background: #fff; border: 2px solid var(--tlm-border); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; color: #8a94a6; }
.tlm-wf-step.done .tlm-wf-dot { background: var(--tlm-primary); border-color: var(--tlm-primary); color: #fff; }
.tlm-wf-step.active .tlm-wf-dot { box-shadow: 0 0 0 4px rgba(13,77,140,.15); }
.tlm-wf-label { font-size: .72rem; color: #6c757d; line-height: 1.1; }
.tlm-wf-step.done .tlm-wf-label { color: var(--tlm-primary); font-weight: 600; }


/* =====================================================================
   Cartes KPI — utilisées par les listes Magasin (pièces, mouvements,
   stock, alertes, catégories, fournisseurs, inventaire, commandes).
   Classe partagée : les vues n'ont plus à redéfinir ces règles.
   ===================================================================== */
.kpi { border: 1px solid var(--tlm-border); border-radius: .85rem; padding: .9rem 1.05rem; background: var(--tlm-sidebar-bg); display: flex; align-items: center; gap: .85rem; height: 100%; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.kpi:hover { box-shadow: 0 .35rem 1rem rgba(13, 77, 140, .12); transform: translateY(-2px); border-color: var(--tlm-primary); }
.kpi-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; flex: 0 0 auto; }
.kpi-val { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.kpi-lbl { font-size: .74rem; color: #8a93a6; text-transform: uppercase; letter-spacing: .3px; }
