/* ==========================================================================
   Comprendo - Layout & Ergonomie Optimisée (Compacte, Lisible & Sans Défilement Inutile)
   ========================================================================== */

/* Barre de navigation et en-tête compacte et élégante */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1.5px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.25rem;
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Onglets de mode intégrés dans l'en-tête (ne forment plus une énorme rangée) */
.nav-modes {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-panel-left);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.nav-tab {
  border: none;
  background: transparent;
  min-height: 32px;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  transition: all var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab:active {
  transform: scale(0.97);
}

.nav-tab.active {
  background: var(--bg-surface);
  color: #2563EB;
  box-shadow: var(--shadow-sm);
}

/* Profil élève, Ceinture et Étoiles */
.user-gamification {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.belt-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  min-height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  touch-action: manipulation;
}

.belt-pill:active {
  transform: scale(0.96);
}

.belt-color-indicator {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.stars-counter {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 800;
  color: #D97706;
  background: #FEF3C7;
  padding: 0.2rem 0.5rem;
  min-height: 32px;
  border-radius: var(--radius-full);
  border: 1.5px solid #FDE68A;
  font-size: 0.8rem;
}

/* Outils d'accessibilité rapide ultra-compacts */
.accessibility-bar {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-surface);
  border-left: 1.5px solid var(--border-color);
  padding-left: 0.35rem;
}

.accessibility-bar .btn {
  min-width: 30px;
  min-height: 30px;
  padding: 0.2rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  touch-action: manipulation;
}

/* ==========================================================================
   Conteneur principal & Agencement en 2 Colonnes (Dashboard)
   ========================================================================== */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 auto;
  padding: 0.65rem 0.85rem 1.25rem 0.85rem;
  box-sizing: border-box;
  gap: 0.65rem;
}

/* Agencement Côte-à-Côte par défaut : Consigne à gauche (40%), Étapes à droite (60%)
   Permet à l'élève de voir la consigne et l'étape d'aide en MÊME TEMPS sans aucun scroll */
.guided-training-layout {
  display: grid;
  grid-template-columns: minmax(320px, 40%) 1fr;
  gap: 0.85rem;
  width: 100%;
  align-items: start;
}

/* Colonne Gauche : Consigne Originale (Fixe et repère visuel) */
.panel-consigne {
  background: var(--bg-panel-left);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.panel-header-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px dashed var(--border-color);
  padding-bottom: 0.35rem;
}

.subject-tag {
  background: #EEF2FF;
  color: #4F46E5;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.consigne-type-tag {
  background: #F1F5F9;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-combinee {
  background: #FEF3C7;
  color: #B45309;
  border: 1px solid #FCD34D;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
}

/* Boîte de texte de la consigne avec mots interactifs cliquables */
.consigne-box {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: var(--font-size-consigne);
  line-height: var(--line-height-consigne);
  color: var(--text-main);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
  min-height: auto;
}

/* Barre d'outils d'assistance sous la consigne */
.consigne-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-color);
}

.consigne-toolbar .btn {
  min-height: 36px;
  font-size: 0.84rem;
  padding: 0.3rem 0.75rem;
}

/* Colonne Droite : Espace de réflexion cognitive pas-à-pas */
.panel-workspace {
  background: var(--bg-panel-right);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

/* Le fil d'Ariane des 5 étapes cognitives (Svelte & Tactile) */
.stepper-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  background: var(--bg-surface);
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  width: 100%;
  gap: 0.2rem;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
  min-height: 32px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.step-indicator:active {
  transform: scale(0.96);
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel-left);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.step-indicator.active {
  background: #EFF6FF;
  border: 1.5px solid #3B82F6;
  color: #1D4ED8;
}

.step-indicator.active .step-number {
  background: #2563EB;
  border-color: #2563EB;
  color: white;
  transform: scale(1.05);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.step-indicator.completed {
  background: #ECFDF5;
  border: 1.5px solid #10B981;
  color: #065F46;
}

.step-indicator.completed .step-number {
  background: #10B981;
  border-color: #10B981;
  color: white;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.step-divider {
  flex: 1;
  height: 2px;
  background: var(--border-color);
  margin: 0 0.15rem;
}

.step-divider.filled {
  background: #10B981;
}

/* Boîte cognitive centrale de l'étape active (Cadre actif avec focus sonar) */
.cognitive-card,
.active-frame {
  background: var(--bg-surface);
  border: 2px solid rgba(230, 57, 70, 0.45);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.35);
  animation: sonarPulse 2.8s infinite ease-in-out;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Effet sonar discret et apaisant pour canaliser l'attention visuelle */
@keyframes sonarPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.35);
    border-color: rgba(230, 57, 70, 0.6);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(230, 57, 70, 0);
    border-color: rgba(230, 57, 70, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.35);
    border-color: rgba(230, 57, 70, 0.6);
  }
}

.cognitive-question {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  padding-bottom: 0.4rem;
  border-bottom: 1.5px solid var(--border-color);
}

.cognitive-question-badge {
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.cognitive-instruction {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Zone d'action interactive */
.workspace-interactive-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  justify-content: center;
}

/* Pied de page de l'espace de travail */
.workspace-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.55rem;
  border-top: 1.5px solid var(--border-color);
}

.workspace-actions .btn {
  min-height: 38px;
  padding: 0.35rem 0.85rem;
  font-size: 0.88rem;
}

/* Modale de félicitations / niveau suivant */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.75rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 2.5px solid #10B981;
  animation: popSuccess 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ==========================================================================
   Adaptations Responsive pour Écrans Étroits (Tablette Portrait ≤ 840px)
   ========================================================================== */
@media (max-width: 840px) {
  .app-header {
    flex-wrap: wrap;
    padding: 0.3rem 0.5rem;
    gap: 0.35rem;
  }

  .nav-modes {
    width: 100%;
    order: 3;
    justify-content: space-between;
  }

  .nav-tab {
    flex: 1;
  }

  .guided-training-layout {
    grid-template-columns: 1fr;
    flex-direction: column;
    gap: 0.65rem;
  }

  .step-indicator:not(.active) span {
    display: none;
  }

  .step-indicator {
    padding: 0.2rem 0.35rem;
    font-size: 0.78rem;
  }

  .step-number {
    width: 22px;
    height: 22px;
    font-size: 0.72rem;
  }

  .brand-subtitle {
    display: none;
  }
}

/* ==========================================================================
   MODE FOCUS — Réduction maximale de la charge mentale
   ========================================================================== */
body.mode-focus .nav-modes,
body.mode-focus .brand-subtitle,
body.mode-focus .belt-pill,
body.mode-focus .stars-counter {
  display: none !important;
}

body.mode-focus .app-header {
  padding: 0.3rem 0.85rem;
  background: var(--bg-surface);
  border-bottom: 1.5px solid #2563EB;
}

body.mode-focus #btn-focus-toggle {
  background: #2563EB;
  color: white;
  border-color: #1D4ED8;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}