/* ============================================================
   DESIGN SYSTEM — Pilotage Appels d'Offres 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: #1565C0;
    --primary-light: #42A5F5;
    --primary-dark: #0D47A1;
    --primary-hover: #0D47A1;
    --primary-alpha-08: rgba(21, 101, 192, 0.08);
    --primary-alpha-15: rgba(21, 101, 192, 0.15);
    --primary-alpha-30: rgba(21, 101, 192, 0.30);

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

    /* --- Couleurs sémantiques --- */
    --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(21, 101, 192, 0.04);

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

    /* --- 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(21, 101, 192, 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-family-display: 'Aptos Display', 'Inter', 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;
    --line-height-relaxed: 1.7;

    /* --- 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 applique .taipy-dark sur le body en dark mode */
.taipy-dark {
    --primary: #64B5F6;
    --primary-light: #90CAF9;
    --primary-dark: #1565C0;
    --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. CONTENEUR GLOBAL
   -------------------------------------------------------- */

#root > .MuiBox-root,
.taipy-Page > .MuiBox-root {
    max-width: 1440px;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
}

.taipy-part {
    margin-bottom: var(--space-2);
}

/* --------------------------------------------------------
   5. PAGE DE CONNEXION
   -------------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 40%, #1A237E 100%);
    position: relative;
    overflow: hidden;
}

/* Effet de particules subtil en background */
.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    top: -200px;
    right: -100px;
    border-radius: 50%;
    animation: float-orb 20s ease-in-out infinite;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(38, 166, 154, 0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
    border-radius: 50%;
    animation: float-orb 15s ease-in-out infinite reverse;
}

@keyframes float-orb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 15px) scale(0.95); }
}

.login-card {
    background: var(--bg-paper);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-xl), 0 0 80px rgba(21, 101, 192, 0.15);
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    animation: card-enter 0.6s var(--transition-spring) both;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: var(--space-1);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--space-4);
}

.login-btn button,
.login-btn .MuiButton-root {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #0D47A1 100%);
    color: var(--text-on-primary);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    font-size: var(--font-size-md);
    font-weight: 600;
    margin-top: var(--space-3);
    border: none;
    box-shadow: var(--shadow-primary);
    transition: all var(--transition-base);
    text-transform: none;
    letter-spacing: 0.3px;
}

.login-btn button:hover,
.login-btn .MuiButton-root:hover {
    background: linear-gradient(135deg, #0D47A1 0%, #1A237E 100%);
    box-shadow: 0 6px 20px rgba(13, 71, 161, 0.4);
    transform: translateY(-1px);
}

.login-help {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-4);
}

.login-version {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-5);
    opacity: 0.6;
}

/* --------------------------------------------------------
   6. 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-3) var(--space-6);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    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(21, 101, 192, 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-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* 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);
}

.comparatif-badge {
    background: var(--info-light);
    border: 1px solid var(--info);
    color: var(--info);
}

.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;
}

.header-user {
    display: flex;
    align-items: center;
}

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

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

/* Bouton deconnexion */
.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);
}

/* --------------------------------------------------------
   7. BARRE D'ONGLETS
   -------------------------------------------------------- */

.tab-bar {
    margin-bottom: var(--space-5);
}

.tab-bar .MuiList-root {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.tab-bar .MuiListItem-root,
.tab-bar .MuiListItemButton-root {
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-5);
    min-width: auto;
    flex: 0 0 auto;
    font-weight: 600;
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    justify-content: center;
    color: var(--text-primary);
    border: 1px solid transparent;
}

.tab-bar .MuiListItemButton-root:hover {
    background-color: var(--primary-alpha-08);
    color: var(--primary);
    border-color: var(--primary-alpha-15);
}

.tab-bar .Mui-selected,
.tab-bar .MuiListItemButton-root.Mui-selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    font-weight: 600;
    box-shadow: var(--shadow-primary);
    border-color: transparent;
}

/* Dark mode : onglets */
.taipy-dark .tab-bar .MuiListItemButton-root {
    color: var(--text-secondary);
}

