/* ============================================================
   DESIGN SYSTEM — Coordination BTP
   Version 2.0 — Modern, accessible, dark-mode ready
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* --------------------------------------------------------
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   -------------------------------------------------------- */

:root {
    /* --- Couleurs primaires --- */
    --primary: #1976D2;
    --primary-light: #42A5F5;
    --primary-dark: #1565C0;
    --primary-hover: #1565C0;
    --primary-alpha-08: rgba(25, 118, 210, 0.08);
    --primary-alpha-15: rgba(25, 118, 210, 0.15);
    --primary-alpha-30: rgba(25, 118, 210, 0.30);

    /* --- Couleurs secondaires --- */
    --secondary: #26A69A;
    --secondary-light: #4DB6AC;
    --secondary-dark: #00897B;

    /* --- Couleurs semantiques --- */
    --success: #43A047;
    --success-light: #E8F5E9;
    --success-dark: #2E7D32;
    --warning: #FB8C00;
    --warning-light: #FFF3E0;
    --warning-dark: #E65100;
    --danger: #E53935;
    --danger-light: #FFEBEE;
    --danger-dark: #C62828;
    --info: #1976D2;
    --info-light: #E3F2FD;

    /* --- Surfaces --- */
    --bg-body: #F5F7FA;
    --bg-paper: #FFFFFF;
    --bg-elevated: #FFFFFF;
    --bg-subtle: #F8F9FB;
    --bg-hover: rgba(25, 118, 210, 0.04);

    /* --- Textes --- */
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-muted: #9E9E9E;
    --text-on-primary: #FFFFFF;

    /* --- Bordures --- */
    --border: #E0E0E0;
    --border-light: #F0F0F0;
    --border-focus: var(--primary);
    --divider: #EEEEEE;

    /* --- Ombres (multi-couches) --- */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.07), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.06);
    --shadow-primary: 0 4px 14px rgba(25, 118, 210, 0.25);
    --shadow-danger: 0 4px 14px rgba(229, 57, 53, 0.25);

    /* --- Rayons --- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* --- Typographie --- */
    --font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Aptos Display', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.35rem;
    --font-size-2xl: 1.75rem;
    --font-size-3xl: 2.25rem;
    --line-height-tight: 1.2;
    --line-height-base: 1.5;

    /* --- Espacement --- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    /* --- Transitions --- */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- Z-index --- */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 500;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* --------------------------------------------------------
   2. DARK MODE TOKENS
   -------------------------------------------------------- */

.taipy-dark {
    --primary: #64B5F6;
    --primary-light: #90CAF9;
    --primary-dark: #1976D2;
    --primary-hover: #42A5F5;
    --primary-alpha-08: rgba(100, 181, 246, 0.08);
    --primary-alpha-15: rgba(100, 181, 246, 0.15);
    --primary-alpha-30: rgba(100, 181, 246, 0.30);

    --secondary: #4DB6AC;
    --secondary-light: #80CBC4;

    --success-light: rgba(67, 160, 71, 0.12);
    --warning-light: rgba(251, 140, 0, 0.12);
    --danger-light: rgba(229, 57, 53, 0.12);
    --info-light: rgba(25, 118, 210, 0.12);

    --bg-body: #0A1929;
    --bg-paper: #132F4C;
    --bg-elevated: #1A3A5C;
    --bg-subtle: #0E2240;
    --bg-hover: rgba(100, 181, 246, 0.06);

    --text-primary: #E8EAF0;
    --text-secondary: #B0BEC5;
    --text-muted: #78909C;
    --text-on-primary: #0A1929;

    --border: #1E3A5F;
    --border-light: #162D4A;
    --border-focus: var(--primary);
    --divider: #1E3A5F;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.4);
    --shadow-primary: 0 4px 14px rgba(100, 181, 246, 0.2);
}

