/* =============================================================
   SKILLS DZ — DESIGN SYSTEM COMPONENTS (PHASE 1)
   -------------------------------------------------------------
   Tous les sélecteurs sont préfixés `.sdz-`.
   AUCUNE collision possible avec le CSS legacy
   (main.css, auth.css, dashboard.css, academy.css, admin.css).

   Dépendance : ce fichier suppose tokens.css chargé avant lui.

   Contrat d'accessibilité (WCAG 2.1 AA) :
   - `.sdz-btn--md` et `.sdz-lg` font 44px de haut (cible tactile).
   - Le ring de focus est unique et visible sur fond clair ET sombre.
   - `:disabled` est identifiable par 3 signaux cumulés :
     opacité réduite + curseur not-allowed + absence de shadow/ring.
   - Aucun composant ne transmet une information par la couleur seule
     (badges et alertes portent toujours un libellé texte).

   Conventions BEM internes : `.sdz-bloc__element--modifiers`.
   ============================================================= */

/* -------------------------------------------------------------
   0. RESET SCOPÉ (spécificité nulle via :where)
   N'affecte aucun élément existant : seuls les blocs .sdz-* sont
   concernés, donc le rendu legacy est strictement inchangé.
   ------------------------------------------------------------- */
:where(
  .sdz-btn, .sdz-icon-btn, .sdz-card, .sdz-badge, .sdz-chip,
  .sdz-avatar, .sdz-progress, .sdz-section-header, .sdz-field,
  .sdz-input, .sdz-select, .sdz-textarea, .sdz-toast, .sdz-alert,
  .sdz-skeleton, .sdz-empty-state, .sdz-error-state, .sdz-modal,
  .sdz-icon, .sdz-mascot
) {
  box-sizing: border-box;
}

:where(.sdz-btn, .sdz-icon-btn, .sdz-input, .sdz-select, .sdz-textarea) {
  font-family: var(--sdz-font-body);
  margin: 0;
}

/* =============================================================
   1. FOCUS — une seule implémentation, réutilisée partout
   ============================================================= */
:where(
  .sdz-btn, .sdz-icon-btn, .sdz-input, .sdz-select, .sdz-textarea,
  .sdz-chip, .sdz-card--interactive, .sdz-alert__close, .sdz-toast__close
):focus-visible {
  outline: var(--sdz-focus-ring-width) solid var(--sdz-focus-ring-color);
  outline-offset: var(--sdz-focus-ring-offset);
}

/* =============================================================
   2. BOUTONS
   ============================================================= */
.sdz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sdz-space-2);
  min-height: var(--sdz-control-height-md);
  padding: var(--sdz-space-3) var(--sdz-space-5);
  border: 1px solid transparent;
  border-radius: var(--sdz-radius-md);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-md);
  font-weight: var(--sdz-font-weight-semibold);
  line-height: var(--sdz-line-height-tight);
  letter-spacing: var(--sdz-letter-spacing-normal);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--sdz-transition-fast),
    border-color var(--sdz-transition-fast),
    color var(--sdz-transition-fast),
    box-shadow var(--sdz-transition-fast),
    transform var(--sdz-transition-fast);
}

/* --- Tailles --- */
.sdz-btn--sm {
  min-height: var(--sdz-control-height-sm);
  padding: var(--sdz-space-2) var(--sdz-space-3);
  font-size: var(--sdz-font-size-sm);
  gap: var(--sdz-space-1);
}

.sdz-btn--md {
  min-height: var(--sdz-control-height-md);
}

.sdz-btn--lg {
  min-height: var(--sdz-control-height-lg);
  padding: var(--sdz-space-4) var(--sdz-space-6);
  font-size: var(--sdz-font-size-lg);
}

/* --- Variantes --- */
.sdz-btn--primary {
  background-color: var(--sdz-primary);
  border-color: var(--sdz-primary);
  color: var(--sdz-text-on-primary);
  box-shadow: var(--sdz-shadow-sm);
}

.sdz-btn--secondary {
  background-color: var(--sdz-surface-2);
  border-color: var(--sdz-border-strong);
  color: var(--sdz-text);
}

.sdz-btn--ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--sdz-text-secondary);
  box-shadow: none;
}

.sdz-btn--danger {
  background-color: var(--sdz-danger);
  border-color: var(--sdz-danger);
  color: var(--sdz-text-on-primary);
  box-shadow: var(--sdz-shadow-sm);
}

/* --- États --- */
.sdz-btn--primary:hover:not(:disabled) {
  background-color: var(--sdz-primary-hover);
  border-color: var(--sdz-primary-hover);
}
.sdz-btn--accent,
.sdz-btn--primary.sdz-btn--accent {
  background-color: var(--sdz-accent);
  border-color: var(--sdz-accent);
  color: var(--sdz-accent-text);
}

