/* ============================================================================
   0. RESET CSS
   ============================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-end) 100%);
  min-height: 100vh;
}

/* ============================================================================
   ECHO-COMMON.CSS - Styles et variables partagés pour WAE
   ============================================================================
   
   Ce fichier DOIT être chargé EN PREMIER dans chaque page HTML.
   Il contient le reset CSS, les variables, et les composants partagés.
   
   Contenu:
   0. Reset CSS
   1. Variables CSS (:root)
      - Espacements, rayons, hauteurs
      - Couleurs (primaires, texte, bordures, fonds, sémantiques)
      - Couleurs d'actions et de chips
      - Z-index, transitions, icônes
   2. Layout (container, header, backdrop)
   3. Menu profil utilisateur
   4. Sections repliables (niveau 1)
   5. Sous-sections repliables (niveau 2)
   6. Modales custom
   7. Bouton retour
   8. Tooltips
   9. Toggle switch (style iOS)
   10. Zone subordonnée
   11. Styles brouillon/pending
   12. Classes utilitaires (.wae-*)
   
   Dernière mise à jour: Février 2025
   Nettoyage CSS: Phase 5 complétée
   
============================================================================ */

/* ============================================================================
   1. VARIABLES CSS
   ============================================================================ */

:root {
  /* ══════════════════════════════════════════════════════════════════════════
     1.1 ESPACEMENTS
     ══════════════════════════════════════════════════════════════════════════ */
  
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.2 RAYONS DE BORDURE
     ══════════════════════════════════════════════════════════════════════════ */
  
  --border-width-subtle: 1px;
  --border-width-interactive: 2px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.3 HAUTEURS STANDARDS
     ══════════════════════════════════════════════════════════════════════════ */
  
  
  --height-touch-target: 44px;
  --height-btn: 44px;
  
  /* Formes de boutons */
  --btn-padding-v: 6px;                     /* padding vertical cosmétique */
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.4 COULEURS — FONDAMENTALES (palette primaire)
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-primary: #667eea;
  --color-primary-dark: #5568d3;
  /* NOTE: --color-primary-end conservé malgré Phase 2 — utilisé pour le gradient body et les avatars.
     NE PAS utiliser pour les boutons d'action (voir Phase 2 BTN-01). */
  --color-primary-end: #764ba2;
  --color-primary-fond: #eef2ff;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.5 COULEURS — TEXTE
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-text-on-color: white;
  --color-text: #374151;
  --color-text-secondary: #6b7280;
  --color-text-placeholder: #999999;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.6 COULEURS — BORDURES
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-border: #d1d5db;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.7 COULEURS — FONDS
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-fond-subtle: #f5f5f5;
  --color-fond-disabled: #cccccc;
  --color-surface: white;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.8 COULEURS — SÉMANTIQUES (succès, erreur, warning)
     ══════════════════════════════════════════════════════════════════════════ */
  
  /* Positif (succès, oui, fait) */
  --color-positive: #059669;
  --color-positive-fond: #ecfdf5;
  
  /* Négatif (erreur, non, danger) */
  --color-negative: #dc2626;
  --color-negative-fond: #fef2f2;
  
  /* Warning */
  --color-warning: #ff9800;
  --color-warning-fond: #fff3e0;
  --color-warning-text: #e65100;
  
  /* Nuclear (sections très sensibles) */
  --color-nuclear-bg: #1a1a1a;
  --color-nuclear-accent: #4a0000;
  --color-nuclear-text: #ff4444;
  --color-nuclear-border: #000000;
  
  /* Événement (action, déclencheur) */
  --color-event: #f59e0b;
  --color-event-text: #92400e;
  --color-event-fond: #fef3c7;
  --color-event-border: #fcd34d;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.9 ICÔNES SÉMANTIQUES (couleurs des icônes de section/formulaire)
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-icon-scroll: #a0522d;       /* Parchemin — brun terre cuite */
  --color-icon-speaker: #ec5de0;      /* Speaker TTS — rose fuchsia */
  --color-icon-bell: #d4a017;         /* Cloche sonnerie — jaune doré */
  --color-icon-help: #5b9bd5;         /* Aide/info — bleu moyen */
  --icon-size-help: 20px;             /* Taille des icônes d'aide */
  
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.10 COULEURS DES CHIPS PAR TYPE
     ══════════════════════════════════════════════════════════════════════════ */
  
  /* Écho chaîné (violet) */
  --chip-echo-bg: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  --chip-echo-border: #d8b4fe;
  --chip-echo-text: #6b21a8;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.11 COULEURS LIENS ET AUTRES
     ══════════════════════════════════════════════════════════════════════════ */
  
  --color-link-on-dark: #8bb4ff;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.12 Z-INDEX ET HEADER
     ══════════════════════════════════════════════════════════════════════════ */
  
  --header-gradient: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.55) 100%
  );
  --header-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  --header-z-index: 1000;
  --backdrop-z-index: 999;
  --z-index-popup-overlay: 9998;
  --z-index-popup: 9999;
  --z-index-modal: 10003;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.13 TRANSITIONS
     ══════════════════════════════════════════════════════════════════════════ */
  
  --duration-fast: 0.2s;
  --duration-standard: 0.3s;
  --transition-fast: all var(--duration-fast);
  --transition-standard: all var(--duration-standard);
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.14 ICÔNES
     ══════════════════════════════════════════════════════════════════════════ */
  
  --lucide-icon-size: 16px;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.15 TYPOGRAPHIE
     ══════════════════════════════════════════════════════════════════════════ */
  
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-title: 22px;
  
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.16 BOUTONS FLOTTANTS (FAB)
     ══════════════════════════════════════════════════════════════════════════ */
  
  /* Sans unité — lu par JS via parseInt() pour attribut SVG size */
  --fab-icon-size: 42;
  --fab-size: 56px;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.17 OPACITÉ
     ══════════════════════════════════════════════════════════════════════════ */
  
  --opacity-disabled: 0.6;
  
  /* ══════════════════════════════════════════════════════════════════════════
     1.18 ANIMATIONS
     ══════════════════════════════════════════════════════════════════════════ */
  
  --pulse-scale: 1.03;
  --pulse-duration: 200ms;

  /* ══════════════════════════════════════════════════════════════════════════
     1.19 BREAKPOINTS (documentation)
     ══════════════════════════════════════════════════════════════════════════
     
     NOTE: Les media queries CSS ne supportent pas les variables CSS.
     Ces valeurs sont documentées ici comme référence. Utiliser ces valeurs
     exactes dans les @media queries pour garantir la cohérence.
     
     Mobile small:  max-width: 480px   (petits téléphones)
     Mobile:        max-width: 600px   (téléphones standards)  
     Desktop:       min-width: 769px   (tablettes et desktop)
     
  ══════════════════════════════════════════════════════════════════════════ */
}