.taipy-dark .tab-bar .Mui-selected,
.taipy-dark .tab-bar .MuiListItemButton-root.Mui-selected {
    background: linear-gradient(135deg, #42A5F5, #1565C0);
    color: #FFFFFF;
}

/* --------------------------------------------------------
   8. FIL D'ARIANE
   -------------------------------------------------------- */

.breadcrumb {
    background: var(--primary-alpha-08);
    border-left: 4px solid var(--primary);
    padding: var(--space-2) var(--space-4);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: var(--space-4);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    font-weight: 500;
}

.global-breadcrumb {
    background: linear-gradient(135deg, var(--primary-alpha-08), rgba(38, 166, 154, 0.06));
    border-left: 4px solid var(--primary);
    padding: var(--space-2) var(--space-5);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: var(--space-5);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: 0.2px;
    animation: breadcrumb-in 0.3s var(--transition-base) both;
}

@keyframes breadcrumb-in {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --------------------------------------------------------
   9. CARTES
   -------------------------------------------------------- */

.card {
    background: var(--bg-paper);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    text-align: center;
    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 on card hover */
.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%;
}

/* --------------------------------------------------------
   10. 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-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--primary);
    line-height: var(--line-height-tight);
    margin-top: var(--space-1);
    letter-spacing: -0.03em;
}

/* Variantes KPI par couleur */
.kpi-success {
    border-left: 4px solid var(--success);
}

.kpi-info {
    border-left: 4px solid var(--info);
}

.kpi-warning {
    border-left: 4px solid var(--warning);
}

.kpi-danger {
    border-left: 4px solid var(--danger);
}

.kpi-danger-value {
    color: var(--danger);
}

/* Carte d'alertes */
.alert-card {
    border-left: 5px solid var(--danger);
    background: linear-gradient(135deg, var(--danger-light), var(--bg-paper));
    text-align: left;
    margin-bottom: var(--space-4);
    animation: alert-pulse 3s ease-in-out infinite;
}

.alert-card .h3 {
    color: var(--danger);
    margin-top: 0;
}

@keyframes alert-pulse {
    0%, 100% { box-shadow: var(--shadow-sm); }
    50% { box-shadow: var(--shadow-sm), 0 0 0 3px var(--danger-light); }
}

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

.status-progress {
    border-left: 4px solid var(--warning);
}

.status-pending {
    border-left: 4px solid var(--danger);
}

/* --------------------------------------------------------
   11. TYPOGRAPHIE
   -------------------------------------------------------- */

.h1 {
    color: var(--primary);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: var(--line-height-tight);
}

.h2 {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-5);
    font-size: var(--font-size-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
    position: relative;
}

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

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

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

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

/* --------------------------------------------------------
   12. BOUTONS
   -------------------------------------------------------- */

.primary button,
.primary .MuiButton-root {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    font-weight: 600;
    border-radius: var(--radius-md);
    text-transform: none;
    padding: var(--space-2) var(--space-6);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-primary);
    border: none;
    letter-spacing: 0.3px;
}

.primary button:hover,
.primary .MuiButton-root:hover {
    background: linear-gradient(135deg, var(--primary-dark), #1A237E);
    box-shadow: 0 6px 20px var(--primary-alpha-30);
    transform: translateY(-1px);
}

.primary button:active,
.primary .MuiButton-root:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Bouton secondaire (refresh, etc.) */
.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);
    font-weight: 500;
    text-transform: none;
    transition: all var(--transition-base);
    padding: var(--space-2) var(--space-4);
}

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

/* --------------------------------------------------------
   13. TABLEAUX
   -------------------------------------------------------- */

.taipy-table {
    font-family: var(--font-family-display);
    font-size: var(--font-size-base);
}

/* En-tetes */
.taipy-table .MuiTableHead-root .MuiTableCell-head {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: var(--text-on-primary);
    font-weight: 700;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-3) var(--space-4);
    white-space: nowrap;
    border-bottom: none;
}