.sdz-btn--secondary:hover:not(:disabled) {
  background-color: var(--sdz-surface-hover);
  border-color: var(--sdz-border-accent);
  color: var(--sdz-text);
}

.sdz-btn--ghost:hover:not(:disabled) {
  background-color: var(--sdz-surface-hover);
  color: var(--sdz-text);
}

.sdz-btn--danger:hover:not(:disabled) {
  background-color: var(--sdz-danger-text);
  border-color: var(--sdz-danger-text);
}

.sdz-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: var(--sdz-shadow-xs);
}

.sdz-btn:disabled,
.sdz-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  /* feedback non-couleur : le texte reste, la bordure s'affaiblit */
  border-color: var(--sdz-border-subtle);
}

/* --- Utilitaires --- */
.sdz-btn--block {
  display: flex;
  width: 100%;
}

.sdz-btn--loading {
  pointer-events: none;
  opacity: 0.75;
}

/* =============================================================
   3. BOUTON ICÔNE (cible 44x44 minimum)
   ============================================================= */
.sdz-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--sdz-control-height-md);
  height: var(--sdz-control-height-md);
  padding: 0;
  border: 1px solid var(--sdz-border);
  border-radius: var(--sdz-radius-md);
  background-color: var(--sdz-surface-2);
  color: var(--sdz-text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--sdz-transition-fast),
    border-color var(--sdz-transition-fast),
    color var(--sdz-transition-fast),
    transform var(--sdz-transition-fast);
}

.sdz-icon-btn:hover:not(:disabled) {
  background-color: var(--sdz-surface-hover);
  border-color: var(--sdz-border-strong);
  color: var(--sdz-text);
}

.sdz-icon-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.sdz-icon-btn:disabled,
.sdz-icon-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.sdz-icon-btn--sm {
  width: var(--sdz-control-height-sm);
  height: var(--sdz-control-height-sm);
  border-radius: var(--sdz-radius-sm);
}

.sdz-icon-btn--lg {
  width: var(--sdz-control-height-lg);
  height: var(--sdz-control-height-lg);
}

.sdz-icon-btn--ghost {
  background-color: transparent;
  border-color: transparent;
}

.sdz-icon-btn--borderless {
  border-color: transparent;
  background-color: transparent;
}

.sdz-icon-btn--borderless:hover:not(:disabled) {
  background-color: var(--sdz-surface-hover);
}

/* =============================================================
   4. CARTES
   ============================================================= */
.sdz-card {
  display: flex;
  flex-direction: column;
  background-color: var(--sdz-surface);
  border: 1px solid var(--sdz-border);
  border-radius: var(--sdz-radius-lg);
  box-shadow: var(--sdz-shadow-sm);
  color: var(--sdz-text);
}

.sdz-card--elevated {
  background-color: var(--sdz-bg-elevated);
  border-color: var(--sdz-border-strong);
  box-shadow: var(--sdz-shadow-md);
}

.sdz-card--flat {
  box-shadow: none;
}

.sdz-card--padded {
  padding: var(--sdz-space-5);
}

.sdz-card--interactive {
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color var(--sdz-transition-fast),
    background-color var(--sdz-transition-fast),
    transform var(--sdz-transition-fast),
    box-shadow var(--sdz-transition-fast);
}

.sdz-card--interactive:hover {
  border-color: var(--sdz-border-accent);
  background-color: var(--sdz-surface-2);
  transform: translateY(-2px);
  box-shadow: var(--sdz-shadow-md);
}

.sdz-card--interactive:active {
  transform: translateY(0);
  box-shadow: var(--sdz-shadow-sm);
}

.sdz-card--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.sdz-card__header,
.sdz-card__body,
.sdz-card__footer {
  padding: var(--sdz-space-4);
}

.sdz-card__header {
  border-bottom: 1px solid var(--sdz-border-subtle);
}

.sdz-card__footer {
  margin-top: auto;
  border-top: 1px solid var(--sdz-border-subtle);
}

/* =============================================================
   5. BADGES — toujours avec libellé texte (jamais couleur seule)
   ============================================================= */
