/* =========================================================================
   TRANSFACT PRO — DESIGN SYSTEM ERP HAUTE DÉFINITION (HD) 2026
   3VO'F SARL — TRANSIT, TRANSPORT MULTIMODAL & LOGISTIQUE PÉTROLIÈRE
   LISIBILITÉ CRISTALLINE, CONTRASTE CHIRURGICAL & ZÉRO FLOU (PIXEL-PERFECT)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700;800&display=swap');

:root {
    /* ===== TYPOGRAPHIE TRANCHANTE HAUTE DÉFINITION (SEGO UI NATIF WINDOWS EN SECOURS ULTRA-NET) ===== */
    --font-main: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
    /* ===== PALETTE THÈME SOMBRE (GRAPHITE PÉTROLE & OR RAFFINÉ) ===== */
    --brand: #1a3a5c; /* Bleu Pétrole corporate TransFact */
    --bg: #090e17; /* Nuit industrielle profonde */
    --bg2: #0f172a; /* Ardoise sombre */
    --card: #131d31; /* Bleu pétrole nuit pour cartes & conteneurs */
    --ch: #18253d; /* Survol de lignes tranchant */
    --ac: #f59e0b; /* Or Raffinerie pur */
    --acl: #fbbf24; /* Or clair au survol */
    --ac-rgb: 245, 158, 11;
    /* Statuts Métier Modernes Ultra-Lisibles */
    --ok: #10b981; /* Vert émeraude validation */
    --no: #ef4444; /* Rouge rubis alerte & coulage */
    --wn: #f59e0b; /* Ambre contrôle & en cours */
    --in: #0284c7; /* Cyan technique information */

    --tx: #f8fafc; /* Blanc craie haute lisibilité sans éblouissement */
    --tx-heading: #ffffff; /* Blanc pur pour titres */
    --mt: #94a3b8; /* Texte secondaire rehaussé pour zéro flou */
    --mt-dark: #64748b; /* Texte tertiaire */
    --bd: #22344f; /* Filet de bordure net */
    /* Variables Barre Latérale & En-Tête Sombre */
    --sb-bg: #070d16;
    --sb-header-bg: #070d16;
    --sidebar-bg: #070d16;
    --sidebar-header-bg: #090e17;
    --topbar-bg: #090e17;
    --sb-border: #1e2c3f;
    --sb-category: #718096;
    --sb-text: #cbd5e1;
    --sb-icon: #a0aec0;
    --sb-hover-bg: rgba(255, 255, 255, 0.06);
    --sb-hover-text: #ffffff;
    --sb-hover-icon: #f59e0b;
    --sb-active-bg: rgba(245, 158, 11, 0.16);
    --sb-active-border: #f59e0b;
    --sb-active-text: #fbbf24;
    --sb-active-icon: #f59e0b;
    --sb-shortcut-bg: rgba(255, 255, 255, 0.08);
    --sb-shortcut-text: #94a3b8;
    --sb-shadow: 2px 0 14px rgba(0, 0, 0, 0.4);
    /* Champs de Saisie Sombre */
    --input-bg: #0b1422;
    --input-bd: #263854;
    --input-focus-bd: var(--ac);
    --input-focus-glow: rgba(var(--ac-rgb), 0.25);
    --sw: 250px;
    --sw-collapsed: 66px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    color-scheme: dark;
}

/* ===== PALETTE THÈME CLAIR (CONTRASTE RENFORCÉ WCAG AAA) ===== */
[data-theme="light"], body.light {
    --brand: #1a3a5c;
    --bg: #f8fafc;
    --bg2: #ffffff;
    --card: #ffffff;
    --ch: #f1f5f9;
    --ac: #d97706;
    --acl: #b45309;
    --ac-rgb: 217, 119, 6;
    --ok: #059669;
    --no: #dc2626;
    --wn: #d97706;
    --in: #0284c7;
    --tx: #0f172a;
    --tx-heading: #020617;
    --mt: #475569;
    --mt-dark: #64748b;
    --bd: #cbd5e1;
    --sb-bg: #ffffff;
    --sb-header-bg: #f8fafc;
    --sidebar-bg: #ffffff;
    --sidebar-header-bg: #ffffff;
    --topbar-bg: #ffffff;
    --sb-border: #e2e8f0;
    --sb-category: #475569;
    --sb-text: #0f172a;
    --sb-icon: #475569;
    --sb-hover-bg: #f1f5f9;
    --sb-hover-text: #0f172a;
    --sb-hover-icon: #d97706;
    --sb-active-bg: rgba(217, 119, 6, 0.12);
    --sb-active-border: #d97706;
    --sb-active-text: #b45309;
    --sb-active-icon: #d97706;
    --sb-shortcut-bg: #e2e8f0;
    --sb-shortcut-text: #475569;
    --sb-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
    --input-bd: #cbd5e1;
    --input-focus-bd: var(--brand);
    --input-focus-glow: rgba(26, 58, 92, 0.18);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
    color-scheme: light;
}

