/* ============================================================
   PILOTIS — Design System CSS
   Architecture : variables → reset → layout → composants → pages
   Thème configurable via CSS Custom Properties
   ============================================================ */

/* ============================================================
   Variables (thème clair — surchargées par .dark-mode)
   ============================================================ */
:root {
    /* Couleurs primaires (surchargées dynamiquement via style inline) */
    --color-primary:   #4f46e5;
    --color-secondary: #0891b2;

    /* Palette sémantique */
    --color-success: #059669;
    --color-danger:  #dc2626;
    --color-warning: #d97706;
    --color-info:    #0284c7;

    /* Niveaux de gris */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Layout */
    --sidebar-width:    260px;
    --sidebar-bg:       #1e1b4b;
    --sidebar-text:     rgba(255,255,255,0.85);
    --sidebar-muted:    rgba(255,255,255,0.45);
    --sidebar-hover:    rgba(255,255,255,0.08);
    --sidebar-active:   rgba(255,255,255,0.15);
    --topbar-height:    60px;
    --topbar-bg:        #ffffff;
    --topbar-border:    var(--gray-200);
    --main-bg:          var(--gray-50);

    /* Contenu */
    --content-bg:   #ffffff;
    --content-text: var(--gray-800);
    --text-muted:   var(--gray-500);
    --border-color: var(--gray-200);

    /* Cards / Widgets */
    --widget-radius: 12px;
    --widget-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --widget-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);

    /* Typographie */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    --font-size-sm:   0.8125rem;
    --font-size-base: 0.9375rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.5rem;
    --font-size-2xl:  2rem;

    /* Transitions */
    --transition: 0.2s ease;
    --transition-slow: 0.35s ease;

    /* Z-index */
    --z-sidebar:  100;
    --z-topbar:   200;
    --z-dropdown: 300;
    --z-modal:    400;
    --z-flash:    500;

    /* Alias sémantiques (compatibilité admin.css / aide.css) */
    --color-surface:    var(--content-bg);
    --color-border:     var(--border-color);
    --color-text:       var(--content-text);
    --color-text-muted: var(--text-muted);
    --color-bg:         var(--gray-100);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* Border radius */
    --radius-sm:   4px;
    --radius:      6px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Mode sombre */
.dark-mode {
    --main-bg:      #0f172a;
    --topbar-bg:    #1e293b;
    --topbar-border:#334155;
    --content-bg:   #1e293b;
    --content-text: #e2e8f0;
    --text-muted:   #94a3b8;
    --border-color: #334155;
    --sidebar-bg:   #0f172a;
    --gray-50:      #1e293b;
    --gray-100:     #334155;
    --widget-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    color: var(--content-text);
    background: var(--main-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--gray-100);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--color-danger);
}

/* ============================================================
   Layout principal (sidebar + topbar + main)
   ============================================================ */
.layout-app {
    display: grid;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) 1fr;
    min-height: 100vh;
    transition: grid-template-columns var(--transition-slow);
}

/* Sidebar repliée */
.layout-app.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}
.layout-app.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
    width: 0;
}

/* Topbar */
.topbar {
    grid-area: topbar;
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar-left  { min-width: 0; flex: 1 1 auto; }
.topbar-right { flex-shrink: 0; }

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-slow), width var(--transition-slow);
    z-index: var(--z-sidebar);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* Brand / Logo sidebar */
