/* Socle : reset, typographie, focus, utilitaires de mise en page. */

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

html {
    /* La place de la barre de défilement est toujours réservée : son apparition ne décale pas la page. */
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    letter-spacing: var(--tracking-tight);
    font-feature-settings: "cv11", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-display);
    color: var(--color-text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { margin: 0; }

a {
    color: var(--color-accent);
    text-decoration: none;
    text-underline-offset: 3px;
}

a:hover { text-decoration: underline; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
}

:focus { outline: none; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

::selection {
    background: var(--color-accent-soft);
    color: var(--color-accent-text);
}

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

code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }

* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
}

/* Même règle pour les zones qui défilent à l'intérieur de la page (tiroirs, dialogues, listes, agenda). */
.drawer-body, .dialog-body, .palette-list, .grille-agenda .corps, .m-contenu { scrollbar-gutter: stable; }

/* L'en-tête de l'agenda réserve la même place que le corps qui défile dessous : les colonnes restent alignées. */
.grille-agenda .entetes { overflow-y: hidden; scrollbar-gutter: stable; }

/* ---------- Utilitaires ---------- */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.stack-sm { --stack-gap: var(--space-2); }
.stack-lg { --stack-gap: var(--space-8); }

.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--cluster-gap, var(--space-2));
}

.cluster-between { justify-content: space-between; }

.grid-auto {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 280px), 1fr));
}

/* ---------- En-tête de page ---------- */

.page {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-8) var(--space-8) var(--space-16);
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.page-eyebrow {
    font-size: var(--text-sm);
    color: var(--color-text-subtle);
    margin-bottom: var(--space-1);
}

.page-title {
    font-size: var(--text-3xl);
    letter-spacing: var(--tracking-display);
}

.page-subtitle {
    margin-top: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-md);
}

.section-title {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-subtle);
}

@media (max-width: 900px) {
    .page { padding: var(--space-6) var(--space-4) var(--space-12); }
}

/* ---------- Tableaux (QuickGrid) ---------- */

.ds-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-base);
}

.ds-table th {
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-subtle);
}

.ds-table th button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.ds-table td {
    padding: var(--row-padding-y) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.ds-table tbody tr { transition: background var(--duration-fast) var(--ease-out); }
.ds-table tbody tr:hover { background: var(--color-surface-hover); }
.ds-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Erreur Blazor ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto var(--space-4) var(--space-4) auto;
    z-index: 1000;
    max-width: 420px;
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui .dismiss { cursor: pointer; margin-left: var(--space-3); }

/* Les icônes ne rétrécissent jamais dans un conteneur flex */
.icon { flex-shrink: 0; }

/* Titre focalisé après navigation (FocusOnNavigate) : utile aux lecteurs d'écran, sans anneau visible */
h1:focus, h1:focus-visible { box-shadow: none; }
