/**
 * CampusQCM Header & Footer — Premium SaaS Styles
 * Responsive Design System avec CSS Variables
 * 
 * @package CampusQCM
 * @version 4.0.0
 */

/* ========================================
   PREVIEW BANNER (Mode Aperçu Étudiant)
   Version compacte et discrète
======================================== */
.cq-preview-banner {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1350;
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  color: #1e1b4b;
  padding: 6px 16px;
  border-radius: 100px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3), 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: cq-preview-slide-in 0.3s ease-out;
}

@keyframes cq-preview-slide-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.cq-preview-banner__content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.cq-preview-banner__icon {
  font-size: 0.875rem;
}

.cq-preview-banner__text {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cq-preview-banner__text strong {
  font-weight: 700;
}

/* Masquer le texte secondaire sur petit écran */
.cq-preview-banner__text span:last-child {
  display: none;
}

@media (min-width: 640px) {
  .cq-preview-banner__text span:last-child {
    display: inline;
    opacity: 0.8;
  }
}

.cq-preview-banner__exit {
  background: rgba(30, 27, 75, 0.15);
  color: #1e1b4b;
  border: none;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.cq-preview-banner__exit:hover {
  background: rgba(30, 27, 75, 0.25);
}

/* Toast notification pour le switch */
.cq-preview-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 1350;
  background: #1e293b;
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.cq-preview-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.cq-preview-toast__content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.cq-preview-toast__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.cq-preview-toast__text h4 {
  margin: 0 0 4px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.cq-preview-toast__text p {
  margin: 0;
  font-size: 0.8125rem;
  opacity: 0.8;
  line-height: 1.4;
}

.cq-preview-toast__close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.cq-preview-toast__close:hover {
  color: white;
}

@media (max-width: 480px) {
  .cq-preview-banner {
    top: 4px;
    padding: 5px 12px;
    max-width: calc(100% - 16px);
  }

  .cq-preview-banner__content {
    font-size: 0.75rem;
    gap: 8px;
  }

  .cq-preview-toast {
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(100px);
    max-width: none;
  }

  .cq-preview-toast.is-visible {
    transform: translateX(0) translateY(0);
  }
}

/* ========================================
   CSS VARIABLES — PALETTES & THÈMES
======================================== */
:root {
  /* Palette par défaut : Violet Premium */
  --cq-accent: #6366f1;
  --cq-accent-alt: #8b5cf6;
  --cq-accent-soft: rgba(99, 102, 241, 0.15);
  --cq-accent-hover: #4f46e5;
  --cq-hero-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --cq-hero-shadow: 0 20px 60px rgba(99, 102, 241, 0.25);

  /* Couleurs de texte hero (défaut: blanc pour palettes colorées) */
  --cq-hero-text: #ffffff;
  --cq-hero-text-soft: rgba(255, 255, 255, 0.9);
  --cq-hero-badge-bg: rgba(255, 255, 255, 0.15);
  --cq-hero-badge-border: rgba(255, 255, 255, 0.2);

  /* Boutons CTA sur hero (défaut: fond blanc, texte accent) */
  --cq-cta-bg: #ffffff;
  --cq-cta-text: var(--cq-accent);
  --cq-cta-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  /* Couleurs de base */
  --cq-bg: #ffffff;
  --cq-bg-alt: #f8fafc;
  --cq-text: #1e293b;
  --cq-text-muted: #64748b;
  --cq-border: #e2e8f0;

  /* Header spécifique */
  --cq-header-bg: rgba(255, 255, 255, 0.92);
  --cq-header-border: rgba(226, 232, 240, 0.8);
  --cq-header-height: 96px;

  /* Footer spécifique */
  --cq-footer-bg: #0f172a;
  --cq-footer-text: #cbd5e1;
  --cq-footer-text-muted: #64748b;
  --cq-footer-border: #1e293b;

  /* Transitions */
  --cq-transition-fast: 150ms ease;
  --cq-transition: 250ms ease;
  --cq-transition-slow: 350ms ease;

  /* Ombres */
  --cq-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --cq-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --cq-shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);

  /* Z-index */
  --cq-z-header: 1100;
  --cq-z-dropdown: 1200;
  --cq-z-mobile: 1300;
  --cq-z-modal: 1400;
}

/* Palettes alternatives - Spécificité augmentée avec html pour override :root */
html[data-palette="blue"] {
  --cq-accent: #3b82f6;
  --cq-accent-alt: #06b6d4;
  --cq-accent-soft: rgba(59, 130, 246, 0.15);
  --cq-accent-hover: #2563eb;
  --cq-hero-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --cq-hero-shadow: 0 20px 60px rgba(59, 130, 246, 0.25);
}

html[data-palette="green"] {
  --cq-accent: #10b981;
  --cq-accent-alt: #34d399;
  --cq-accent-soft: rgba(16, 185, 129, 0.15);
  --cq-accent-hover: #059669;
  --cq-hero-gradient: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  --cq-hero-shadow: 0 20px 60px rgba(16, 185, 129, 0.25);
}

html[data-palette="rose"] {
  --cq-accent: #f43f5e;
  --cq-accent-alt: #fb7185;
  --cq-accent-soft: rgba(244, 63, 94, 0.15);
  --cq-accent-hover: #e11d48;
  --cq-hero-gradient: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
  --cq-hero-shadow: 0 20px 60px rgba(244, 63, 94, 0.25);
}

html[data-palette="amber"] {
  --cq-accent: #f59e0b;
  --cq-accent-alt: #fbbf24;
  --cq-accent-soft: rgba(245, 158, 11, 0.15);
  --cq-accent-hover: #d97706;
  --cq-hero-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --cq-hero-shadow: 0 20px 60px rgba(245, 158, 11, 0.25);
}

/* Palette Black : Hero sombre uniquement (page reste claire) */
/* Spécificité augmentée avec html pour override :root */
html[data-palette="black"] {
  /* Accent UI reste coloré (violet) pour lisibilité */
  --cq-accent: #6366f1;
  --cq-accent-alt: #8b5cf6;
  --cq-accent-soft: rgba(99, 102, 241, 0.15);
  --cq-accent-hover: #4f46e5;
  /* Hero sombre avec texte clair */
  --cq-hero-gradient: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --cq-hero-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --cq-hero-text: #f8fafc;
  --cq-hero-text-soft: rgba(248, 250, 252, 0.85);
  --cq-hero-badge-bg: rgba(255, 255, 255, 0.12);
  --cq-hero-badge-border: rgba(255, 255, 255, 0.2);
  /* Boutons CTA sur hero sombre : fond blanc, texte sombre */
  --cq-cta-bg: #ffffff;
  --cq-cta-text: #1e293b;
  --cq-cta-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Mode sombre */
body.qcm-dark,
[data-theme="dark"] {
  --cq-bg: #0f172a;
  --cq-bg-alt: #1e293b;
  --cq-text: #f1f5f9;
  --cq-text-muted: #94a3b8;
  --cq-border: #334155;

  --cq-header-bg: rgba(15, 23, 42, 0.95);
  --cq-header-border: rgba(51, 65, 85, 0.8);

  --cq-footer-bg: #020617;
  --cq-footer-text: #e2e8f0;
  --cq-footer-border: #1e293b;

  --cq-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --cq-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --cq-shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);

  /* Hero shadow : hérite de la palette (html[data-palette]) pour garder
     la lueur colorée en dark mode — pas de neutralisation ici */
}

/* ========================================
   HEADER — STRUCTURE PRINCIPALE
======================================== */
.cq-header {
  position: sticky;
  top: 0;
  z-index: var(--cq-z-header);
  height: var(--cq-header-height);
  background: var(--cq-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--cq-accent);
  box-shadow: var(--cq-shadow-sm);
  overflow: visible;
}

.cq-header__inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* ========================================
   HEADER V2 — ZONE GAUCHE (Logo + Rôle)
======================================== */
.cq-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cq-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--cq-text);
  flex-shrink: 0;
}