.sdz-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sdz-space-1);
  padding: 0.25rem var(--sdz-space-2);
  border: 1px solid var(--sdz-border-strong);
  border-radius: var(--sdz-radius-xs);
  background-color: var(--sdz-surface-2);
  color: var(--sdz-text-secondary);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-xs);
  font-weight: var(--sdz-font-weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.sdz-badge--lg {
  padding: var(--sdz-space-1) var(--sdz-space-3);
  font-size: var(--sdz-font-size-sm);
  border-radius: var(--sdz-radius-sm);
}

.sdz-badge--primary {
  background-color: var(--sdz-primary-subtle);
  border-color: var(--sdz-primary);
  color: var(--sdz-accent);
}

.sdz-badge--accent {
  background-color: var(--sdz-accent-subtle);
  border-color: var(--sdz-accent);
  color: var(--sdz-accent);
}

.sdz-badge--success {
  background-color: var(--sdz-success-subtle);
  border-color: var(--sdz-success-border);
  color: var(--sdz-success-text);
}

.sdz-badge--warning {
  background-color: var(--sdz-warning-subtle);
  border-color: var(--sdz-warning-border);
  color: var(--sdz-warning-text);
}

.sdz-badge--danger {
  background-color: var(--sdz-danger-subtle);
  border-color: var(--sdz-danger-border);
  color: var(--sdz-danger-text);
}

.sdz-badge--info {
  background-color: var(--sdz-info-subtle);
  border-color: var(--sdz-info-border);
  color: var(--sdz-info-text);
}

/* Neutre : information secondaire sans connotation d'etat
   (statut "complet", compteur, tag structurel). */
.sdz-badge--neutral {
  background-color: var(--sdz-surface-active);
  border-color: var(--sdz-border);
  color: var(--sdz-text-secondary);
}

.sdz-badge--solid {
  background-color: var(--sdz-primary);
  border-color: var(--sdz-primary);
  color: var(--sdz-text-on-primary);
}

/* pastille d'état : toujours accompagnée d'un texte voisin */
.sdz-badge__dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: var(--sdz-radius-full);
  background-color: currentColor;
}

/* =============================================================
   6. CHIPS (filtres, tags)
   ============================================================= */
.sdz-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sdz-space-2);
  min-height: var(--sdz-control-height-sm);
  padding: var(--sdz-space-1) var(--sdz-space-3);
  border: 1px solid var(--sdz-border);
  border-radius: var(--sdz-radius-full);
  background-color: var(--sdz-surface-2);
  color: var(--sdz-text-secondary);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-sm);
  font-weight: var(--sdz-font-weight-medium);
  line-height: var(--sdz-line-height-snug);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--sdz-transition-fast),
    border-color var(--sdz-transition-fast),
    color var(--sdz-transition-fast);
}

.sdz-chip:hover:not(:disabled) {
  background-color: var(--sdz-surface-hover);
  border-color: var(--sdz-border-strong);
  color: var(--sdz-text);
}

/* état sélectionné : bordure + fond + texte, pas seulement la couleur */
.sdz-chip[aria-pressed="true"],
.sdz-chip.is-selected {
  background-color: var(--sdz-accent-subtle);
  border-color: var(--sdz-accent);
  color: var(--sdz-text);
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* =============================================================
   7. AVATARS
   ============================================================= */
.sdz-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border: 1px solid var(--sdz-border-strong);
  border-radius: var(--sdz-radius-full);
  background-color: var(--sdz-surface-2);
  color: var(--sdz-text-secondary);
  font-family: var(--sdz-font-display);
  font-size: var(--sdz-font-size-md);
  font-weight: var(--sdz-font-weight-semibold);
  line-height: 1;
  text-transform: uppercase;
}

.sdz-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sdz-avatar--xs {
  width: 1.5rem;
  height: 1.5rem;
  font-size: var(--sdz-font-size-xs);
}

.sdz-avatar--sm {
  width: 2rem;
  height: 2rem;
  font-size: var(--sdz-font-size-sm);
}

.sdz-avatar--lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: var(--sdz-font-size-xl);
}

.sdz-avatar--xl {
  width: 5rem;
  height: 5rem;
  font-size: var(--sdz-font-size-2xl);
}

.sdz-avatar--ring {
  border-color: var(--sdz-accent);
  box-shadow: 0 0 0 2px var(--sdz-accent-subtle);
}

/* =============================================================
   8. PROGRESSION
   L'accessibilité passe par role="progressbar" + aria-valuenow :
   voir .sdz-progress__label pour l announces alternative.
   ============================================================= */
.sdz-progress {
  display: flex;
  flex-direction: column;
  gap: var(--sdz-space-2);
  width: 100%;
}

.sdz-progress__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sdz-space-3);
  font-size: var(--sdz-font-size-sm);
}

.sdz-progress__label {
  color: var(--sdz-text-secondary);
  font-weight: var(--sdz-font-weight-medium);
}

