/* =====================================================================
   Essafa Auto Plus — Thème « Pro clair » (sans compilation)
   Design premium pour magasin d'auto-parts. Marque #076BB4.
   ===================================================================== */
:root {
    --bs-primary: #076BB4;
    --bs-primary-rgb: 7, 107, 180;
    --brand: #076BB4;
    --brand-2: #0a8ed9;
    --brand-3: #033f6b;

    --app-bg: #eef2f9;
    --ink: #1f2a37;
    --muted: #67748a;
    --line: rgba(16, 24, 40, .08);

    --radius: 16px;
    --radius-sm: 11px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 6px 18px rgba(16, 24, 40, .07), 0 2px 6px rgba(16, 24, 40, .05);
    --shadow-lg: 0 18px 44px rgba(16, 24, 40, .14);

    --sb-w: 268px;
}

/* ------------------------------ Base ------------------------------ */
* { scrollbar-color: rgba(16, 24, 40, .25) transparent; }
body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background-color: var(--app-bg);
    background-image:
        radial-gradient(1100px 560px at 100% -8%, rgba(10, 142, 217, .12), transparent 60%),
        radial-gradient(820px 480px at -10% 112%, rgba(7, 107, 180, .09), transparent 55%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, .fw-bold { letter-spacing: -.01em; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: #055a98; }
.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.badge.bg-primary { background-color: var(--brand) !important; }
.text-muted { color: var(--muted) !important; }

/* ---------------------------- Boutons ----------------------------- */
.btn { border-radius: .6rem; font-weight: 500; }
.btn-primary {
    --bs-btn-bg: #076BB4; --bs-btn-border-color: #076BB4;
    --bs-btn-hover-bg: #065a98; --bs-btn-hover-border-color: #05568f;
    --bs-btn-active-bg: #05568f; --bs-btn-active-border-color: #044b7e;
    --bs-btn-disabled-bg: #076BB4; --bs-btn-disabled-border-color: #076BB4;
    box-shadow: 0 6px 16px rgba(7, 107, 180, .25);
}
.btn-outline-primary { --bs-btn-color:#076BB4; --bs-btn-border-color:#076BB4; --bs-btn-hover-bg:#076BB4; --bs-btn-hover-border-color:#076BB4; --bs-btn-active-bg:#076BB4; }
.btn-group .btn, .btn-sm { box-shadow: none; }

/* ======================================================================
   BARRE LATÉRALE
   ====================================================================== */
.sidebar {
    width: var(--sb-w);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(185deg, #0a82cf 0%, #076BB4 45%, #055a98 100%);
    box-shadow: 6px 0 26px rgba(7, 107, 180, .18);
    z-index: 1045;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* En-tête / marque */
.sidebar-brand {
    display: flex; align-items: center; justify-content: center; gap: .7rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
    position: sticky; top: 0; z-index: 2;
    background: linear-gradient(185deg, #1c1c1c, #000);
}
.sidebar-logo-img { max-width: 100%; height: auto; display: block; }
.sidebar-logo {
    width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .18); color: #fff; font-size: 1.35rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.sidebar-brand .brand-name { color: #fff; font-weight: 700; line-height: 1.1; }
.sidebar-brand .brand-sub { color: rgba(255, 255, 255, .68); font-size: .72rem; letter-spacing: .02em; }

/* Titres de section */
.sidebar-heading {
    list-style: none;
    font-size: .67rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
    padding: .55rem 1.2rem .35rem;
    margin-top: .45rem;
}

/* Liens */
.sidebar .nav { padding: .35rem .15rem .8rem; }
.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; margin: .12rem .6rem;
    border-radius: .65rem;
    color: rgba(255, 255, 255, .84); font-size: .92rem; font-weight: 500;
    position: relative; transition: background .16s ease, color .16s ease, padding .16s ease;
}
.sidebar-link:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.sidebar-link.active { background: rgba(255, 255, 255, .17); color: #fff; font-weight: 600; }
.sidebar-link.active::before {
    content: ""; position: absolute; left: -.6rem; top: 50%; transform: translateY(-50%);
    width: 4px; height: 62%; border-radius: 0 4px 4px 0;
    background: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .75);
}
.sidebar-ico {
    width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .10); font-size: 1rem; transition: background .16s ease;
}
.sidebar-link:hover .sidebar-ico, .sidebar-link.active .sidebar-ico { background: rgba(255, 255, 255, .22); }
.sidebar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-chevron { margin-left: auto; font-size: .72rem; opacity: .7; transition: transform .2s ease; }
.sidebar-link[aria-expanded="true"] .sidebar-chevron { transform: rotate(180deg); }
.sidebar-link[aria-expanded="true"] { background: rgba(255, 255, 255, .08); color: #fff; }

/* Sous-menus */
.sidebar-sub { margin: .15rem .6rem .35rem 1.55rem; padding-left: .55rem; border-left: 1px solid rgba(255, 255, 255, .18); }
.sidebar-sub .sidebar-link { padding: .42rem .6rem; margin: .08rem 0; font-size: .86rem; font-weight: 400; }
.sidebar-sub .sidebar-ico { width: 24px; height: 24px; font-size: .8rem; background: transparent; }
.sidebar-sub .sidebar-link:hover .sidebar-ico, .sidebar-sub .sidebar-link.active .sidebar-ico { background: rgba(255, 255, 255, .18); }

/* Off-canvas mobile */
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(16, 24, 40, .5);
    backdrop-filter: blur(2px); z-index: 1044; opacity: 0; visibility: hidden; transition: opacity .25s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed; left: 0; top: 0;
        transform: translateX(-100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    }
    .sidebar.show { transform: none; }
}

/* ======================================================================
   TOPBAR
   ====================================================================== */
.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1.15rem;
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
}
.topbar-title { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.topbar .icon-btn {
    width: 40px; height: 40px; border-radius: 11px; border: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: #f1f4f9; color: var(--ink); position: relative; transition: background .15s ease;
}
.topbar .icon-btn:hover { background: #e6ebf3; }
.topbar .user-chip {
    display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .3rem;
    border-radius: 999px; transition: background .15s ease;
}
.topbar .user-chip:hover { background: #f1f4f9; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    box-shadow: 0 4px 12px rgba(7, 107, 180, .3);
}
.dropdown-menu { border: 0; border-radius: 14px; box-shadow: var(--shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 9px; padding: .5rem .7rem; }

/* ------------------------------ Cartes ---------------------------- */
.card { border: 0 !important; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-md); }
.card.shadow-sm { box-shadow: var(--shadow-md) !important; }
.card-header {
    background: #fff; border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding-top: .85rem; padding-bottom: .85rem;
}
.lift { transition: transform .18s ease, box-shadow .18s ease; will-change: transform; }
.lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card.border-start.border-4 { box-shadow: var(--shadow-md); }

/* ------------------------- Cartes KPI dégradé --------------------- */
.kpi { color: #fff; border: 0; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.kpi .kpi-label { color: rgba(255, 255, 255, .9); font-size: .82rem; font-weight: 500; }
.kpi .stat-num { color: #fff; }
.kpi .kpi-icon {
    width: 56px; height: 56px; border-radius: 16px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .22); font-size: 1.6rem; color: #fff;
}
.kpi-primary { background: linear-gradient(135deg, #0a8ed9 0%, #076BB4 100%); }
.kpi-danger  { background: linear-gradient(135deg, #ff7a7a 0%, #e23b54 100%); }
.kpi-warning { background: linear-gradient(135deg, #fcb73e 0%, #f59e0b 100%); }
.kpi-success { background: linear-gradient(135deg, #34d399 0%, #0f9d6e 100%); }
.kpi-info    { background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%); }

/* --------------------------- Chiffres ----------------------------- */
.stat-num { font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-counter { font-variant-numeric: tabular-nums; }

/* --------------------------- Composants --------------------------- */
.progress { border-radius: 999px; background: rgba(16, 24, 40, .07); }
.progress-bar { border-radius: 999px; }
.badge { font-weight: 600; border-radius: .5rem; padding: .42em .62em; }
/* Pastille de disponibilité par stock : icône blanche cerclée vert/rouge */
.stock-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    color: #fff; font-size: .9rem; line-height: 1;
    box-shadow: 0 2px 6px rgba(16, 24, 40, .18);
}
.stock-dot i { color: #fff; }
.table { --bs-table-hover-bg: rgba(7, 107, 180, .05); }
.table > thead th { font-weight: 600; color: var(--muted); background: #f7f9fc; border-bottom-color: var(--line); }
.table > :not(caption) > * > * { padding: .7rem .85rem; }
.form-control, .form-select { border-radius: .6rem; border-color: #e3e8f0; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(7, 107, 180, .15); }
.alert { border: 0; border-radius: 13px; box-shadow: var(--shadow-sm); }
.list-group-item { border-color: var(--line); }
/* Animation d'entrée en OPACITÉ uniquement : un transform sur <main> créerait un
   containing block qui piège les modales (Bootstrap) sous leur backdrop. */
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
main { animation: pageIn .35s ease; }
footer { background: transparent; }

/* --------------------------- Animations --------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .45s ease both; }

/* Rechargement AJAX des statistiques (sans recharger la page) */
.stats-loading { position: relative; opacity: .55; pointer-events: none; transition: opacity .15s ease; }
.stats-loading::after {
    content: ""; position: absolute; top: 64px; left: 50%; width: 38px; height: 38px; margin-left: -19px;
    border: 3px solid rgba(7, 107, 180, .25); border-top-color: var(--brand); border-radius: 50%;
    animation: spin .7s linear infinite; z-index: 5;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media print {
    .no-print, .sidebar, .sidebar-backdrop, .topbar, footer { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #dee2e6 !important; }
}