/* --------------------------------------------------------
   3. BASE / RESET
   -------------------------------------------------------- */

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: var(--line-height-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

hr {
    border: none;
    border-top: 1px solid var(--divider);
    margin: var(--space-6) 0;
}

/* --------------------------------------------------------
   4. HEADER DE L'APPLICATION
   -------------------------------------------------------- */

.app-header {
    background: linear-gradient(135deg, var(--info-light), rgba(38, 166, 154, 0.08));
    color: var(--primary);
    padding: var(--space-2) var(--space-6);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--primary-alpha-15);
    position: relative;
    z-index: var(--z-sticky);
    animation: header-slide 0.4s var(--transition-base) both;
}

.taipy-dark .app-header {
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.12), rgba(38, 166, 154, 0.06));
    border-color: var(--border);
}

@keyframes header-slide {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-header h1 {
    color: var(--primary);
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-header .header-info {
    display: flex;
    align-items: center;
    color: var(--primary);
}

/* Badge utilisateur */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--font-size-sm);
    letter-spacing: 0.2px;
    transition: all var(--transition-fast);
}

.admin-badge {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: var(--success-dark);
}

.reader-badge {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: var(--warning-dark);
}

/* Layout row du header : tout aligne verticalement */
.header-row > div {
    display: flex;
    align-items: center;
}

/* Bouton deconnexion dans le header */
.header-logout,
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-right: 90px;
}

.header-logout button,
.header-actions button {
    margin-top: 0;
}

/* Toggle theme — compact, position fixe en bas à droite, ne bloque pas les clics */
.theme-toggle-fixed {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-10);
    z-index: 1000;
    width: 80px;
    height: 40px;
    overflow: visible;
    pointer-events: auto;
}

.theme-toggle-fixed > span,
.theme-toggle-fixed > label,
.theme-toggle-fixed .MuiTypography-root,
.theme-toggle-fixed .MuiFormControlLabel-label {
    display: none !important;
}

.theme-toggle-fixed .MuiBox-root,
.theme-toggle-fixed > div {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    max-width: 80px !important;
}

/* Bouton deconnexion orange */
.btn-disconnect button,
.btn-disconnect .MuiButton-root {
    background: linear-gradient(135deg, #FF6D00, #E65100);
    color: #FFFFFF;
    border: none;
    min-width: 140px;
    font-weight: 600;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 10px rgba(255, 109, 0, 0.35);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: var(--space-2) var(--space-4);
    transition: all var(--transition-base);
}

.btn-disconnect button:hover,
.btn-disconnect .MuiButton-root:hover {
    background: linear-gradient(135deg, #E65100, #BF360C);
    box-shadow: 0 4px 16px rgba(255, 109, 0, 0.5);
    transform: translateY(-1px);
}

/* Ancien btn-logout (rouge) */
.btn-logout button,
.btn-logout .MuiButton-root {
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
    color: white;
    border: none;
    min-width: 130px;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-danger);
    transition: all var(--transition-base);
}

.btn-logout button:hover,
.btn-logout .MuiButton-root:hover {
    background: linear-gradient(135deg, var(--danger-dark), #B71C1C);
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.5);
    transform: translateY(-1px);
}

/* --------------------------------------------------------
   5. NAVIGATION ONGLETS (Toggle)
   -------------------------------------------------------- */

.nav-tabs {
    margin: var(--space-3) 0;
}

.nav-tabs .MuiToggleButtonGroup-root {
    flex-wrap: wrap;
    gap: var(--space-1);
    background: var(--bg-paper);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.nav-tabs .MuiToggleButton-root {
    text-transform: none;
    font-weight: 500;
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: all var(--transition-base);
}

.nav-tabs .MuiToggleButton-root:hover {
    background-color: var(--primary-alpha-08);
    color: var(--primary);
    border-color: var(--primary-alpha-15);
}

.nav-tabs .MuiToggleButton-root.Mui-selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    box-shadow: var(--shadow-primary);
    border-color: transparent;
}

.taipy-dark .nav-tabs .MuiToggleButton-root {
    color: var(--text-secondary);
}

.taipy-dark .nav-tabs .MuiToggleButton-root.Mui-selected {
    background: linear-gradient(135deg, #42A5F5, #1976D2);
    color: #FFFFFF;
}

/* --------------------------------------------------------
   6. CARTES
   -------------------------------------------------------- */

.card {
    background: var(--bg-paper);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin: var(--space-3) 0;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-alpha-15);
}

/* Shimmer effect */
.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
}