.sdz-progress__value {
  color: var(--sdz-text);
  font-variant-numeric: tabular-nums;
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-progress__track {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: var(--sdz-radius-full);
  background-color: var(--sdz-surface-sunken);
  box-shadow: var(--sdz-shadow-inset);
}

/* S26.3A — la barre est un <progress> : la largeur du remplissage est la
   propriété native `value` (aucun style inline possible). L'élément reste
   une piste pleine largeur transparente ; le remplissage est le pseudo
   element de valeur, qui reçoit le dégradé et le radius. */
progress.sdz-progress__bar {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--sdz-radius-full);
  background: transparent;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

progress.sdz-progress__bar::-webkit-progress-bar {
  background: transparent;
}

progress.sdz-progress__bar::-webkit-progress-value {
  border-radius: var(--sdz-radius-full);
  background: linear-gradient(
    90deg,
    var(--sdz-primary) 0%,
    var(--sdz-accent) 100%
  );
}

progress.sdz-progress__bar::-moz-progress-bar {
  border-radius: var(--sdz-radius-full);
  background: linear-gradient(
    90deg,
    var(--sdz-primary) 0%,
    var(--sdz-accent) 100%
  );
}

progress.sdz-progress__bar--success::-webkit-progress-value {
  background: var(--sdz-success);
}

progress.sdz-progress__bar--success::-moz-progress-bar {
  background: var(--sdz-success);
}

progress.sdz-progress__bar--warning::-webkit-progress-value {
  background: var(--sdz-warning);
}

progress.sdz-progress__bar--warning::-moz-progress-bar {
  background: var(--sdz-warning);
}

progress.sdz-progress__bar--danger::-webkit-progress-value {
  background: var(--sdz-danger);
}

progress.sdz-progress__bar--danger::-moz-progress-bar {
  background: var(--sdz-danger);
}

.sdz-progress--sm .sdz-progress__track {
  height: 4px;
}

.sdz-progress--lg .sdz-progress__track {
  height: 12px;
}

/* dégradé cyan pur pour l'Academy / progression de niveau */
.sdz-progress--accent progress.sdz-progress__bar::-webkit-progress-value {
  background: linear-gradient(90deg, var(--sdz-accent) 0%, var(--sdz-primary) 100%);
}

.sdz-progress--accent progress.sdz-progress__bar::-moz-progress-bar {
  background: linear-gradient(90deg, var(--sdz-accent) 0%, var(--sdz-primary) 100%);
}

/* =============================================================
   9. EN-TÊTE DE SECTION
   ============================================================= */
.sdz-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sdz-space-4);
  margin-bottom: var(--sdz-space-5);
}

.sdz-section-header__text {
  min-width: 0;
}

.sdz-section-header__title {
  margin: 0;
  color: var(--sdz-text);
  font-family: var(--sdz-font-display);
  font-size: var(--sdz-font-size-xl);
  font-weight: var(--sdz-font-weight-bold);
  line-height: var(--sdz-line-height-snug);
  letter-spacing: var(--sdz-letter-spacing-tight);
}

.sdz-section-header__desc {
  margin: var(--sdz-space-1) 0 0;
  color: var(--sdz-text-muted);
  font-size: var(--sdz-font-size-sm);
  line-height: var(--sdz-line-height-normal);
}

.sdz-section-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sdz-space-2);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .sdz-section-header {
    flex-direction: column;
    align-items: stretch;
  }
  .sdz-section-header__actions {
    justify-content: flex-start;
  }
}

/* =============================================================
   10. FORMULAIRES
   ============================================================= */
.sdz-field {
  display: flex;
  flex-direction: column;
  gap: var(--sdz-space-2);
  margin-bottom: var(--sdz-space-4);
}

.sdz-field:last-child {
  margin-bottom: 0;
}

.sdz-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sdz-space-1);
  color: var(--sdz-text);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-sm);
  font-weight: var(--sdz-font-weight-semibold);
  line-height: var(--sdz-line-height-snug);
}

/* marque l'obligation sans dépendre de la couleur */
.sdz-label__required {
  color: var(--sdz-danger-text);
  font-weight: var(--sdz-font-weight-bold);
}

.sdz-label__optional {
  color: var(--sdz-text-muted);
  font-size: var(--sdz-font-size-xs);
  font-weight: var(--sdz-font-weight-regular);
}

.sdz-input,
.sdz-select,
.sdz-textarea {
  display: block;
  width: 100%;
  min-height: var(--sdz-control-height-md);
  padding: var(--sdz-space-3);
  border: 1px solid var(--sdz-border-strong);
  border-radius: var(--sdz-radius-md);
  background-color: var(--sdz-surface-sunken);
  color: var(--sdz-text);
  font-size: var(--sdz-font-size-md);
  line-height: var(--sdz-line-height-normal);
  transition:
    border-color var(--sdz-transition-fast),
    background-color var(--sdz-transition-fast),
    box-shadow var(--sdz-transition-fast);
}

