*, *::before, *::after { box-sizing: border-box; }

/* ═══════════════════════════════════════════════════════════════════════════
   DESIGN SYSTEM — FacturaPro (TijaraFlow ERP)
   Changer uniquement les deux variables --tf-primary et --tf-primary-light
   pour adapter l'identité visuelle du module. Tout le reste est partagé.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. CSS Custom Properties ─────────────────────────────────────────────── */
:root {
    /* Module accent */
    --tf-primary:        #1D9E75;
    --tf-primary-light:  #E1F5EE;

    /* Surfaces */
    --tf-bg:             #f9fafb;
    --tf-surface:        #ffffff;
    --tf-surface-raised: #f3f4f6;

    /* Borders */
    --tf-border:         #e5e7eb;
    --tf-border-strong:  #d1d5db;

    /* Typography */
    --tf-text:           #111827;
    --tf-text-secondary: #374151;
    --tf-text-muted:     #6b7280;
    --tf-text-disabled:  #9ca3af;

    /* States */
    --tf-hover-bg:       #f3f4f6;
    --tf-focus-ring:     rgba(29, 158, 117, 0.25);

    /* Navigation */
    --tf-nav-label:      #9ca3af;

    /* Table */
    --tf-table-header:   #f9fafb;
    --tf-table-row-hover:#f9fafb;

    /* Radius */
    --tf-radius-sm:      4px;
    --tf-radius:         8px;
    --tf-radius-lg:      12px;

    /* Shadows */
    --tf-shadow-sm:      0 1px 2px 0 rgb(0 0 0 / .05);
    --tf-shadow:         0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
    --tf-shadow-md:      0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);

    /* Transitions */
    --tf-transition:     0.15s ease;
}

/* ── 2. Base ──────────────────────────────────────────────────────────────── */
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--tf-bg);
    color: var(--tf-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ── 3. MudBlazor Layout Shell ────────────────────────────────────────────── */

/* AppBar */
.mud-appbar {
    background-color: var(--tf-surface) !important;
    border-bottom: 1px solid var(--tf-border) !important;
    color: var(--tf-text) !important;
    box-shadow: none !important;
}
.mud-appbar .mud-icon-button {
    color: var(--tf-text-muted) !important;
}
.mud-appbar .mud-icon-button:hover {
    background-color: var(--tf-hover-bg) !important;
}

/* Drawer */
.mud-drawer,
.mud-drawer-content {
    background-color: var(--tf-surface) !important;
    border-right: 1px solid var(--tf-border) !important;
    box-shadow: none !important;
}

/* Drawer header */
.mud-drawer-header {
    padding: 12px 16px 8px !important;
    border-bottom: none !important;
}

/* Main content */
.mud-main-content {
    background-color: var(--tf-bg) !important;
    min-height: 100vh;
}

/* ── 4. Logo du module ────────────────────────────────────────────────────── */
.app-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tf-primary);
    flex-shrink: 0;
    display: inline-block;
}

.app-name {
    color: var(--tf-text) !important;
    font-weight: 700 !important;
    letter-spacing: -0.3px !important;
}

/* Label de section du drawer */
.drawer-section-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--tf-nav-label);
}

/* ── 5. Navigation ────────────────────────────────────────────────────────── */
.mud-nav-link {
    color: var(--tf-text-muted) !important;
    border-radius: var(--tf-radius-sm) !important;
    margin: 1px 8px !important;
    font-size: 14px !important;
    transition: background var(--tf-transition), color var(--tf-transition) !important;
}
.mud-nav-link:hover {
    background: var(--tf-hover-bg) !important;
    color: var(--tf-text) !important;
}
.mud-nav-link.active {
    background: var(--tf-primary-light) !important;
    color: var(--tf-primary) !important;
    font-weight: 500 !important;
}
.mud-nav-link .mud-nav-link-icon { color: inherit !important; }

.mud-nav-group-title {
    color: var(--tf-nav-label) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: .08em !important;
}

/* ── 6. Auth pages (Login / Register) ────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--tf-bg);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-subtitle {
    color: var(--tf-text-muted);
}

/* ── 7. Page structure ───────────────────────────────────────────────────── */

/* En-tête de page : titre à gauche + bouton d'action à droite */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    color: var(--tf-text) !important;
    font-weight: 700 !important;
}

.page-subtitle {
    color: var(--tf-text-muted) !important;
    margin-top: 2px;
}

/* En-tête d'une section à l'intérieur d'une card */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* ── 8. KPI / Stat cards ─────────────────────────────────────────────────── */
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tf-text-muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--tf-text);
}

.kpi-meta {
    font-size: 12px;
    color: var(--tf-text-muted);
    margin-top: 6px;
}

/* ── 9. Typographie utilitaires ──────────────────────────────────────────── */
.fw-medium   { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold     { font-weight: 700 !important; }

.text-muted     { color: var(--tf-text-muted) !important; }
.text-secondary { color: var(--tf-text-secondary) !important; }
.text-primary   { color: var(--tf-primary) !important; }
.text-error     { color: #EF4444 !important; }
.text-success   { color: #1D9E75 !important; }
.text-warning   { color: #F59E0B !important; }

/* ── 10. Table utilitaires ───────────────────────────────────────────────── */
.td-right { text-align: right !important; }
.td-bold  { font-weight: 700 !important; }
.th-right { text-align: right !important; }

/* ── 11. Force light theme — override dark inline styles des pages ──────────
   CSS !important dans la feuille de style > inline style sans !important      */
.mud-paper {
    background-color: var(--tf-surface) !important;
    border-color: var(--tf-border) !important;
    color: var(--tf-text) !important;
}

.mud-table-container,
.mud-table,
.mud-table-root { background: transparent !important; color: var(--tf-text) !important; }

.mud-table-head .mud-table-head-row,
.mud-table-head th {
    background-color: var(--tf-table-header) !important;
    color: var(--tf-text-muted) !important;
}

.mud-table-body tr,
.mud-table-body td { color: var(--tf-text) !important; }

.mud-table-toolbar { background-color: var(--tf-surface) !important; }

.mud-typography-h4,
.mud-typography-h5,
.mud-typography-h6 { color: var(--tf-text) !important; }

.mud-typography-body1,
.mud-typography-body2 { color: var(--tf-text-secondary) !important; }

.mud-data-grid .mud-table-head th {
    background-color: var(--tf-table-header) !important;
    color: var(--tf-text-muted) !important;
}

/* ── 12. Section card (remplace les anciens cards dark #18181b) ─────────── */
.content-section {
    background-color: var(--tf-surface) !important;
    border: 1px solid var(--tf-border) !important;
    border-radius: var(--tf-radius-lg) !important;
}

.content-section-header {
    padding: 20px;
    border-bottom: 1px solid var(--tf-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-section-body {
    padding: 20px;
}

/* Sous-section à l'intérieur d'un content-section */
.sub-section {
    background-color: var(--tf-bg) !important;
    border-radius: var(--tf-radius) !important;
    padding: 12px !important;
}

/* ── 13. Form section label ──────────────────────────────────────────────── */
.form-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--tf-text-muted);
    margin-bottom: 12px;
}

/* ── 14. Empty states ────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    text-align: center;
}
.empty-state-icon {
    font-size: 48px !important;
    color: var(--tf-border-strong) !important;
    margin-bottom: 12px;
}
.empty-state-text { color: var(--tf-text-muted) !important; }

/* ── 13. Loading full-page spinner ──────────────────────────────────────── */
.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--tf-bg);
}

/* ── 14. Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tf-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--tf-text-muted); }