.sidebar-brand { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-link { display: flex; align-items: center; gap: 0.75rem; color: white; }
.brand-link:hover { text-decoration: none; }
.brand-icon {
    width: 36px; height: 36px;
    background: var(--color-primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(79,70,229,0.4);
}
.brand-name { display: block; font-weight: 700; font-size: 1.1rem; letter-spacing: 0.05em; }
.brand-sub  { display: block; font-size: 0.7rem; color: var(--sidebar-muted); }

/* Navigation sidebar */
.sidebar-nav { flex: 1; padding: 0.75rem 0; }

.nav-group { margin-bottom: 0.25rem; }
.nav-group-label {
    display: block;
    padding: 0.75rem 1rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    margin: 0 0.5rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
    cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); text-decoration: none; color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; }
.nav-item.active .nav-icon { color: var(--color-primary); filter: brightness(1.5); }

.nav-icon { width: 18px; text-align: center; color: var(--sidebar-muted); flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-shortcut {
    font-size: 0.65rem;
    background: rgba(255,255,255,0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--sidebar-muted);
}

.nav-item-action { border: 1px solid rgba(255,255,255,0.08); }
.nav-item-primary {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    font-weight: 600;
    color: white !important;
}
.nav-item-primary:hover { background: rgba(255,255,255,0.2); }
.nav-item-primary .nav-icon { color: white; }

/* Pied de sidebar */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.75rem;
    color: var(--sidebar-muted);
}
.sidebar-footer-info { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.sidebar-footer-version { font-size: 0.65rem; }

/* Main content */
.main-content {
    grid-area: main;
    padding: 1.5rem;
    min-height: calc(100vh - var(--topbar-height));
    overflow-x: hidden;
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-sidebar) - 1);
}

/* ============================================================
   Layout minimal (login, setup)
   ============================================================ */
.layout-minimal {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
    padding: 1rem;
}

.flash-container-minimal {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-flash);
    min-width: 320px;
    max-width: 90vw;
}

/* ============================================================
   Composants — Boutons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-primary) 85%, black); color: white; }

.btn-secondary { background: var(--color-secondary); color: white; border-color: var(--color-secondary); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-secondary) 85%, black); color: white; }

.btn-success   { background: var(--color-success); color: white; }
.btn-danger    { background: var(--color-danger);  color: white; }
.btn-warning   { background: var(--color-warning); color: white; }

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: white; }

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: var(--border-color);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm  { padding: 0.3rem 0.7rem; font-size: 0.75rem; border-radius: 6px; }
.btn-lg  { padding: 0.75rem 1.5rem; font-size: 1rem; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--gray-600);
    transition: background var(--transition), color var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-icon-sm {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 6px;
    color: var(--gray-500);
    transition: all var(--transition);
    border: none; background: none; cursor: pointer;
    text-decoration: none;
}
.btn-icon-sm:hover { background: var(--gray-100); color: var(--color-primary); }

/* ============================================================
   Composants — Formulaires
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.4rem; font-weight: 500; font-size: var(--font-size-sm); color: var(--gray-700); }
.dark-mode .form-label { color: var(--gray-300); }

.form-control {
    display: block;
    width: 100%;
    padding: 0.6rem 0.875rem;
    font-size: var(--font-size-base);
    font-family: var(--font-sans);
    color: var(--content-text);
    background: var(--content-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled { background: var(--gray-100); opacity: 0.7; cursor: not-allowed; }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

.input-group { display: flex; align-items: stretch; }
.input-group > .form-control { flex: 1 1 auto; min-width: 0; border-radius: 0; }
.input-group > .form-control:first-child { border-radius: 8px 0 0 8px; }
.input-group > .form-control:last-child  { border-radius: 0 8px 8px 0; }
.input-group > .form-control:only-child  { border-radius: 8px; }

.input-group .input-addon,
.input-group-prefix,
.input-group-suffix {
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    background: var(--gray-100);
    border: 1.5px solid var(--border-color);
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}
.input-group-prefix { border-right: none; border-radius: 8px 0 0 8px; }
.input-group-suffix { border-left: none;  border-radius: 0 8px 8px 0; }
.input-group .input-addon { border-left: none; border-radius: 0 8px 8px 0; cursor: pointer; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.8rem; color: var(--color-danger); margin-top: 0.25rem; }

/* Barre de filtres (Notes, Étudiants, Réunions, Progression) */
.filters-form { padding: 1.1rem 1.25rem; }