/* placeholder lisible mais moins fort que le texte saisi */
.sdz-input::placeholder,
.sdz-textarea::placeholder {
  color: var(--sdz-text-muted);
  opacity: 1;
}

.sdz-textarea {
  min-height: 7rem;
  resize: vertical;
}

.sdz-select {
  appearance: none;
  padding-right: var(--sdz-space-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% + 2px),
    calc(100% - 15px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* --- États --- */
.sdz-input:hover:not(:disabled):not(:focus),
.sdz-select:hover:not(:disabled):not(:focus),
.sdz-textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--sdz-border-accent);
}

.sdz-input:focus,
.sdz-select:focus,
.sdz-textarea:focus {
  outline: none;
  border-color: var(--sdz-accent);
  box-shadow: var(--sdz-shadow-focus);
}

.sdz-input:disabled,
.sdz-select:disabled,
.sdz-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--sdz-surface-2);
  border-color: var(--sdz-border-subtle);
}

.sdz-input[readonly] {
  cursor: default;
}

/* error / success : bordure + texte d'aide dédié (jamais la couleur seule) */
.sdz-input--error,
.sdz-select--error,
.sdz-textarea--error,
.sdz-field--error .sdz-input,
.sdz-field--error .sdz-select,
.sdz-field--error .sdz-textarea {
  border-color: var(--sdz-danger);
  background-color: var(--sdz-danger-subtle);
}

.sdz-input--success,
.sdz-select--success,
.sdz-textarea--success,
.sdz-field--success .sdz-input,
.sdz-field--success .sdz-select,
.sdz-field--success .sdz-textarea {
  border-color: var(--sdz-success);
}

.sdz-field-help {
  color: var(--sdz-text-muted);
  font-size: var(--sdz-font-size-xs);
  line-height: var(--sdz-line-height-normal);
}

/* l'erreur est annoncée par aria-live dans le markup */
.sdz-field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sdz-space-1);
  color: var(--sdz-danger-text);
  font-size: var(--sdz-font-size-xs);
  font-weight: var(--sdz-font-weight-medium);
  line-height: var(--sdz-line-height-normal);
}

.sdz-field-error:empty {
  display: none;
}

/* =============================================================
   11. FEEDBACK — toasts
   ============================================================= */
.sdz-toast {
  position: fixed;
  right: var(--sdz-space-5);
  bottom: var(--sdz-space-5);
  z-index: var(--sdz-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sdz-space-3);
  width: min(380px, calc(100vw - var(--sdz-space-6)));
  margin: 0;
  padding: 0;
  list-style: none;
}

.sdz-toast__item {
  display: flex;
  align-items: flex-start;
  gap: var(--sdz-space-3);
  padding: var(--sdz-space-3) var(--sdz-space-4);
  border: 1px solid var(--sdz-border-strong);
  border-left: 3px solid var(--sdz-info);
  border-radius: var(--sdz-radius-md);
  background-color: var(--sdz-bg-elevated);
  box-shadow: var(--sdz-shadow-lg);
  color: var(--sdz-text);
  font-size: var(--sdz-font-size-sm);
  line-height: var(--sdz-line-height-normal);
  animation: sdz-toast-in var(--sdz-duration-normal) var(--sdz-ease-out);
}

.sdz-toast__item--success { border-left-color: var(--sdz-success); }
.sdz-toast__item--error   { border-left-color: var(--sdz-danger); }
.sdz-toast__item--warning { border-left-color: var(--sdz-warning); }

.sdz-toast__content {
  flex: 1;
  min-width: 0;
}

.sdz-toast__title {
  display: block;
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-toast__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sdz-text-muted);
  cursor: pointer;
}

.sdz-toast__close:hover {
  color: var(--sdz-text);
}

@keyframes sdz-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 480px) {
  .sdz-toast {
    right: var(--sdz-space-3);
    left: var(--sdz-space-3);
    bottom: var(--sdz-space-3);
    width: auto;
  }
}

/* =============================================================
   12. ALERTES (inline)
   ============================================================= */
.sdz-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sdz-space-3);
  padding: var(--sdz-space-3) var(--sdz-space-4);
  border: 1px solid var(--sdz-info-border);
  border-radius: var(--sdz-radius-md);
  background-color: var(--sdz-info-subtle);
  color: var(--sdz-text);
  font-size: var(--sdz-font-size-sm);
  line-height: var(--sdz-line-height-normal);
}

.sdz-alert__icon {
  flex-shrink: 0;
  color: var(--sdz-info-text);
}

.sdz-alert__content {
  flex: 1;
  min-width: 0;
}