.cq-header__logo svg {
  display: block;
  width: 36px;
  height: 36px;
}

.cq-header__brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Badge Rôle Enseignant */
.cq-header__role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  background: var(--cq-accent-soft);
  color: var(--cq-accent);
  white-space: nowrap;
}

.cq-header__role-badge--teacher {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  color: var(--cq-accent);
}

body.qcm-dark .cq-header__role-badge--teacher {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
  color: #a5b4fc;
}

/* ========================================
   HEADER — NAVIGATION PRINCIPALE
======================================== */
.cq-header__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}

.cq-header__link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--cq-text-muted);
  text-decoration: none;
  border-radius: 8px;
  white-space: nowrap;
  transition: all var(--cq-transition-fast);
}

.cq-header__link:hover {
  color: var(--cq-text);
  background: var(--cq-accent-soft);
}

.cq-header__link.is-active {
  color: var(--cq-accent);
  background: var(--cq-accent-soft);
}

.cq-header__link-icon {
  font-size: 1rem;
}

/* ========================================
   HEADER — ZONE DROITE / ACTIONS
======================================== */
.cq-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Boutons icône */
.cq-header__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--cq-transition-fast);
  text-decoration: none;
}

.cq-header__btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--cq-bg-alt);
  color: var(--cq-text-muted);
  border-radius: 10px;
  border: 1.5px solid var(--cq-border);
  font-size: 1.25rem !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cq-header__btn--icon:hover {
  background: var(--cq-accent-soft);
  color: var(--cq-accent);
}