/* ============================================================================
   ANIMATIONS GLOBALES
   ============================================================================ */

@keyframes waePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(var(--pulse-scale)); }
}

@keyframes fieldErrorFlash {
    0%, 40%, 80% { color: var(--color-negative); }
    20%, 60%, 100% { color: var(--color-text); }
}

.field-error-flash {
    animation: fieldErrorFlash 1.8s ease-in-out;
}

.wae-pulse {
    animation: waePulse var(--pulse-duration) ease-out;
}

/* ============================================================================
   ICÔNES LUCIDE
   ============================================================================ */

.lucide-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    width: var(--lucide-icon-size);
    height: var(--lucide-icon-size);
}

.section-title .lucide-icon {
    margin-right: 6px;
}

/* ============================================================================
   LAYOUT — CONTAINER
   ============================================================================ */

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-sm);
}

/* ============================================================================
   LAYOUT — HEADER BACKDROP
   ============================================================================ */

#header-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  z-index: var(--backdrop-z-index);
}

/* ============================================================================
   LAYOUT — PAGE HEADER
   ============================================================================ */

.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--header-gradient);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  box-shadow: var(--header-shadow);
  z-index: var(--header-z-index);
  padding: var(--space-sm);
  padding-bottom: var(--space-md);
}

/* ============================================================================
   TITRE ÉDITABLE INLINE
   ============================================================================ */

#page-title-input {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  text-align: center;
  outline: none;
  width: 100%;
  max-width: 70%;
}

#page-title-input::placeholder {
  color: var(--color-primary);
  opacity: 0.5;
}

/* ============================================================================
   MENU PROFIL UTILISATEUR
   ============================================================================ */

.user-profile-menu {
  position: absolute;
  top: 10px;
  right: 15px;
}

.profile-btn {
  width: var(--height-btn);
  height: var(--height-btn);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-end) 100%);
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: var(--color-text-on-color);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition-standard);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.profile-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.profile-btn:active {
  transform: scale(0.95);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 280px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: var(--transition-standard);
  z-index: var(--z-index-popup);
}