.taipy-dark .taipy-table .MuiTableHead-root .MuiTableCell-head {
    background: linear-gradient(180deg, #1E3A5F, #162D4A);
}

/* Zebra striping */
.taipy-table .MuiTableBody-root .MuiTableRow-root:nth-of-type(even) {
    background-color: var(--bg-subtle);
}

/* Hover */
.taipy-table .MuiTableBody-root .MuiTableRow-root {
    transition: background-color var(--transition-fast);
}

.taipy-table .MuiTableBody-root .MuiTableRow-root:hover {
    background-color: var(--primary-alpha-08);
}

/* Cellules */
.taipy-table .MuiTableBody-root .MuiTableCell-body {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

/* Bordure exterieure */
.taipy-table .MuiTable-root {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.taipy-table .MuiTableContainer-root {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* Couleurs lignes par statut */
.row-done td { background-color: rgba(67, 160, 71, 0.1); }
.row-progress td { background-color: rgba(251, 140, 0, 0.08); }
.row-pending td { background-color: rgba(189, 189, 189, 0.06); }
.row-best-offer td { background-color: rgba(67, 160, 71, 0.12); font-weight: 600; }

/* --------------------------------------------------------
   14. FORMULAIRES
   -------------------------------------------------------- */

.MuiOutlinedInput-root {
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.MuiOutlinedInput-root .MuiOutlinedInput-notchedOutline {
    border-color: var(--border);
    transition: all var(--transition-fast);
}

.MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
    border-color: var(--primary);
}

.MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha-08);
}

.MuiFormControl-root {
    margin-top: var(--space-2);
}

.MuiInputLabel-root {
    color: var(--text-primary);
    font-weight: 600;
    position: relative;
    transform: none;
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
}

.MuiInputLabel-root.Mui-focused {
    color: var(--primary);
}

.MuiInputLabel-root.MuiInputLabel-shrink {
    transform: none;
}

.MuiOutlinedInput-root .MuiOutlinedInput-notchedOutline legend {
    display: none;
}

/* Alignement colonnes en bas */
.align-columns-bottom > div {
    display: flex;
    align-items: flex-end;
}

.align-columns-bottom > div > div,
.align-columns-bottom > div > .MuiBox-root,
.align-columns-bottom > div .MuiFormControl-root,
.align-columns-bottom > div .MuiInputBase-root,
.align-columns-bottom > div .MuiAutocomplete-root {
    width: 100%;
}

.align-columns-bottom > div button,
.align-columns-bottom > div .MuiButton-root {
    width: 100%;
}

/* Full width */
.form-full-width > div > div {
    width: 100%;
}

.form-full-width > div > div > * {
    width: 100%;
    max-width: 100%;
}

.btn-full-width,
.btn-full-width button,
.btn-full-width .MuiButton-root,
.form-full-width > div button,
.form-full-width > div .MuiButton-root,
.form-full-width > div .MuiButtonBase-root {
    width: 100%;
    box-sizing: border-box;
}

/* Compact gap */
.compact-gap {
    gap: var(--space-2);
    column-gap: var(--space-2);
}

.compact-gap > div {
    padding-left: var(--space-1);
    padding-right: var(--space-1);
}

/* Marge haute */
.mt-2 {
    margin-top: 1.2rem;
}

/* --------------------------------------------------------
   15. SECTIONS AJOUTER / SUPPRIMER (Arborescence)
   -------------------------------------------------------- */

.section-add {
    background: var(--primary-alpha-08);
    border: 1px solid var(--primary-alpha-15);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin-bottom: var(--space-4);
    transition: all var(--transition-base);
}

.section-add:hover {
    border-color: var(--primary-alpha-30);
    box-shadow: var(--shadow-xs);
}

.section-delete {
    background: rgba(211, 47, 47, 0.04);
    border: 1px solid rgba(211, 47, 47, 0.15);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin-bottom: var(--space-4);
    transition: all var(--transition-base);
}

.section-delete:hover {
    border-color: rgba(211, 47, 47, 0.3);
    box-shadow: 0 0 0 3px var(--danger-light);
}

/* Bouton de confirmation pulsation rouge */
.confirm-blink button,
.confirm-blink .MuiButton-root {
    animation: confirm-pulse 0.8s ease-in-out infinite alternate;
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
    color: white;
    font-weight: 700;
    border: 2px solid var(--danger-dark);
    box-shadow: var(--shadow-danger);
}

@keyframes confirm-pulse {
    from {
        box-shadow: var(--shadow-danger);
        transform: scale(1);
    }
    to {
        box-shadow: 0 0 20px rgba(198, 40, 40, 0.6);
        transform: scale(1.02);
    }
}

/* --------------------------------------------------------
   16. MESSAGES DE SUCCES / ERREUR
   -------------------------------------------------------- */

.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;
}

.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;
}

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

/* --------------------------------------------------------
   17. TOGGLE THEME (position fixe bas-droite)
   -------------------------------------------------------- */

.footer-theme {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--bg-paper);
    border-radius: var(--radius-full);
    padding: var(--space-2);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    cursor: pointer;
}

.footer-theme .MuiFormControl-root {
    margin-top: 0;
}

.footer-theme .MuiFormLabel-root,
.footer-theme .MuiInputLabel-root,
.footer-theme label,
.footer-theme p {
    display: none !important;
}

.footer-theme:hover {
    box-shadow: var(--shadow-xl);
}

/* --------------------------------------------------------
   18. ANIMATIONS D'ENTREE (pages / sections)
   -------------------------------------------------------- */

/* Fade-in pour chaque onglet */
.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 pour les 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; }

/* --------------------------------------------------------
   19. RESPONSIVE
   -------------------------------------------------------- */

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

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

@media (max-width: 768px) {
    .taipy-layout > div > div {
        min-width: 100%;
        flex: 1 1 100%;
    }

    :root {
        --space-6: 1rem;
    }

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

    .tab-bar .MuiList-root {
        gap: var(--space-1);
    }

    .tab-bar .MuiListItemButton-root {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
    }

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

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

    .login-card {
        padding: var(--space-6);
        margin: 0 var(--space-4);
    }

    #root > .MuiBox-root,
    .taipy-Page > .MuiBox-root {
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }
}

@media (max-width: 480px) {
    .tab-bar .MuiList-root {
        flex-direction: column;
    }

    .tab-bar .MuiListItemButton-root {
        width: 100%;
    }
}

/* --------------------------------------------------------
   20. UTILITAIRES
   -------------------------------------------------------- */

.text-center {
    text-align: center;
}

/* 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);
}