/* =========================================================================
   TRAITEMENT OPTIQUE ANTI-FLOU HARDWARE (LISSAGE CRISTALLIN RÉSEAU)
   ========================================================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--tx);
    font-size: 13px; /* Taille entière nette (Plus de demi-pixel) */
    line-height: 1.5;
    font-weight: 500;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transform: translateZ(0); /* Force l'accélération matérielle nette */
    transition: background-color var(--transition), color var(--transition);
}

/* Élimination du contour focus parasite */
h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus,
.ctx:focus, .side-brand:focus, [tabindex="-1"]:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Titrages Nets & Tranchés */
h1, h2, h3, h4, h5, h6, .ctx {
    color: var(--tx-heading);
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* ===== Scrollbars Modernes & Discrètes ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bd);
    border-radius: 4px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--ac);
    }

/* =========================================================================
   STRUCTURE DU LAYOUT GLOBAL & BARRE LATÉRALE (SIDEBAR)
   ========================================================================= */
.page {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
}

.sidebar, .tf-sidebar {
    width: var(--sw, 250px);
    background: var(--sb-bg) !important;
    border-right: 1px solid var(--sb-border) !important;
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition), background-color var(--transition);
    z-index: 100 !important;
    box-shadow: var(--sb-shadow);
}

    .sidebar .top-row, .tf-sidebar-header {
        height: 62px;
        background: var(--sb-header-bg) !important;
        border-bottom: 1px solid var(--sb-border) !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
    }

    .sidebar .navbar-brand, .side-brand {
        font-size: 15px;
        font-weight: 900;
        color: var(--tx) !important;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 8px;
        letter-spacing: -0.01em;
    }

.nav-category {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--sb-category);
    padding: 16px 16px 6px 16px;
}

.sidebar .nav-link, .tf-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--sb-text) !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

    .sidebar .nav-link:hover, .tf-nav-item:hover {
        background: var(--sb-hover-bg);
        color: var(--sb-hover-text) !important;
    }

    .sidebar .nav-link.active, .tf-nav-item.active {
        background: var(--sb-active-bg) !important;
        color: var(--sb-active-text) !important;
        border-left-color: var(--sb-active-border) !important;
        font-weight: 800;
    }

    .sidebar .nav-link .nav-icon {
        font-size: 14px;
        color: var(--sb-icon);
        transition: color var(--transition);
    }

    .sidebar .nav-link:hover .nav-icon,
    .sidebar .nav-link.active .nav-icon {
        color: var(--sb-active-icon);
    }

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 22px;
}

/* =========================================================================
   TABLEAUX HAUTE DÉFINITION (.dt) — DOUBLE ANCRAGE (EN-TÊTE & PIED FIGÉS)
   ========================================================================= */
.dt-wrap,
.invoices-table-wrap {
    overflow-y: auto !important;
    overflow-x: auto !important;
    max-height: calc(100vh - 235px) !important;
    border-radius: var(--radius-md);
    border: 1px solid var(--bd);
    box-shadow: var(--shadow-sm);
    background: var(--card);
    position: relative;
    transform: translateZ(0); /* Empêche le flou de défilement */
}

.dt {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
}

    /* En-tête de tableau figé universel */
    .dt thead th,
    table thead th {
        background: var(--bg2) !important;
        color: var(--mt);
        text-align: left;
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .06em;
        padding: 11px 14px;
        border-bottom: 2px solid var(--ac);
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        white-space: nowrap;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }

        .dt thead th.text-right,
        .dt tbody td.text-right {
            text-align: right;
        }

        .dt thead th.text-center,
        .dt tbody td.text-center {
            text-align: center;
        }

    .dt tbody td {
        padding: 10px 14px;
        border-bottom: 1px solid var(--bd);
        color: var(--tx);
        font-size: 13px;
        font-weight: 500;
    }

    .dt tbody tr {
        transition: background-color var(--transition);
    }

        .dt tbody tr:hover {
            background: var(--ch);
        }

/* Pied de tableau / Barre de pagination figée en bas d'écran */
.table-footer-sticky,
.table-pagination-bar {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 9 !important;
    background: var(--card) !important;
    border-top: 1.5px solid var(--bd) !important;
    padding: 10px 16px !important;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.25) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* Alignement parfait des montants financiers et litiges */
.tabular-amount {
    font-family: var(--font-mono) !important;
    font-variant-numeric: tabular-nums lining-nums !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em;
}

/* ===== Cartes & Conteneurs ===== */
.cc {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.ctx {
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tx);
}

/* ===== Boutons ERP Professionnels Tranchants ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

    .btn:active {
        transform: scale(.98);
    }

.btn-p {
    background: var(--ac);
    color: #0b1320;
    border-color: var(--ac);
    box-shadow: 0 2px 6px rgba(var(--ac-rgb), 0.25);
}

    .btn-p:hover {
        background: var(--acl);
        border-color: var(--acl);
        color: #ffffff;
        box-shadow: 0 4px 14px rgba(var(--ac-rgb), 0.35);
    }

.btn-s {
    background: var(--card);
    color: var(--tx);
    border: 1px solid var(--bd);
}

    .btn-s:hover {
        background: var(--ch);
        border-color: var(--ac);
        color: var(--ac);
    }

.btn-d {
    background: rgba(239, 68, 68, 0.12);
    color: var(--no);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

    .btn-d:hover {
        background: var(--no);
        color: #ffffff;
    }

.btn-sm {
    padding: 5px 11px;
    font-size: 11px;
}

.btn-i {
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--bd);
    color: var(--mt);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .btn-i:hover {
        color: var(--tx);
        border-color: var(--ac);
        background: var(--ch);
    }

/* =========================================================================
   FORMULAIRES & CHAMPS DE SAISIE HAUTE LISIBILITÉ
   ========================================================================= */