/* Palette toggle — montre la couleur accent active */
.cq-header__btn--palette {
  background: var(--cq-accent-soft);
  border-color: var(--cq-accent);
  color: var(--cq-accent);
}

.cq-header__btn--palette:hover {
  background: var(--cq-accent);
  color: #fff;
}

/* Emoji icônes — taille fiable tous navigateurs */
.cq-header__btn-icon {
  font-size: 1.25rem !important;
  line-height: 1;
}

/* WordPress emoji → img conversion : taille stable, pas de FOUC */
.cq-header__btn-icon img.emoji {
  width: 1.25rem !important;
  height: 1.25rem !important;
  vertical-align: -0.1em;
}

/* Gestion affichage icône thème */
.cq-header__btn-icon--dark {
  display: none;
}

/* ========================================
   HEADER V2 — INDICATEUR ACADÉMIQUE
======================================== */
.cq-header__academic {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--cq-text-muted);
}

.cq-header__btn-icon--light {
  display: block;
}

body.qcm-dark .cq-header__btn-icon--dark,
[data-theme="dark"] .cq-header__btn-icon--dark {
  display: block;
}

body.qcm-dark .cq-header__btn-icon--light,
[data-theme="dark"] .cq-header__btn-icon--light {
  display: none;
}

/* Boutons outline/solid */
.cq-header__btn--outline {
  background: transparent;
  color: var(--cq-text);
  border: 1.5px solid var(--cq-border);
}

.cq-header__btn--outline:hover {
  border-color: var(--cq-accent);
  color: var(--cq-accent);
}

.cq-header__btn--solid {
  background: linear-gradient(135deg, var(--cq-accent), var(--cq-accent-alt));
  color: white;
  border: none;
}

.cq-header__btn--solid:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ========================================
   HEADER — DROPDOWN MENUS
======================================== */
.cq-header__dropdown {
  position: relative;
}

.cq-header__dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 8px;
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 12px;
  box-shadow: var(--cq-shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--cq-transition-fast);
  z-index: var(--cq-z-dropdown);
}