.sdz-alert__title {
  display: block;
  margin-bottom: var(--sdz-space-1);
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-alert--success {
  border-color: var(--sdz-success-border);
  background-color: var(--sdz-success-subtle);
}
.sdz-alert--success .sdz-alert__icon { color: var(--sdz-success-text); }

.sdz-alert--warning {
  border-color: var(--sdz-warning-border);
  background-color: var(--sdz-warning-subtle);
}
.sdz-alert--warning .sdz-alert__icon { color: var(--sdz-warning-text); }

.sdz-alert--danger {
  border-color: var(--sdz-danger-border);
  background-color: var(--sdz-danger-subtle);
}
.sdz-alert--danger .sdz-alert__icon { color: var(--sdz-danger-text); }

.sdz-alert--neutral {
  border-color: var(--sdz-border);
  background-color: var(--sdz-surface-2);
}
.sdz-alert--neutral .sdz-alert__icon { color: var(--sdz-text-secondary); }

/* =============================================================
   13. SKELETONS
   ============================================================= */
.sdz-skeleton {
  display: block;
  width: 100%;
  height: 1rem;
  border-radius: var(--sdz-radius-sm);
  background: linear-gradient(
    90deg,
    var(--sdz-surface-2) 25%,
    var(--sdz-surface-hover) 37%,
    var(--sdz-surface-2) 63%
  );
  background-size: 200% 100%;
  animation: sdz-skeleton-shimmer 1.4s ease-in-out infinite;
}

.sdz-skeleton--text {
  height: 0.875rem;
  margin-bottom: var(--sdz-space-2);
}

.sdz-skeleton--title {
  height: 1.5rem;
  width: 60%;
}

.sdz-skeleton--circle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--sdz-radius-full);
}

.sdz-skeleton--block {
  height: 8rem;
  border-radius: var(--sdz-radius-lg);
}

.sdz-skeleton--bar {
  width: 100%;
  height: 10px;
  border-radius: var(--sdz-radius-full);
}

.sdz-skeleton--line {
  width: 100%;
  height: 12px;
  border-radius: var(--sdz-radius-full);
}

@keyframes sdz-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================
   14. ÉTATS VIDES / ERREUR
   ============================================================= */
.sdz-empty-state,
.sdz-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sdz-space-3);
  padding: var(--sdz-space-7) var(--sdz-space-5);
  border: 1px dashed var(--sdz-border-strong);
  border-radius: var(--sdz-radius-lg);
  background-color: var(--sdz-surface-2);
  text-align: center;
}

.sdz-empty-state__icon,
.sdz-error-state__icon {
  color: var(--sdz-text-muted);
}

.sdz-error-state {
  border-style: solid;
  border-color: var(--sdz-danger-border);
  background-color: var(--sdz-danger-subtle);
}

.sdz-error-state__icon {
  color: var(--sdz-danger-text);
}

.sdz-empty-state__title,
.sdz-error-state__title {
  margin: 0;
  color: var(--sdz-text);
  font-family: var(--sdz-font-display);
  font-size: var(--sdz-font-size-lg);
  font-weight: var(--sdz-font-weight-semibold);
  line-height: var(--sdz-line-height-snug);
}

.sdz-empty-state__desc,
.sdz-error-state__desc {
  margin: 0;
  max-width: 46ch;
  color: var(--sdz-text-secondary);
  font-size: var(--sdz-font-size-sm);
  line-height: var(--sdz-line-height-normal);
}

/* Etat vide occupe toute la largeur d'une grille (3 cartes -> 1 bloc),
   plutot qu'un texte centre au milieu de trois colonnes. */
.sdz-empty-state--block,
.sdz-error-state--block {
  grid-column: 1 / -1;
}

/* Variante discrete : message court dans une barre d'outils. */
.sdz-empty-state--inline {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sdz-space-3);
  padding: var(--sdz-space-4);
}

.sdz-empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sdz-space-2);
  margin-top: var(--sdz-space-2);
}

/* =============================================================
   15. MODALE
   Markup attendu :
   <div class="sdz-modal" role="dialog" aria-modal="true"
        aria-labelledby="titre" data-sdz-open hidden>
     <div class="sdz-modal__backdrop" data-sdz-close></div>
     <div class="sdz-modal__dialog">
       <header class="sdz-modal__header">
         <h2 id="titre" class="sdz-modal__title">…</h2>
         <button class="sdz-icon-btn sdz-icon-btn--sm" data-sdz-close
                 aria-label="Fermer">…</button>
       </header>
       <div class="sdz-modal__body">…</div>
       <footer class="sdz-modal__footer">…</footer>
     </div>
   </div>
   ============================================================= */
.sdz-modal[hidden] {
  display: none;
}