.card:hover::after {
    left: 100%;
}

.card-top {
    background: var(--bg-paper);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    margin: 0;
    box-shadow: var(--shadow-sm);
}

/* Layout consultation : colonnes droites alignees */
.consultation-right > div {
    display: flex;
    align-items: stretch;
}

.consultation-right .card-top {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.consultation-right .card-top .taipy-input[multiline] textarea,
.consultation-right .card-top .MuiInputBase-multiline {
    flex: 1;
    min-height: 120px;
}

/* Layout consultation detail */
.consultation-detail > div {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.consultation-detail > div > div {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

/* --------------------------------------------------------
   7. KPI CARDS (Dashboard)
   -------------------------------------------------------- */

.kpi-card {
    text-align: center;
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.kpi-label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: var(--font-size-3xl);
    font-weight: 800;
    line-height: var(--line-height-tight);
    color: var(--primary);
    letter-spacing: -0.03em;
}

.kpi-sub {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Variantes KPI */
.kpi-success { border-left: 4px solid var(--success); }
.kpi-info { border-left: 4px solid var(--info); }
.kpi-danger { border-left: 4px solid var(--danger); }
.kpi-danger-value { color: var(--danger); }

/* --------------------------------------------------------
   8. TYPOGRAPHIE
   -------------------------------------------------------- */

h1, .h1 {
    color: var(--primary);
    margin-bottom: var(--space-5);
    font-family: var(--font-display);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2, .h2 {
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: var(--space-3);
    font-family: var(--font-display);
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-top: var(--space-3);
    position: relative;
}

/* Gradient underline */
h2::after, .h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--secondary), transparent);
    border-radius: 2px;
}

h3, .h3 {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-top: var(--space-3);
}

h4, .h4 {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    font-weight: 500;
}

/* --------------------------------------------------------
   9. TABLEAUX (MUI DataGrid)
   -------------------------------------------------------- */

.MuiDataGrid-root {
    font-family: var(--font-display);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.MuiDataGrid-columnHeaders,
.MuiDataGrid-columnHeaderTitle {
    color: var(--text-primary);
    font-weight: 600;
    background-color: var(--bg-subtle);
}

.MuiDataGrid-columnHeader {
    border-bottom: 2px solid var(--primary);
}

.MuiDataGrid-columnSeparator {
    color: var(--border);
}

.MuiDataGrid-cell {
    color: var(--text-primary);
}

.MuiDataGrid-row:nth-of-type(even) {
    background-color: var(--bg-subtle);
}

.MuiDataGrid-row {
    transition: background-color var(--transition-fast);
}

.MuiDataGrid-row:hover {
    background-color: var(--primary-alpha-08);
    cursor: pointer;
}

/* Cellule editable */
.MuiDataGrid-cell--editable {
    cursor: pointer;
    position: relative;
}

.MuiDataGrid-cell--editable:hover::after {
    content: "\270F\FE0F";
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.6;
}

/* Cellule en edition */
.MuiDataGrid-cell--editing {
    overflow: visible;
}

.MuiDataGrid-cell--editing > * {
    width: 100%;
}

.MuiDataGrid-cell--editing input[type="text"],
.MuiDataGrid-cell--editing input[role="combobox"] {
    width: 100%;
    min-width: 200px;
}

.MuiDataGrid-cell--editing .MuiAutocomplete-root,
.MuiDataGrid-cell--editing .MuiAutocomplete-inputRoot,
.MuiDataGrid-cell--editing .MuiInputBase-root {
    width: 100%;
}

.MuiDataGrid-cell--editing .MuiAutocomplete-inputRoot {
    flex-wrap: nowrap;
}

/* Panneau deroulant */
.MuiAutocomplete-popper,
.MuiPopover-paper {
    min-width: 250px;
    z-index: 99999;
}

/* Tables HTML generiques */
table {
    font-family: var(--font-display);
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-primary);
}

/* --------------------------------------------------------
   10. FORMULAIRES
   -------------------------------------------------------- */

button {
    margin-top: var(--space-3);
}

input, select {
    width: 100%;
    margin-bottom: var(--space-3);
}

/* Selecteur d'onglets */
.taipy-selector {
    max-width: 300px;
}

.taipy-selector .MuiFormControl-root,
.taipy-selector .MuiInputBase-root {
    max-width: 280px;
    min-width: 280px;
}

.MuiList-root {
    min-width: 280px;
}

.taipy-selector select {
    max-width: 280px;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    transition: all var(--transition-fast);
}

.taipy-selector select:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--primary-alpha-15);
}