.cq-header__dropdown.is-open .cq-header__dropdown-menu,
.cq-header__dropdown:focus-within .cq-header__dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Palette sélecteur — panneau externe (hors header) */
.cq-header__palette {
  position: fixed;
  top: 88px;
  right: 20px;
  min-width: auto;
  padding: 12px;
  display: flex;
  gap: 8px;
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 12px;
  box-shadow: var(--cq-shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--cq-transition-fast);
  z-index: calc(var(--cq-z-header) + 10);
}

.cq-header__palette.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.cq-palette__swatch {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--cq-transition-fast);
  overflow: hidden;
  background: none;
  box-sizing: border-box;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cq-palette__swatch span {
  display: block;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  border-radius: 50%;
}

.cq-palette__swatch:hover,
.cq-palette__swatch.is-active {
  border-color: var(--cq-text);
  transform: scale(1.15);
}

.cq-palette__swatch--sm {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
}

.cq-palette__swatch--sm span {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
}

.cq-palette__swatch[data-palette="violet"] span {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.cq-palette__swatch[data-palette="blue"] span {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}

.cq-palette__swatch[data-palette="green"] span {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.cq-palette__swatch[data-palette="rose"] span {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
}

.cq-palette__swatch[data-palette="amber"] span {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.cq-palette__swatch[data-palette="black"] span {
  background: linear-gradient(135deg, #18181b, #09090b);
}

/* Menu utilisateur */
.cq-header__user-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--cq-bg-alt);
  border: 1px solid var(--cq-border);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--cq-transition-fast);
}

.cq-header__user-toggle:hover {
  border-color: var(--cq-accent);
}

.cq-header__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--cq-accent-soft);
  flex-shrink: 0;
}

.cq-header__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Default avatar dark mode swap */
[data-theme="dark"] .cq-header__avatar-img--default {
  content: url('../images/default-avatar-dark.svg');
}

.cq-header__avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cq-accent), var(--cq-accent-alt));
  color: white;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cq-header__user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--cq-text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cq-header__chevron {
  color: var(--cq-text-muted);
  transition: transform var(--cq-transition-fast);
}

.cq-header__user.is-open .cq-header__chevron {
  transform: rotate(180deg);
}

.cq-header__user-menu {
  min-width: 240px;
}

/* ========================================
   HEADER V2 — EN-TÊTE MENU PROFIL
======================================== */
.cq-header__menu-header {
  padding: 12px;
  border-bottom: 1px solid var(--cq-border);
  margin-bottom: 6px;
}

.cq-header__menu-name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--cq-text);
  margin-bottom: 2px;
}

.cq-header__menu-role {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--cq-text-muted);
  margin-bottom: 4px;
}

.cq-header__menu-role--teacher {
  color: var(--cq-accent);
}

.cq-header__menu-context {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--cq-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.cq-header__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.9375rem;
  color: var(--cq-text);
  text-decoration: none;
  border-radius: 8px;
  transition: background var(--cq-transition-fast);
}

.cq-header__menu-item:hover {
  background: var(--cq-bg-alt);
}

.cq-header__menu-item--danger {
  color: #ef4444;
}

.cq-header__menu-item--danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Switch Mode (Enseignant -> Aperçu étudiant) */
.cq-header__menu-item--switch {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  background: color-mix(in srgb, var(--cq-accent) 10%, transparent);
  color: var(--cq-accent);
  border: 1px solid color-mix(in srgb, var(--cq-accent) 20%, transparent);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--cq-transition-fast);
}

.cq-header__menu-item--switch:hover {
  background: color-mix(in srgb, var(--cq-accent) 20%, transparent);
  border-color: var(--cq-accent);
}

.cq-header__menu-divider {
  height: 1px;
  background: var(--cq-border);
  margin: 6px 0;
}

/* Badge niveau */
.cq-header__level {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--cq-accent-soft);
  color: var(--cq-accent);
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 100px;
  text-decoration: none;
  transition: all var(--cq-transition-fast);
}

.cq-header__level:hover {
  background: var(--cq-accent);
  color: white;
}

.cq-header__level-icon {
  font-size: 0.875rem;
}