.profile-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.profile-header {
  padding: var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.profile-initial-large {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-end) 100%);
  color: var(--color-text-on-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
}

.profile-info {
  flex: 1;
}

.profile-username {
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-lg);
  color: var(--color-text);
}

.profile-email {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: 1px;
}

.profile-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xs) 0;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.2s ease;
  cursor: pointer;
}

.profile-menu-item:hover {
  background: var(--color-fond-subtle);
}

.profile-menu-item.logout {
  color: var(--color-negative);
}

.profile-menu-item.logout:hover {
  background: var(--color-negative-fond);
}

.profile-icon {
  font-size: var(--font-size-xl);
  width: var(--space-xl);
  text-align: center;
}

@media (max-width: 600px) {
  .user-profile-menu {
    right: 15px;
  }
  
  .profile-btn {
    width: var(--height-btn);
    height: var(--height-btn);
    font-size: var(--font-size-lg);
  }
  
  .profile-dropdown {
    width: 260px;
  }
}

/* Scroll padding pour compenser le header sticky lors de scrollIntoView() */
html {
  /* 88px = hauteur estimée du header sticky, 8px = marge de confort */
  scroll-padding-top: calc(88px + var(--space-sm));
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   2. SECTIONS REPLIABLES
   ============================================================================
   
   Structure HTML attendue:
   
   <div class="section-header" 
        data-section-id="unique-id"
        data-initial="open|collapsed"
        data-persist="true|false">
     <div class="section-title">📋 Titre</div>
     <div class="section-toggle">▼</div>
   </div>
   <div class="section-content">
     ... contenu ...
   </div>
   
   TECHNIQUE D'ANIMATION:
   - height contrôlé par JavaScript (pas CSS Grid qui casse scrollHeight)
   - scrollHeight reste fiable car pas de contrainte grid
   - Après transition: height: auto pour contenu dynamique
   - scrollIntoView() pour le scroll (fonctionne même si destination pas visible)
   
   GESTION DES COINS ARRONDIS:
   - Section dépliée: header = coins TOP, content = coins BOTTOM
   - Section pliée: header = TOUS les coins (boîte complète)
   
============================================================================ */

/* Wrapper de section - conteneur logique pour header + content */
.section-wrapper {
  /* Espacement entre les sections */
  margin-top: var(--space-xs);
}

/* Pas de marge sur le premier wrapper */
.section-wrapper:first-child {
  margin-top: 0;
}

/* Header de section - État DÉPLIÉ par défaut */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0 var(--space-md);
  min-height: var(--height-touch-target);
  cursor: pointer;
  background: var(--color-fond-subtle);
  border: 1px solid var(--color-fond-subtle);
  
  /* Coins arrondis TOP seulement quand déplié */
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  
  transition: background 0.3s, border-radius 0.3s;
  user-select: none;
}

.section-header:hover {
  background: var(--color-fond-subtle);
}

.section-header:active {
  background: var(--color-fond-subtle);
}

/* Icône aide "?" — réutilisable dans les section-headers, boutons, etc. */
.echo-help-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: var(--space-xs);
  cursor: pointer;
}

.echo-help-icon svg {
  width: var(--icon-size-help);
  height: var(--icon-size-help);
}

/* Header de section - État PLIÉ */
.section-header.collapsed {
  background: var(--color-fond-subtle);
  
  /* Tous les coins arrondis quand plié (boîte complète) */
  border-radius: var(--radius-md);
}

/* Variante danger (sections sensibles) */
.section-header.danger-section {
  border-color: var(--color-negative);
  background: var(--color-negative-fond);
}

.section-header.danger-section .section-title {
  color: var(--color-negative);
}

.section-header.danger-section.collapsed {
  background: var(--color-negative-fond);
}

/* Le content qui suit un danger-section doit avoir la même bordure */
.section-header.danger-section + .section-content {
  border-color: var(--color-negative);
}

.section-header.danger-section + .section-content.collapsed {
  border-color: transparent;
}

/* Variante nuclear (sections très sensibles) */
.section-header.nuclear-section {
  border-color: var(--color-nuclear-border);
  background: linear-gradient(135deg, var(--color-nuclear-bg) 0%, var(--color-nuclear-accent) 100%);
}