.taipy-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha-08);
}

.taipy-dark .taipy-selector select {
    background-color: var(--bg-paper);
    border-color: var(--border);
    color: var(--text-primary);
}

.taipy-dark .taipy-selector select:hover {
    border-color: var(--primary);
}

/* Boutons ameliores */
.taipy-button,
button.MuiButton-root {
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    font-weight: 500;
    text-transform: none;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-base);
}

.taipy-button:hover,
button.MuiButton-root:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Espacement formulaire login */
.login-fields {
    margin-top: var(--space-6);
}

.login-fields .taipy-input {
    margin-bottom: var(--space-4);
}

/* Espacement selectors/inputs dans les cartes et recherche */
.card .taipy-selector,
.card .taipy-input,
.search-row .taipy-selector,
.search-row .taipy-input {
    margin-top: var(--space-4);
}

/* Labels flottants MUI */
.MuiInputLabel-root,
.MuiFormLabel-root {
    color: var(--text-secondary);
    font-weight: 500;
}

.MuiInputLabel-shrink,
.MuiFormLabel-filled,
.MuiInputLabel-outlined.MuiInputLabel-shrink {
    color: var(--primary);
    font-weight: 600;
    font-size: 1rem;
    transform: translate(14px, -18px) scale(0.85);
    background: var(--bg-paper);
    padding: 0 6px;
    z-index: 1;
}

/* Inputs ameliores */
.taipy-input input,
.MuiTextField-root input {
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
}

/* Filtres calendrier — alignement vertical */
.filtres-row > div {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
}

.filtres-row > div > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Filtres recherche */
.search-row {
    align-items: center;
    column-gap: var(--space-4);
}

.search-row > div {
    overflow: hidden;
}

.search-row > div > div,
.search-row .MuiFormControl-root {
    width: 100%;
    max-width: none;
}

/* --------------------------------------------------------
   11. BOUTONS SPECIAUX
   -------------------------------------------------------- */

/* Bouton refresh */
.btn-refresh button,
.btn-refresh .MuiButton-root {
    background: var(--info-light);
    color: var(--primary);
    border: 1px solid var(--primary-alpha-15);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.btn-refresh button:hover,
.btn-refresh .MuiButton-root:hover {
    background: var(--primary-alpha-15);
    border-color: var(--primary-alpha-30);
    transform: translateY(-1px);
}

/* Bouton ajout (vert) */
.btn-add button,
.btn-add .MuiButton-root {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: white;
    font-weight: 600;
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px rgba(67, 160, 71, 0.25);
    transition: all var(--transition-base);
}

.btn-add button:hover,
.btn-add .MuiButton-root:hover {
    background: linear-gradient(135deg, var(--success-dark), #1B5E20);
    box-shadow: 0 6px 20px rgba(67, 160, 71, 0.35);
    transform: translateY(-1px);
}

/* --------------------------------------------------------
   12. MESSAGES
   -------------------------------------------------------- */

.alert-warning {
    background: var(--warning-light);
    border-left: 4px solid var(--warning);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-2) 0;
    border-radius: var(--radius-sm);
    color: var(--warning-dark);
    font-weight: 500;
}

.alert {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning-dark);
}