/* Rendu du contenu WYSIWYG (observations, descriptions...) */
.wysiwyg-content { line-height: 1.6; }
.wysiwyg-content > *:first-child { margin-top: 0; }
.wysiwyg-content > *:last-child { margin-bottom: 0; }
.wysiwyg-content p { margin: 0 0 0.6em; }
.wysiwyg-content ul, .wysiwyg-content ol { margin: 0.4em 0 0.6em; padding-left: 1.4em; }
.wysiwyg-content ul { list-style: disc; }
.wysiwyg-content ol { list-style: decimal; }
.wysiwyg-content li { margin-bottom: 0.2em; }
.wysiwyg-content h2 { font-size: 1.2em; font-weight: 600; margin: 0.7em 0 0.3em; }
.wysiwyg-content h3 { font-size: 1.05em; font-weight: 600; margin: 0.6em 0 0.25em; }
.wysiwyg-content h4 { font-size: 1em; font-weight: 600; margin: 0.5em 0 0.2em; }
.wysiwyg-content a { color: var(--color-primary); }
.wysiwyg-content table { border-collapse: collapse; margin: 0.5em 0; }
.wysiwyg-content td, .wysiwyg-content th { border: 1px solid var(--border-color); padding: 0.3rem 0.6rem; }
.wysiwyg-content blockquote { margin: 0.5em 0; padding-left: 0.9em; border-left: 3px solid var(--border-color); color: var(--text-muted); }
.filters-grid {
    display: grid;
    gap: 1rem;
    align-items: start;
}
.filters-grid .form-group { margin-bottom: 0; }
.filters-grid .input-group { width: 100%; }
@media (max-width: 720px) {
    .filters-grid { grid-template-columns: 1fr !important; }
    .filters-grid .form-group[style*="align-self:end"] { display: flex; gap: 0.6rem; flex-wrap: wrap; }
}

/* ============================================================
   Composants — Alertes / Flash messages
   ============================================================ */
.flash-container {
    position: fixed;
    top: calc(var(--topbar-height) + 1rem);
    right: 1rem;
    z-index: var(--z-flash);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 420px;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-left: 4px solid;
    animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { transform: translateX(2rem); opacity: 0; } to { transform: none; opacity: 1; } }

.alert-info    { background: #eff6ff; border-color: var(--color-info);    color: #1e40af; }
.alert-success { background: #f0fdf4; border-color: var(--color-success); color: #166534; }
.alert-warning { background: #fffbeb; border-color: var(--color-warning); color: #92400e; }
.alert-danger  { background: #fef2f2; border-color: var(--color-danger);  color: #991b1b; }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: currentColor;
    opacity: 0.5;
    flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

/* ============================================================
   Composants — Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.badge-primary   { background: color-mix(in srgb, var(--color-primary) 15%, transparent);   color: var(--color-primary); }
.badge-secondary { background: color-mix(in srgb, var(--color-secondary) 15%, transparent); color: var(--color-secondary); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-gray      { background: var(--gray-100); color: var(--gray-600); }

/* ============================================================
   Composants — Tables
   ============================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
    color: var(--content-text);
}

.table th,
.table td {
    padding: 0.6rem 0.875rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}

.table th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--gray-50);
    white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: none; }

.table-sm th,
.table-sm td { padding: 0.4rem 0.75rem; }

.table-striped tbody tr:nth-child(even) td { background: var(--gray-50); }

.table-hover tbody tr:hover td { background: color-mix(in srgb, var(--color-primary) 5%, transparent); }

.dark-mode .table th { background: rgba(255,255,255,0.04); }
.dark-mode .table-striped tbody tr:nth-child(even) td { background: rgba(255,255,255,0.03); }

/* ============================================================
   Composants — Widgets (cards dashboard)
   ============================================================ */
.widget {
    background: var(--content-bg);
    border-radius: var(--widget-radius);
    box-shadow: var(--widget-shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}
.widget:hover { box-shadow: var(--widget-shadow-hover); }
.widget--alert { border-left: 4px solid var(--color-warning); }
.widget--primary { border-left: 4px solid var(--color-primary); }

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.widget-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.widget-title i { color: var(--color-primary); }
.dark-mode .widget-title { color: var(--gray-300); }

.widget-body { padding: 1.25rem; }
.widget-body--compact { padding: 0; }

/* ============================================================
   Composants — Stats KPI cards
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    border-radius: var(--widget-radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    border: none;
}
.stat-card::after {
    content: '';
    position: absolute;
    right: -16px; top: -16px;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.08;
    background: currentColor;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: rgba(255,255,255,0.25);
    color: white;
}
.stat-value {
    font-size: 2rem; font-weight: 800; line-height: 1;
    color: white;
}
.stat-label {
    font-size: 0.8rem; margin-top: 0.25rem;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
}

.stat-card--primary   { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.stat-card--secondary { background: linear-gradient(135deg, #0891b2, #0e7490); }
.stat-card--success   { background: linear-gradient(135deg, #059669, #047857); }
.stat-card--info      { background: linear-gradient(135deg, #d97706, #b45309); }

.stat-link { position: absolute; inset: 0; }

/* Dark mode — stat cards gardent leur couleur */
.dark-mode .stat-card--primary,
.dark-mode .stat-card--secondary,
.dark-mode .stat-card--success,
.dark-mode .stat-card--info { opacity: 0.92; }

/* ============================================================
   Dashboard — Grille principale
   ============================================================ */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.dashboard-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.page-title { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.dark-mode .page-title { color: white; }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.2rem; }
.wave { display: inline-block; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    align-items: start;
}
.dashboard-col-main { display: flex; flex-direction: column; gap: 1.5rem; }
.dashboard-col-side  { display: flex; flex-direction: column; gap: 1rem; }

/* Séances list */
.seances-list { display: flex; flex-direction: column; gap: 0; }
.seance-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    transition: background var(--transition);
}
.seance-item:last-child { border-bottom: none; }
.seance-item:hover { background: var(--gray-50); }

.seance-date-block {
    text-align: center;
    min-width: 42px;
    flex-shrink: 0;
}
.seance-day   { display: block; font-size: 1.4rem; font-weight: 700; line-height: 1; color: var(--gray-800); }
.seance-month { display: block; font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }

.seance-color-bar { width: 3px; height: 40px; border-radius: 2px; flex-shrink: 0; }
.seance-info { flex: 1; min-width: 0; }
.seance-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seance-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-muted); }
.seance-link { position: absolute; inset: 0; }

/* Journal list */
.journal-list { display: flex; flex-direction: column; }
.journal-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--content-text);
    transition: background var(--transition);
}
.journal-item:last-child { border-bottom: none; }
.journal-item:hover { background: var(--gray-50); text-decoration: none; }
.journal-item-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.journal-item-content { flex: 1; min-width: 0; }
.journal-item-title { font-weight: 500; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journal-item-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 0.75rem; margin-top: 0.1rem; }
.journal-item-arrow { color: var(--gray-300); font-size: 0.75rem; flex-shrink: 0; }