.section-header.nuclear-section .section-title {
  color: var(--color-nuclear-text);
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.section-header.nuclear-section .section-toggle {
  color: var(--color-nuclear-text);
}

/* EXCEPTION ACCEPTÉE — couleurs nuclear hors tokens (usage unique) */
.section-header.nuclear-section.collapsed {
  background: linear-gradient(135deg, #2a2a2a 0%, #5a0000 100%);
}

/* Le content qui suit un nuclear-section doit avoir la même bordure */
.section-header.nuclear-section + .section-content {
  border-color: var(--color-nuclear-border);
}

.section-header.nuclear-section + .section-content.collapsed {
  border-color: transparent;
}

/* Titre de section */
.section-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0; /* Permet le text-overflow */
}

/* Icône de toggle (flèche) */
.section-toggle {
  font-size: var(--font-size-xl);
  color: var(--color-text-placeholder);
  transition: transform 0.3s ease-out;
  flex-shrink: 0;
}

.section-header.collapsed .section-toggle {
  transform: rotate(-90deg);
}

/* Contenu de section - height contrôlé par JS */
.section-content {
  overflow: hidden;
  padding: var(--space-lg);
  background: var(--color-surface);
  
  /* Bordures pour continuité visuelle avec le header */
  border: 1px solid var(--color-fond-subtle);
  border-top: none;
  
  /* Coins arrondis BOTTOM seulement */
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  
  /* Animation de height - le JS va définir la valeur */
  transition: height 0.3s ease-out, padding 0.3s ease-out, border-color 0.3s ease-out;
}

/* Contenu de section - État FERMÉ */
.section-content.collapsed {
  height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  border: none;
  background: transparent;
}

/* ============================================================================
   3. MODALES CUSTOM
   ============================================================================
   
   Modales réutilisables pour les confirmations et alertes.
   Utilisées dans index.html et form.html via wae-common.js
   
============================================================================ */

.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-index-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.custom-modal.visible,
.custom-modal.custom-modal--visible,
.custom-modal.wae-modal-overlay--visible {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
      opacity: 0;
      transform: translateY(-20px) scale(0.95);
  }
  to {
      opacity: 1;
      transform: translateY(0) scale(1);
  }
}

/* EXCEPTION ACCEPTÉE — taille icône décorative hors échelle typographique */
.modal-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  text-align: center;
  margin-bottom: var(--space-md);
}

.modal-message {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: var(--space-xl);
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: var(--space-md);
}