.error {
    color: var(--danger);
    font-weight: 700;
}

.placeholder {
    text-align: center;
    padding: var(--space-10);
    color: var(--text-muted);
}

.center {
    text-align: center;
}

/* Status borders */
.status-pending { border-left: 4px solid var(--text-muted); }
.status-progress { border-left: 4px solid var(--warning); }
.status-done { border-left: 4px solid var(--success); }

.success-message {
    color: var(--success);
    background: var(--success-light);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success);
    animation: msg-in 0.3s ease both;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Notifications */
.taipy-notification.success {
    background-color: var(--success);
    color: white;
}

.taipy-notification.error {
    background-color: var(--danger);
    color: white;
}

.taipy-notification.warning {
    background-color: var(--warning);
    color: white;
}

/* --------------------------------------------------------
   13. TOGGLE THEME (dans le header)
   -------------------------------------------------------- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
}

.theme-toggle > label,
.theme-toggle .MuiFormControlLabel-label,
.theme-toggle .MuiTypography-root {
    display: none;
}

.theme-toggle .MuiToggleButtonGroup-root {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px;
}

.theme-toggle .MuiToggleButton-root {
    border: none;
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-2);
    min-width: 36px;
}

/* --------------------------------------------------------
   14. LARGEUR TABLEAU LIMITEE
   -------------------------------------------------------- */

.table-limited {
    max-width: 1200px;
    width: fit-content;
}

.table-limited .MuiDataGrid-root {
    max-width: 1200px;
    width: fit-content;
}

.table-limited .MuiDataGrid-main {
    max-width: 1200px;
}

/* --------------------------------------------------------
   15. ANIMATIONS D'ENTREE
   -------------------------------------------------------- */

/* Fade-in pages */
.taipy-part[class*="render"] {
    animation: page-enter 0.35s var(--transition-base) both;
}

@keyframes page-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Entree echelonnee KPI cards */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 180ms; }
.card:nth-child(5) { animation-delay: 240ms; }
.card:nth-child(6) { animation-delay: 300ms; }

/* --------------------------------------------------------
   16. RESPONSIVE
   -------------------------------------------------------- */

@media (max-width: 1200px) {
    .consultation-detail > div {
        flex-direction: column;
    }

    .consultation-detail > div > div {
        width: 100%;
        max-width: 100%;
    }

    .consultation-right > div {
        flex-direction: column;
    }

    .consultation-right .card-top {
        width: 100%;
        margin-bottom: var(--space-2);
    }
}

@media (max-width: 900px) {
    .taipy-layout > div {
        flex-wrap: wrap;
    }

    .taipy-layout > div > div {
        min-width: 100%;
        margin-bottom: var(--space-2);
    }
}

@media (max-width: 768px) {
    :root {
        --space-6: 1rem;
    }

    .card {
        padding: var(--space-4);
    }

    .taipy-selector select {
        max-width: 100%;
    }

    table {
        font-size: var(--font-size-base);
    }

    .app-header {
        padding: var(--space-2) var(--space-3);
    }

    .kpi-value {
        font-size: var(--font-size-2xl);
    }
}

/* --------------------------------------------------------
   17. UTILITAIRES
   -------------------------------------------------------- */

/* Scrollbar personnalisee */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection de texte */
::selection {
    background: var(--primary-alpha-30);
    color: var(--text-primary);
}

/* Focus visible (accessibilite) */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