/* ========================================
   HEADER — BURGER MOBILE
======================================== */
.cq-header__burger {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.cq-header__burger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--cq-text);
  border-radius: 2px;
  transition: all var(--cq-transition-fast);
  transform-origin: center;
}

.cq-header__burger[aria-expanded="true"] .cq-header__burger-line:nth-child(1) {
  transform: rotate(45deg) translateY(7px);
}

.cq-header__burger[aria-expanded="true"] .cq-header__burger-line:nth-child(2) {
  opacity: 0;
}

.cq-header__burger[aria-expanded="true"] .cq-header__burger-line:nth-child(3) {
  transform: rotate(-45deg) translateY(-7px);
}

/* ========================================
   MOBILE MENU — DRAWER
======================================== */
.cq-mobile {
  position: fixed;
  inset: 0;
  z-index: var(--cq-z-mobile);
  visibility: hidden;
  pointer-events: none;
}

.cq-mobile[aria-hidden="false"],
.cq-mobile.is-open {
  visibility: visible;
  pointer-events: auto;
}

.cq-mobile__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--cq-transition);
}

.cq-mobile.is-open .cq-mobile__backdrop {
  opacity: 1;
}

.cq-mobile__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 360px;
  height: 100%;
  background: var(--cq-bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--cq-transition);
  overflow-y: auto;
}

.cq-mobile.is-open .cq-mobile__panel {
  transform: translateX(0);
}

.cq-mobile__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--cq-border);
  flex-shrink: 0;
}

.cq-mobile__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--cq-text);
}

.cq-mobile__close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--cq-text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--cq-transition-fast);
}

.cq-mobile__close:hover {
  background: var(--cq-bg-alt);
  color: var(--cq-text);
}

.cq-mobile__content {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}

/* User card mobile */
.cq-mobile__user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--cq-accent-soft);
  border-radius: 12px;
  margin-bottom: 16px;
}

.cq-mobile__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.cq-mobile__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Default avatar dark mode swap */
[data-theme="dark"] .cq-mobile__avatar-img--default {
  content: url('../images/default-avatar-dark.svg');
}

.cq-mobile__avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cq-accent), var(--cq-accent-alt));
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.cq-mobile__user-info {
  flex: 1;
  min-width: 0;
}

.cq-mobile__user-name {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--cq-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cq-mobile__user-level {
  display: block;
  font-size: 0.8125rem;
  color: var(--cq-accent);
  font-weight: 500;
}

/* Badge rôle enseignant mobile */
.cq-mobile__user-role {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cq-text-muted);
}

.cq-mobile__user-role--teacher {
  color: var(--cq-accent);
}

/* CTA Principal Mobile */
.cq-mobile__cta {
  margin-bottom: 20px;
}

.cq-mobile__cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--cq-accent), var(--cq-accent-alt));
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--cq-accent) 30%, transparent);
  transition: all var(--cq-transition-fast);
}

.cq-mobile__cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--cq-accent) 40%, transparent);
}

/* Sections mobile */
.cq-mobile__section {
  margin-bottom: 24px;
}

.cq-mobile__section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cq-text-muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

.cq-mobile__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cq-mobile__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--cq-text);
  text-decoration: none;
  border-radius: 10px;
  transition: background var(--cq-transition-fast);
  min-height: 44px;
  /* Touch target */
}

.cq-mobile__link:hover,
.cq-mobile__link:focus {
  background: var(--cq-bg-alt);
}

.cq-mobile__link--cta {
  background: linear-gradient(135deg, var(--cq-accent), var(--cq-accent-alt));
  color: white;
}

.cq-mobile__link--cta:hover {
  opacity: 0.95;
}

.cq-mobile__link--danger {
  color: #ef4444;
}

/* Préférences mobile */
.cq-mobile__prefs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cq-mobile__pref {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--cq-bg-alt);
  border-radius: 10px;
}

.cq-mobile__pref>span {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--cq-text);
}

.cq-mobile__theme-toggle {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
}