.fg {
    margin-bottom: 14px;
}

    .fg label {
        display: block;
        font-size: 12px;
        font-weight: 700;
        color: var(--tx);
        margin-bottom: 5px;
        letter-spacing: 0.1px;
    }

.fi, input[type="text"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-bd) !important;
    border-radius: var(--radius-sm);
    color: var(--tx) !important;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    transition: border-color var(--transition), box-shadow var(--transition);
}

    .fi:focus, input:focus, select:focus, textarea:focus {
        outline: none !important;
        border-color: var(--input-focus-bd) !important;
        box-shadow: 0 0 0 3px var(--input-focus-glow) !important;
    }

    .fi::placeholder, input::placeholder, textarea::placeholder {
        color: var(--mt-dark);
        opacity: 0.85;
        font-weight: 500;
    }

    /* =========================================================================
   SÉLECTEURS DÉROULANTS (<SELECT>)
   ========================================================================= */
    select.fi, select {
        cursor: pointer;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f59e0b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
        background-size: 13px;
        padding-right: 32px !important;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
    }

[data-theme="light"] select.fi, [data-theme="light"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23d97706'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

select option, select optgroup {
    background-color: var(--card) !important;
    color: var(--tx) !important;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
}

    select option:checked, select option:hover {
        background-color: var(--brand) !important;
        color: #ffffff !important;
    }

.fr {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

    .fr .fg {
        flex: 1;
        min-width: 180px;
    }

/* ===== Badges d'État Harmonisés ===== */
.bdg {
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-transform: uppercase;
}

.bdg-ok {
    background: rgba(16, 185, 129, 0.16);
    color: var(--ok);
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.bdg-wn {
    background: rgba(245, 158, 11, 0.16);
    color: var(--wn);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.bdg-no {
    background: rgba(239, 68, 68, 0.16);
    color: var(--no);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.bdg-in {
    background: rgba(2, 132, 199, 0.16);
    color: var(--in);
    border: 1px solid rgba(2, 132, 199, 0.35);
}

/* =========================================================================
   OPTION A : FENÊTRES MODALES SOUVERAINES — DOUBLE ANCRAGE TOTAL (HAUT & BAS FIGÉS)
   Z-INDEX : 9999 (Souveraineté totale sur tout l'écran)
   ========================================================================= */
.mo,
.modal-super-overlay,
.modal-pro-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(7, 13, 22, 0.85) !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    outline: none;
}

.mb,
.modal-super-container,
.modal-pro-container {
    background: var(--card) !important;
    border: 1.5px solid var(--bd) !important;
    border-radius: var(--radius-lg);
    width: min(1300px, 95vw) !important;
    max-height: 92vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modalAppear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    cursor: default;
    overflow: hidden !important;
    transform: translateZ(0); /* Élimine tout flou lors de l'animation */
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ms {
    max-width: 440px !important;
}

.mm {
    max-width: 650px !important;
}

.ml {
    max-width: 900px !important;
}

.mx {
    max-width: 1300px !important;
}

/* 1. EN-TÊTE FIGÉ EN HAUT DE LA MODALE */
.mh,
.modal-super-header,
.modal-pro-header {
    padding: 14px 20px;
    border-bottom: 1.5px solid var(--bd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg2) !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
}

    .mh h3,
    .modal-super-title,
    .modal-pro-title {
        font-size: 15px;
        font-weight: 800;
        color: var(--tx);
        letter-spacing: -0.2px;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

.mc,
.modal-super-close-btn,
.modal-pro-close-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--bd);
    background: var(--card);
    border-radius: 6px;
    color: var(--mt);
    cursor: pointer !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 13px;
}

    .mc:hover,
    .modal-super-close-btn:hover,
    .modal-pro-close-btn:hover {
        background: var(--no) !important;
        color: #ffffff !important;
        border-color: var(--no) !important;
        transform: scale(1.05);
    }

/* 2. CORPS DÉFILANT CENTRAL */
.mbd,
.modal-super-body,
.modal-pro-body {
    padding: 22px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex: 1 1 auto !important;
    background: var(--card);
    color: var(--tx);
    scrollbar-width: thin;
}

/* 3. PIED DE PAGE FIGÉ EN BAS DE LA MODALE */
.mft,
.modal-super-footer,
.modal-pro-footer {
    padding: 12px 20px;
    border-top: 1.5px solid var(--bd);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    background: var(--bg2) !important;
    flex-shrink: 0 !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 20 !important;
}