.sdz-modal {
  position: fixed;
  inset: 0;
  z-index: var(--sdz-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sdz-space-4);
}

.sdz-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: var(--sdz-surface-overlay);
  backdrop-filter: blur(2px);
}

.sdz-modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(85vh, 44rem);
  border: 1px solid var(--sdz-border-strong);
  border-radius: var(--sdz-radius-2xl);
  background-color: var(--sdz-bg-elevated);
  box-shadow: var(--sdz-shadow-lg);
  animation: sdz-modal-in var(--sdz-duration-normal) var(--sdz-ease-out);
}

.sdz-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sdz-space-4);
  padding: var(--sdz-space-5) var(--sdz-space-5) var(--sdz-space-4);
  border-bottom: 1px solid var(--sdz-border-subtle);
}

.sdz-modal__title {
  margin: 0;
  color: var(--sdz-text);
  font-family: var(--sdz-font-display);
  font-size: var(--sdz-font-size-xl);
  font-weight: var(--sdz-font-weight-bold);
  line-height: var(--sdz-line-height-snug);
  letter-spacing: var(--sdz-letter-spacing-tight);
}

.sdz-modal__body {
  flex: 1;
  padding: var(--sdz-space-5);
  overflow-y: auto;
  color: var(--sdz-text-secondary);
  font-size: var(--sdz-font-size-sm);
  line-height: var(--sdz-line-height-normal);
}

.sdz-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sdz-space-2);
  padding: var(--sdz-space-4) var(--sdz-space-5);
  border-top: 1px solid var(--sdz-border-subtle);
}

@keyframes sdz-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 480px) {
  .sdz-modal {
    padding: 0;
    align-items: flex-end;
  }
  .sdz-modal__dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--sdz-radius-xl) var(--sdz-radius-xl) 0 0;
  }
  .sdz-modal__footer {
    flex-direction: column-reverse;
  }
  .sdz-modal__footer .sdz-btn {
    width: 100%;
  }
}

/* =============================================================
   16. ICÔNES
   Librairie en place : Lucide 0.454.0 (CDN unpkg), déjà utilisée
   par index.html, login, register, dashboard via data-lucide.
   → AUCUNE nouvelle dépendance. On stylise la sortie de Lucide.

   <i data-lucide="trophy" class="sdz-icon sdz-icon--md"></i>
   ============================================================= */
.sdz-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sdz-icon--xs {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

.sdz-icon--sm {
  width: 16px;
  height: 16px;
}

.sdz-icon--md {
  width: 20px;
  height: 20px;
}

.sdz-icon--lg {
  width: 24px;
  height: 24px;
}

.sdz-icon--xl {
  width: 32px;
  height: 32px;
  stroke-width: 1.75;
}

.sdz-icon--accent { color: var(--sdz-accent); }
.sdz-icon--primary { color: var(--sdz-primary); }
.sdz-icon--muted { color: var(--sdz-text-muted); }
.sdz-icon--success { color: var(--sdz-success-text); }
.sdz-icon--warning { color: var(--sdz-warning-text); }
.sdz-icon--danger { color: var(--sdz-danger-text); }

/* =============================================================
   17. MASCOTTE PANDA — source unique
   assets/img/panda.svg
   Le SVG inline était dupliqué 3 fois (login, register, dashboard)
   avec des IDs de gradient différents => collision d'ID dans le DOM.
   En référençant le fichier via <img>, chaque occurrence est un
   document isolé : plus aucun risque de collision.

   <img class="sdz-mascot" src="assets/img/panda.svg"
        alt="" width="200" height="200">
   ============================================================= */
.sdz-mascot {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.sdz-mascot--xs { width: 32px; height: 32px; }
.sdz-mascot--sm { width: 56px; height: 56px; }
.sdz-mascot--md { width: 120px; height: 120px; }
.sdz-mascot--lg { width: 180px; height: 180px; }
.sdz-mascot--xl { width: 260px; height: 260px; }

.sdz-mascot--float {
  animation: sdz-mascot-float 4s var(--sdz-ease-standard) infinite;
}

@keyframes sdz-mascot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* =============================================================
   18. MOTION — respect de prefers-reduced-motion
   Les tokens de durée sont ramenés à ~0 dans tokens.css.
   On neutralise en plus les animations qui sequent.
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .sdz-mascot--float,
  .sdz-skeleton,
  .sdz-toast__item,
  .sdz-modal__dialog {
    animation: none;
  }

  .sdz-card--interactive,
  .sdz-btn,
  .sdz-icon-btn {
    transition-duration: 0.01ms;
  }
}

/* =============================================================
   19. UTILITAIRES
   ============================================================= */

/* Visible pour les lecteurs d'écran, invisible à l'écran.
   Utiliser à la place de `display:none` pour un contenu qui doit
   rester annoncé (libellés d'icônes, contexte d'un état actif...). */
.sdz-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Lien d'évitement : hors écran jusqu'au focus clavier. */
.sdz-skiplink {
  position: absolute;
  top: -100px;
  left: var(--sdz-space-4);
  z-index: var(--sdz-z-tooltip);
  padding: var(--sdz-space-3) var(--sdz-space-4);
  border-radius: 0 0 var(--sdz-radius-md) var(--sdz-radius-md);
  background-color: var(--sdz-primary);
  color: var(--sdz-text-on-primary);
  font-size: var(--sdz-font-size-sm);
  font-weight: var(--sdz-font-weight-semibold);
  text-decoration: none;
  transition: top var(--sdz-transition-fast);
}

.sdz-skiplink:focus {
  top: 0;
}
/* =============================================================
   SEARCH FIELD
   Champ de recherche avec icone et bouton de reinitialisation.
   Primitive generique : reutilisable par toute vue qui filtre une liste.
   ============================================================= */
.sdz-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.sdz-search__input {
  width: 100%;
  min-height: var(--sdz-control-height-lg);
  padding: var(--sdz-space-3) var(--sdz-space-4);
  padding-left: calc(var(--sdz-space-4) * 2 + var(--sdz-space-2));
  padding-right: calc(var(--sdz-space-4) * 2 + var(--sdz-space-2));
  border: 1px solid var(--sdz-border-strong);
  border-radius: var(--sdz-radius-md);
  background-color: var(--sdz-surface-sunken);
  color: var(--sdz-text);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-md);
  line-height: var(--sdz-line-height-normal);
  appearance: none;
}