/* Section quick */
.section-quick-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.section-quick-item:last-child { border-bottom: none; }
.section-color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.section-quick-info { flex: 1; min-width: 0; }
.section-quick-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-quick-meta { font-size: 0.75rem; color: var(--text-muted); }
.section-quick-links { display: flex; gap: 0.25rem; }

/* Progression bars */
.progression-item { margin-bottom: 1rem; }
.progression-item:last-child { margin-bottom: 0; }
.progression-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.progression-matiere { font-size: 0.85rem; font-weight: 500; }
.progression-pct { font-size: 0.8rem; font-weight: 700; color: var(--gray-600); }
.progression-bar { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; margin-bottom: 0.3rem; }
.progression-bar-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease; }
.progression-detail { display: flex; gap: 0.4rem; align-items: center; font-size: 0.75rem; }

/* Absences */
.absence-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-sm);
}
.absence-item:last-child { border-bottom: none; }
.absence-absent .absence-icon  { color: var(--color-danger); }
.absence-retard .absence-icon  { color: var(--color-warning); }
.absence-name  { font-weight: 500; }
.absence-meta  { font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }
.absence-info  { flex: 1; }

/* Alertes */
.alerte-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-sm);
}
.alerte-item:last-child { border-bottom: none; }
.alerte-content { flex: 1; line-height: 1.4; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; min-width: 0; overflow: hidden; white-space: nowrap; }
.breadcrumb > * { flex-shrink: 0; }
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb-sep { color: var(--gray-300); font-size: 0.7rem; }
.breadcrumb-current { color: var(--gray-700); font-weight: 500; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   Composants — User menu (topbar)
   ============================================================ */
.sidebar-toggle { display: flex; }

.user-menu { position: relative; }
.user-menu-trigger {
    display: flex; align-items: center; gap: 0.6rem;
    background: none; border: none; cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: background var(--transition);
    color: var(--content-text);
    font-size: var(--font-size-sm);
}
.user-menu-trigger:hover { background: var(--gray-100); }

.user-avatar {
    width: 32px; height: 32px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-menu-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 0.5rem);
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 200px;
    z-index: var(--z-dropdown);
    overflow: hidden;
}
.user-menu-header { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border-color); }
.user-menu-header strong { display: block; margin-bottom: 0.2rem; }
.user-menu-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem;
    font-size: var(--font-size-sm);
    color: var(--content-text);
    transition: background var(--transition);
}
.user-menu-item:hover { background: var(--gray-50); text-decoration: none; }
.user-menu-logout { color: var(--color-danger); }
.user-menu-divider { height: 1px; background: var(--border-color); }