.modal-btn {
  flex: 1;
  padding: var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-btn-cancel {
  background: var(--color-fond-subtle);
  color: var(--color-text-secondary);
}

.modal-btn-cancel:hover {
  background: var(--color-border);
}

.modal-btn-confirm {
  background: var(--color-primary);
  color: var(--color-text-on-color);
}

.modal-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* EXCEPTION ACCEPTÉE — #b91c1c = variante sombre de --color-negative pour gradient */
.modal-btn-confirm.danger {
  background: linear-gradient(135deg, var(--color-negative) 0%, #b91c1c 100%);
}

.modal-btn-confirm.danger:hover {
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

/* Container pour le champ de saisie (mode prompt) */
.modal-input-container {
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s;
}

.modal-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.modal-input::placeholder {
  color: var(--color-text-placeholder);
  font-style: italic;
}

/* ============================================================================
   4. BOUTON RETOUR
   ============================================================================ */

.btn-back {
  background: var(--color-primary);
  color: var(--color-text-on-color);
  border: none;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  /* EXCEPTION ACCEPTÉE — taille flèche retour hors échelle typographique */
  font-size: 28px;
  font-weight: var(--font-weight-bold);
  transition: var(--transition-standard);
  text-decoration: none;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-back:hover {
  filter: brightness(0.9);
}
/* ============================================================================
   4. INFO-BULLES (TOOLTIPS)
   ============================================================================ */

.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--color-border);
  color: var(--color-text-secondary);
  border-radius: 50%;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  margin-left: auto;
  margin-right: var(--space-sm);
  transition: background 0.2s, color 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.tooltip-trigger:hover {
  background: var(--color-primary);
  color: var(--color-text-on-color);
}

.tooltip-trigger.active {
  background: var(--color-primary);
  color: var(--color-text-on-color);
}

.tooltip-bubble {
  display: none;
  position: fixed;
  background: var(--color-text);
  color: var(--color-text-on-color);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: 1.4;
  z-index: var(--z-index-popup);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 280px;
  width: max-content;
}

.tooltip-bubble.show {
  display: block;
  animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-bubble a {
  color: var(--color-link-on-dark);
  text-decoration: none;
}

.tooltip-bubble a:hover {
  text-decoration: underline;
}
/* ============================================================================
   TEXTAREA AUTO-EXPANSIBLE
   Une ligne sans focus (comme un input text), multi-lignes avec focus.
   ============================================================================ */

textarea.auto-expand {
    overflow: hidden;
    line-height: 1.4;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-height: var(--height-btn);
    height: auto;
    padding: var(--space-sm) var(--space-md);
    /* Transition explicite — PAS 'all' pour éviter le flash white-space au focus */
    transition: border-color var(--duration-fast), color var(--duration-fast), height var(--duration-fast) ease-out;
}

textarea.auto-expand:focus {
    white-space: pre-wrap;
    word-wrap: break-word;
    text-overflow: clip;
}

/* ============================================================================
   7. STYLE "BROUILLON / À CRÉER" (éléments pas encore sauvegardés)
   ============================================================================ */
.draft-style-border {
    border: 2px dashed var(--color-warning) !important;
}

.draft-style-full {
    border: 2px dashed var(--color-warning) !important;
    background: var(--color-warning-fond) !important;
}

.draft-style-text {
    color: var(--color-warning-text);
}

/* ============================================================================
   8. CLASSES UTILITAIRES
   ============================================================================ */

/* Bouton d'action coloré */
.wae-action-btn {
  min-height: var(--height-touch-target);
  padding: 0 var(--space-md);
  border-radius: var(--radius-md);
  border: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-on-color);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wae-action-btn:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Icône ronde (wrapper) */
.wae-icon-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* État vide / chargement */
.wae-empty-state {
  text-align: center;
  padding: 40px 10px;
  color: var(--color-text-placeholder);
}

/* EXCEPTION ACCEPTÉE — taille icône décorative hors échelle typographique */
.wae-empty-state .icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ============================================================================
   9. FORMULAIRES — STYLES DE BASE
   ============================================================================ */

/* Groupe de champ */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group:last-child {
  margin-bottom: 0;
}

/* Labels */
/* GLOBAL — s'applique à tous les labels de WAE */
label {
  display: block;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-sm);
}

/* Inputs de base */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: var(--btn-padding-v) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  transition: var(--transition-standard);
  background: var(--color-surface);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-fond-disabled);
  cursor: not-allowed;
}

textarea {
  resize: none;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================================
   10. BOUTONS — STYLES DE BASE
   ============================================================================ */

.btn {
  background: var(--color-primary);
  color: var(--color-text-on-color);
  border: none;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-standard);
}

.btn:hover {
  filter: brightness(0.9);
}

.btn:disabled {
  background: var(--color-fond-disabled);
  cursor: not-allowed;
}

.btn--success {
  background: var(--color-positive);
}

/* ============================================================================
   SELECTOR TRIGGER (bouton qui ouvre WAESelector)
   ============================================================================ */

.wae-selector-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--btn-padding-v) var(--space-lg);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: left;
}

.wae-selector-trigger:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-fond);
}

.wae-selector-trigger:active {
  transform: scale(0.99);
}

.wae-selector-trigger:disabled {
  background: var(--color-fond-disabled);
  cursor: not-allowed;
  opacity: var(--opacity-disabled);
}

.wae-selector-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wae-selector-trigger-arrow {
  color: var(--color-text-placeholder);
  margin-left: 10px;
  font-size: var(--font-size-xs);
}

/* ============================================================================
   11. MESSAGES FEEDBACK
   ============================================================================ */

.error-message,
.success-message {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
  display: none;
}

.error-message {
  background: var(--color-negative-fond);
  color: var(--color-negative);
  border-left: 4px solid var(--color-negative);
}

.success-message {
  background: var(--color-positive-fond);
  color: var(--color-positive);
  border-left: 4px solid var(--color-positive);
}

.error-message.show,
.success-message.show {
  display: block;
}

/* ============================================================================
   12. LOADING / SPINNER
   ============================================================================ */

.loading {
  display: none;
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-secondary);
}

.loading.show {
  display: block;
}

.spinner {
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================================================
   CLASSES UTILITAIRES
   ============================================================================ */

.hidden {
  display: none !important; /* Utilitaire de visibilité — doit toujours gagner */
}

/* ============================================================================
   FIN DE ECHO-COMMON.CSS
   ============================================================================ */