.sdz-search__input::placeholder {
  color: var(--sdz-text-muted);
}

.sdz-search > .sdz-icon {
  position: absolute;
  left: var(--sdz-space-4);
  color: var(--sdz-text-muted);
  pointer-events: none;
}

.sdz-search__clear {
  position: absolute;
  right: var(--sdz-space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--sdz-control-height-sm);
  height: var(--sdz-control-height-sm);
  padding: 0;
  border: 0;
  border-radius: var(--sdz-radius-full);
  background-color: transparent;
  color: var(--sdz-text-muted);
  cursor: pointer;
}

.sdz-search__clear:hover {
  background-color: var(--sdz-surface-hover);
  color: var(--sdz-text);
}

/* =============================================================
   TABS / CHIPS FILTRANTS
   L'etat actif est signale par le fond, la bordure ET la
   typographie : jamais par la seule couleur (WCAG 1.4.1).
   ============================================================= */
.sdz-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sdz-space-2);
}

.sdz-tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sdz-space-2);
  min-height: var(--sdz-control-height-sm);
  padding: var(--sdz-space-1) var(--sdz-space-4);
  border: 1px solid var(--sdz-border);
  border-radius: var(--sdz-radius-full);
  background-color: var(--sdz-surface-2);
  color: var(--sdz-text-secondary);
  font-family: var(--sdz-font-body);
  font-size: var(--sdz-font-size-sm);
  font-weight: var(--sdz-font-weight-medium);
  line-height: var(--sdz-line-height-normal);
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color var(--sdz-transition-fast) var(--sdz-ease-standard),
    background-color var(--sdz-transition-fast) var(--sdz-ease-standard),
    color var(--sdz-transition-fast) var(--sdz-ease-standard);
}

.sdz-tabs__tab:hover {
  border-color: var(--sdz-border-strong);
  background-color: var(--sdz-surface-hover);
  color: var(--sdz-text);
}

.sdz-tabs__tab[aria-selected='true'],
.sdz-tabs__tab.is-active {
  border-color: var(--sdz-border-accent);
  background-color: var(--sdz-primary-subtle);
  color: var(--sdz-primary-text);
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-tabs__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0 var(--sdz-space-1);
  border-radius: var(--sdz-radius-full);
  background-color: var(--sdz-surface-active);
  color: var(--sdz-text-muted);
  font-size: var(--sdz-font-size-xs);
  font-weight: var(--sdz-font-weight-semibold);
}

.sdz-tabs__tab[aria-selected='true'] .sdz-tabs__count,
.sdz-tabs__tab.is-active .sdz-tabs__count {
  background-color: var(--sdz-accent-subtle);
  color: var(--sdz-primary-text);
}

/* Defilement horizontal propre sur mobile plutot qu'un retour a la ligne
   qui gonfle la hauteur de la page. */
@media (max-width: 640px) {
  .sdz-tabs--scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sdz-space-1);
  }

  .sdz-tabs--scroll::-webkit-scrollbar {
    display: none;
  }
}