/* ============================================================
   Page Login
   ============================================================ */
.login-container { width: 100%; max-width: 420px; }

.login-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem; color: white;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(79,70,229,0.3);
}
.login-title    { font-size: 1.75rem; font-weight: 800; color: #1e1b4b; letter-spacing: 0.05em; }
.login-subtitle { color: var(--gray-500); margin-top: 0.25rem; }

.login-form .btn-login { margin-top: 0.5rem; padding: 0.75rem; font-size: 1rem; }

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--gray-400);
}
.separator { color: var(--gray-300); }
.link-muted { color: var(--gray-400); }
.link-muted:hover { color: var(--gray-600); }

.login-etablissement {
    text-align: center;
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

.login-rgpd-note {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ============================================================
   Pages d'erreur
   ============================================================ */
.error-page {
    text-align: center;
    padding: 3rem 1.5rem;
    color: white;
}
.error-code  { font-size: 6rem; font-weight: 800; line-height: 1; opacity: 0.15; }
.error-icon  { font-size: 4rem; margin-bottom: 1rem; }
.error-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 1rem; }
.error-message { color: rgba(255,255,255,0.7); margin-bottom: 2rem; }
.error-actions { display: flex; gap: 1rem; justify-content: center; }

/* ============================================================
   Modales
   ============================================================ */
.modal { display: none; position: fixed; inset: 0; z-index: var(--z-modal); }

/* Overlay canonique (toggle via style.display none/flex sur l'élément) */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1000);
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal-overlay > .modal-box { max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.modal-overlay > .modal-box .modal-body { overflow-y: auto; }
.modal-box--sm { max-width: 420px; }
.modal-box--lg { max-width: 760px; }
.modal-actions, .modal-footer {
    display: flex; gap: 0.75rem; justify-content: flex-end; flex-wrap: wrap;
    padding: 1rem 1.5rem; border-top: 1px solid var(--border-color);
}
.modal.is-open { display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-box {
    position: relative;
    background: var(--content-bg);
    border-radius: 14px;
    max-width: 560px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 1;
    overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.modal-close {
    background: none; border: none; font-size: 1.5rem; cursor: pointer;
    color: var(--gray-400); line-height: 1; padding: 0.2rem;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 1.5rem; }

/* Raccourcis clavier (modale) */
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
.shortcut-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.shortcut-group-title {
    grid-column: 1 / -1;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
    padding-top: .5rem;
    border-top: 1px solid var(--color-border);
    margin-top: .25rem;
}
.shortcut-group-title:first-child { border-top: none; margin-top: 0; padding-top: 0; }
kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    box-shadow: 0 1px 0 var(--gray-300);
    min-width: 2rem;
    text-align: center;
    flex-shrink: 0;
}

/* ============================================================
   Utilitaires
   ============================================================ */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-primary   { color: var(--color-primary); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-warning   { color: var(--color-warning); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex      { display: flex; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1       { gap: 0.5rem; }
.gap-2       { gap: 1rem; }

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; opacity: 0.3; }
.empty-state p { margin-bottom: 1rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .dashboard-col-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 280px; }

    .layout-app {
        grid-template-columns: 0 minmax(0, 1fr);
        grid-template-areas: "topbar topbar" "main main";
    }

    .sidebar {
        transform: translateX(-100%);
        grid-area: sidebar;
        position: fixed;
    }

    .layout-app.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay { display: block; }
    .main-content { padding: 1rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-col-side { grid-template-columns: 1fr; }

    .user-name { display: none; }
    .breadcrumb a, .breadcrumb-sep { display: none; }

    .topbar { padding: 0 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 1rem 1.15rem; }
    .dashboard-actions .btn span { display: none; }
    .login-card { padding: 1.5rem 1rem; }
}

/* ============================================================
   Animations
   ============================================================ */
[x-cloak] { display: none !important; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}
.fade-in { animation: fadeIn 0.25s ease; }

/* ============================================================
   TinyMCE — règles structurelles globales
   (évite que le throbber couvre toute la page pendant le chargement)
   ============================================================ */
.tox.tox-tinymce { position: relative !important; }
.tox .tox-throbber { pointer-events: none !important; }
.tox-tinymce-aux { pointer-events: none; }
.tox-tinymce-aux > .tox-dialog-wrap,
.tox-tinymce-aux > .tox-menu,
.tox-tinymce-aux > .tox-tooltip { pointer-events: auto; }
.tox-tinymce-aux .tox-menu, .tox-tinymce-aux .tox-dialog-wrap, .tox-tinymce-aux .tox-pop { pointer-events: auto; }

/* ============================================================
   Scrollbar personnalisée (Webkit)
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }


/* ============================================================
   Recherche globale (topbar)
   ============================================================ */
.topbar-search { flex: 0 1 380px; min-width: 0; display: flex; align-items: center; }
.global-search-toggle { display: none; }
.global-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--gray-50, #f8fafc);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 .65rem;
    height: 38px;
    transition: border-color .15s, box-shadow .15s;
}
.global-search:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    background: var(--color-surface);
}
.global-search-icon { color: var(--color-text-muted); font-size: .85rem; margin-right: .5rem; flex-shrink: 0; }
.global-search-input {
    flex: 1 1 auto; min-width: 0; border: none; background: transparent; outline: none;
    font-size: .875rem; color: var(--color-text);
}
.global-search-clear {
    border: none; background: none; color: var(--color-text-muted); cursor: pointer;
    padding: .15rem .3rem; flex-shrink: 0;
}
.global-search-clear:hover { color: var(--color-text); }

.global-search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--color-surface); border: 1px solid var(--border-color);
    border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14);
    max-height: 70vh; overflow-y: auto; z-index: var(--z-modal, 1000);
    padding: .4rem;
}
.global-search-group-label {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--color-text-muted); padding: .5rem .6rem .25rem;
}
.global-search-item {
    display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .6rem;
    border-radius: 8px; text-decoration: none; color: inherit;
}
.global-search-item:hover { background: var(--gray-50, #f1f5f9); }
.global-search-badge {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: .3rem;
    font-size: .7rem; font-weight: 600; padding: .2rem .5rem; border-radius: 999px;
    white-space: nowrap; margin-top: .1rem;
}
.global-search-badge.badge-seance  { background: #ede9fe; color: #5b21b6; }
.global-search-badge.badge-reunion { background: #dbeafe; color: #1d4ed8; }
.global-search-item-body { min-width: 0; flex: 1 1 auto; }
.global-search-item-title { display: block; font-weight: 600; font-size: .875rem; color: var(--color-text); }
.global-search-item-meta { display: block; font-size: .75rem; color: var(--color-text-muted); margin-top: .1rem; }
.global-search-item-extrait {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; font-size: .78rem; color: var(--color-text-muted); margin-top: .25rem;
}
.global-search-empty, .global-search-loading {
    padding: 1rem .75rem; text-align: center; font-size: .85rem; color: var(--color-text-muted);
}

@media (max-width: 768px) {
    .topbar-search { flex: 0 0 auto; }
    .global-search-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; border: none; background: none; color: var(--color-text);
        border-radius: 8px; cursor: pointer;
    }
    .global-search-toggle:hover { background: var(--gray-50, #f1f5f9); }
    .global-search { display: none; }
    body.search-mobile-open .global-search {
        display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 1101;
        height: var(--topbar-height); border-radius: 0; border: none;
        border-bottom: 1px solid var(--topbar-border); padding: 0 .75rem;
    }
    body.search-mobile-open .global-search-results {
        position: fixed; top: var(--topbar-height); left: 0; right: 0;
        border-radius: 0; max-height: calc(100vh - var(--topbar-height));
        border-left: none; border-right: none;
    }
    body.search-mobile-open .topbar-left { display: none; }
}