.cq-mobile__theme-icon--dark {
  display: none;
}

.cq-mobile__theme-icon--light {
  display: block;
}

body.qcm-dark .cq-mobile__theme-icon--dark {
  display: block;
}

body.qcm-dark .cq-mobile__theme-icon--light {
  display: none;
}

.cq-mobile__palette {
  display: flex;
  gap: 6px;
}

/* ========================================
   FOOTER — STRUCTURE PRINCIPALE
======================================== */
.cq-footer {
  background: var(--cq-footer-bg);
  color: var(--cq-footer-text);
}

.cq-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.cq-footer__main {
  padding: 60px 0 40px;
}

.cq-footer__main .cq-footer__inner {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, 1fr);
  gap: 40px;
}

/* Colonne marque */
.cq-footer__brand {
  padding-right: 40px;
}

.cq-footer__logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.cq-footer__logo svg {
  flex-shrink: 0;
}

.cq-footer__tagline {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--cq-footer-text, #cbd5e1);
  margin-bottom: 20px;
}

.cq-footer__social {
  display: flex;
  gap: 12px;
}

.cq-footer__social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--cq-footer-text);
  transition: all var(--cq-transition-fast);
}

.cq-footer__social-link:hover {
  background: var(--cq-accent);
  color: white;
}

/* Colonnes de liens */
.cq-footer__column {
  display: flex;
  flex-direction: column;
}

.cq-footer__column-toggle {
  display: none;
  /* Visible uniquement mobile */
  width: 100%;
  padding: 16px 0;
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--cq-footer-border);
}

.cq-footer__column-toggle svg {
  transition: transform var(--cq-transition-fast);
}

.cq-footer__column-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.cq-footer__column-toggle span {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
}

.cq-footer__nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
}

.cq-footer__nav a {
  font-size: 0.9375rem;
  color: var(--cq-footer-text-muted);
  text-decoration: none;
  transition: color var(--cq-transition-fast);
}

.cq-footer__nav a:hover {
  color: white;
}

/* Barre légale */
.cq-footer__legal {
  padding: 24px 0;
  border-top: 1px solid var(--cq-footer-border);
}

.cq-footer__legal .cq-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.cq-footer__copyright {
  font-size: 0.875rem;
  color: var(--cq-footer-text-muted);
}

.cq-footer__legal-nav {
  display: flex;
  gap: 24px;
}

.cq-footer__legal-nav a {
  font-size: 0.875rem;
  color: var(--cq-footer-text-muted);
  text-decoration: none;
  transition: color var(--cq-transition-fast);
}

.cq-footer__legal-nav a:hover {
  color: white;
}

/* ========================================
   MAIN CONTENT
======================================== */
.cq-main {
  min-height: calc(100vh - var(--cq-header-height) - 200px);
}

/* ========================================
   RESPONSIVE — LARGE (≥1440px)
======================================== */
@media (min-width: 1440px) {

  .cq-header__inner,
  .cq-footer__inner {
    padding: 0 40px;
  }

  .cq-header__link {
    padding: 10px 18px;
  }
}

/* ========================================
   RESPONSIVE — TABLETTE (768px - 1024px)
======================================== */
@media (max-width: 1024px) {
  .cq-header__nav {
    gap: 2px;
  }

  .cq-header__link {
    padding: 8px 10px;
    font-size: 0.875rem;
  }

  .cq-header__link-icon {
    display: none;
  }

  .cq-header__user-name {
    display: none;
  }

  .cq-footer__main .cq-footer__inner {
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
  }

  .cq-footer__brand {
    grid-column: 1 / -1;
    padding-right: 0;
    max-width: 400px;
  }
}

/* ========================================
   RESPONSIVE — MOBILE (<768px)
======================================== */
@media (max-width: 768px) {
  :root {
    --cq-header-height: 85px;
  }

  .cq-header__inner {
    padding: 0 16px;
  }

  /* Masquer navigation desktop */
  .cq-header__nav {
    display: none;
  }

  /* Masquer éléments desktop */
  .cq-header__btn--outline,
  .cq-header__btn--solid,
  .cq-header__level,
  .cq-header__user,
  .cq-header__role-badge {
    display: none;
  }

  /* Afficher burger */
  .cq-header__burger {
    display: flex;
  }

  /* Garder toggle thème + palette */
  .cq-header__actions {
    gap: 4px;
  }

  .cq-header__btn--icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.25rem !important;
  }

  .cq-header__btn-icon {
    font-size: 1.25rem !important;
  }

  .cq-header__btn-icon img.emoji {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }

  /* Footer mobile */
  .cq-footer__main {
    padding: 40px 0 32px;
  }

  .cq-footer__main .cq-footer__inner {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .cq-footer__brand {
    margin-bottom: 32px;
    text-align: center;
  }

  .cq-footer__social {
    justify-content: center;
  }

  /* Accordéons footer — SEO-safe: max-height au lieu de display:none
     pour garder les liens crawlables par Googlebot (mobile-first indexing) */
  .cq-footer__column-toggle {
    display: flex;
  }

  .cq-footer__nav {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  }

  .cq-footer__column-toggle[aria-expanded="true"]+.cq-footer__nav {
    max-height: 500px;
    overflow: visible;
    padding: 12px 0 20px;
    opacity: 1;
  }

  /* Légal mobile */
  .cq-footer__legal .cq-footer__inner {
    flex-direction: column;
    text-align: center;
  }

  .cq-footer__legal-nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
  }
}

/* ========================================
   RESPONSIVE — PETIT MOBILE (<480px)
======================================== */
@media (max-width: 480px) {
  .cq-header__brand-text {
    font-size: 1.125rem;
  }

  .cq-mobile__panel {
    max-width: 100%;
  }
}

/* ========================================
   ACCESSIBILITY — FOCUS VISIBLE
======================================== */
.cq-header__link:focus-visible,
.cq-header__btn:focus-visible,
.cq-header__user-toggle:focus-visible,
.cq-header__burger:focus-visible,
.cq-mobile__link:focus-visible,
.cq-mobile__close:focus-visible,
.cq-footer__nav a:focus-visible,
.cq-footer__column-toggle:focus-visible,
.cq-footer__social-link:focus-visible,
.cq-palette__swatch:focus-visible {
  outline: 2px solid var(--cq-accent);
  outline-offset: 2px;
}

/* Skip to content (accessibility) */
.cq-skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 12px 24px;
  background: var(--cq-accent);
  color: white;
  font-weight: 600;
  border-radius: 8px;
  z-index: 9999;
  text-decoration: none;
}

.cq-skip-link:focus {
  top: 16px;
}

/* Skip-to-content visible sur mobile pour accessibilité WCAG */
@media (max-width: 768px) {
  .cq-skip-link {
    /* Garde le comportement focus mais ne supprime plus complètement */
  }
}

/* Skip to content - classe alternative utilisée dans header.php */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 12px 24px;
  background: var(--cq-accent, #6366f1);
  color: white;
  font-weight: 600;
  border-radius: 8px;
  z-index: 9999;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-to-content:focus {
  top: 16px;
}

/* Skip-to-content mobile — garder accessible sur mobile */
@media (max-width: 768px) {
  .skip-to-content {
    /* Garde le comportement focus mais ne supprime plus complètement */
  }
}

/* ========================================
   WORDPRESS ADMIN BAR — Fix header gap
   Neutralise le margin-top ajouté par WordPress
   quand la barre d'administration est active
======================================== */
@media (max-width: 782px) {
  html.admin-bar {
    margin-top: 0 !important;
  }

  .admin-bar .cq-header {
    top: 0 !important;
  }

  /* Cacher la barre admin WP sur mobile pour éviter le gap */
  #wpadminbar {
    display: none !important;
  }
}

@media (min-width: 783px) {
  .admin-bar .cq-header {
    top: 32px;
  }
}