/**
 * STYLES.CSS - VERSION OPTIMISÉE
 * OmegApp Pro
 * 
 * Améliorations :
 * ✅ Transitions fluides pour le mode sombre
 * ✅ Boutons modales centrés
 * ✅ Responsive optimisé
 * ✅ Tous les styles nécessaires consolidés
 */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
  --blue: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --transition-speed: 0.3s;
}

/* ============================================
   TRANSITIONS GLOBALES (Mode sombre fluide)
   ============================================ */
* {
  transition: background-color var(--transition-speed) ease, 
              color var(--transition-speed) ease, 
              border-color var(--transition-speed) ease;
}

/* Désactiver transitions pendant le changement de thème */
body.theme-transitioning * {
  transition: none !important;
}

/* ============================================
   BASE
   ============================================ */
body {
  background: #eff6ff;
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
}

/* ============================================
   BLOCS DE CODE / ALGORITHMES
   ============================================ */
pre,
.algo-block {
  white-space: pre-wrap !important;
  word-wrap: break-word;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: #f1f5f9;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  border-left: 4px solid #3b82f6;
}

pre code,
.algo-block code {
  background: none;
  padding: 0;
}

.app { 
  min-height: 100vh; 
  display: flex; 
}

/* ============================================
   SIDEBAR
   ============================================ */
aside {
  width: 300px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,.06);
  padding: 24px;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  color: #1d4ed8;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-right: -8px;
  padding-right: 8px;
  min-height: 0; /* Important pour le scroll dans flexbox */
}

/* Scrollbar discrète pour la nav */
.nav::-webkit-scrollbar {
  width: 4px;
}
.nav::-webkit-scrollbar-track {
  background: transparent;
}
.nav::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.nav::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.nav button { 
  display: block; 
  width: 100%; 
  text-align: left; 
  padding: 10px 12px; 
  border-radius: 10px; 
  border: none; 
  background: transparent; 
  cursor: pointer; 
}

.nav button.active { 
  background: #dbeafe; 
  color: #1d4ed8; 
  font-weight: 700; 
}

.nav button:hover { 
  background: #f3f4f6; 
}

/* ============================================
   MAIN CONTENT
   ============================================ */
main { 
  flex: 1; 
}

/* ============================================
   HEADER
   ============================================ */
.header { 
  display: grid; 
  grid-template-columns: auto 1fr auto; 
  align-items: center; 
  padding: 24px; 
  gap: 16px; 
  row-gap: 12px; 
}

.header .h1 { 
  grid-column: 1; 
  grid-row: 1; 
  font-size: 28px; 
  font-weight: 900; 
  color: #1d4ed8; 
}

.header #toolbar { 
  grid-column: 2; 
  grid-row: 1; 
  display: flex; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: wrap; 
}

.header > div:last-child { 
  grid-column: 3; 
  grid-row: 1; 
  white-space: nowrap; 
}

/* ============================================
   UI COMPONENTS
   ============================================ */
.card { 
  background: #fff; 
  border-radius: 16px; 
  box-shadow: 0 10px 30px rgba(0,0,0,.06); 
  border: 1px solid #e5e7eb; 
}

.grid { 
  display: grid; 
  gap: 16px; 
  padding: 0 24px; 
}

.stats { 
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); 
  padding: 24px; 
}

.stat { 
  padding: 18px; 
}

/* ============================================
   BOUTONS
   ============================================ */
.btn { 
  padding: 8px 12px; 
  border-radius: 10px; 
  border: 1px solid var(--blue); 
  background: #fff; 
  color: #1d4ed8; 
  font-weight: 700; 
  cursor: pointer; 
  height: 36px; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn.primary { 
  background: var(--blue); 
  color: #fff; 
  border-color: var(--blue); 
}

.btn.light { 
  background: #f3f4f6; 
  color: #111827; 
  border-color: #e5e7eb; 
}

.btn.danger { 
  background: #ef4444; 
  border-color: #ef4444; 
  color: #fff; 
}

.btn.success { 
  background: #10b981; 
  border-color: #10b981; 
  color: #fff; 
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn.primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn.danger:hover:not(:disabled) {
  background: #dc2626;
}

/* ============================================
   FULLCALENDAR EVENTS (V6) - CORRIGÉ
   ============================================ */
/* Style global de la carte événement */
.fc-event { 
  border: none !important; 
  box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important; 
  border-radius: 4px !important; 
  cursor: pointer !important; /* Force le curseur main */
  margin-bottom: 2px !important;
  font-family: ui-sans-serif, system-ui, sans-serif !important;
  text-decoration: none !important; /* Enlève soulignement éventuel */
}

.fc-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
  z-index: 50 !important;
}

/* --- CONTENU INTERNE (Texte) --- */
/* On force la couleur du texte en GRIS FONCÉ pour qu'il soit visible */
.fc-content-custom {
  padding: 3px 5px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  color: #1f2937 !important; /* Gris très foncé */
  pointer-events: none; /* Laisse le clic passer à l'événement parent */
}

.fc-time {
  font-size: 11px;
  font-weight: 800;
  color: #111827 !important; /* Noir presque pur */
  margin-bottom: 1px;
}

.fc-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
  color: #1f2937 !important;
  white-space: normal; /* Permet au texte de revenir à la ligne */
}

.fc-desc {
  font-size: 10px;
  margin-top: 2px;
  color: #4b5563 !important; /* Gris moyen */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- COULEURS DE FOND --- */

/* 1. COURS (Par défaut) */
.fc-event.cours { 
  background-color: #ffffff !important; 
  border-left: 4px solid #3b82f6 !important; /* Barre Bleue */
}

/* Variante : Voiture */
.fc-event.cours.voiture { 
  background-color: #fef2f2 !important; /* Rouge très pâle pour lisibilité */
  border-left-color: #ef4444 !important; /* Barre Rouge */
}

/* Variante : Vélo */
.fc-event.cours.velo { 
  background-color: #eff6ff !important; /* Bleu très pâle */
  border-left-color: #3b82f6 !important; /* Barre Bleue */
}

/* 2. ÉVÉNEMENTS PERSO */
.fc-event.event {
  background-color: #f3f4f6 !important; /* Gris pâle */
  border-left: 4px solid #6b7280 !important;
}

.fc-event.event-rdv-medical { 
  background-color: #fffbeb !important; /* Jaune pâle */
  border-left-color: #f59e0b !important; 
} 

.fc-event.event-absence { 
  background-color: #f3f4f6 !important; 
  border-left-color: #9ca3af !important; 
  opacity: 0.7;
}

/* Force override FullCalendar text color defaults */
.fc-v-event .fc-event-main {
  color: #1f2937 !important;
}

/* --- 3. CONTENU INTERNE (Généré par planning-view.js) --- */
.fc-content-custom {
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: flex-start;
}

.fc-time {
  font-size: 0.75rem; /* 12px */
  font-weight: 700;
  margin-bottom: 2px;
  opacity: 0.8;
}

.fc-title {
  font-size: 0.85rem; /* 13-14px */
  font-weight: 600;
  line-height: 1.2;
}

.fc-desc {
  font-size: 0.7rem; /* 11px */
  margin-top: 2px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 4. AJUSTEMENT MODE SOMBRE --- */
@media (prefers-color-scheme: dark) {
  body.dark-mode .fc-event.cours { 
    background: #1f2937 !important; 
    color: #e5e7eb !important; 
  }
  /* On fonce les fonds pour que ça ne flash pas en mode sombre */
  body.dark-mode .fc-event.cours.voiture { background: #2d1b1b !important; } 
  body.dark-mode .fc-event.cours.velo { background: #1e293b !important; }
  
  /* Ajustements divers du calendrier en mode sombre */
  body.dark-mode .fc-time-grid .fc-slats td { border-color: #374151 !important; }
  body.dark-mode .fc-col-header-cell { background-color: #1f2937 !important; color: white; }
}

/* ============================================
   MODALES (Design 2025 - Glassmorphism léger)
   ============================================ */
.modal-overlay {
  position: fixed; 
  inset: 0;
  background: rgba(15, 23, 42, 0.4); /* Bleu nuit transparent */
  backdrop-filter: blur(4px);        /* Effet flou arrière-plan */
  display: flex; 
  align-items: center; 
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal { 
  background: #fff; 
  border-radius: 16px; 
  width: 100%;
  max-width: 820px; 
  max-height: 90vh; 
  display: flex; 
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
  transform: scale(1);
  animation: scaleIn 0.2s ease-out;
}

.modal-h { 
  padding: 20px 24px; 
  border-bottom: 1px solid #f1f5f9; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  background: #fff;
  border-radius: 16px 16px 0 0;
}

.modal-b { 
  padding: 24px; 
  overflow-y: auto; 
  flex: 1; 
}

.modal-f { 
  border-top: 1px solid #f1f5f9; 
  padding: 16px 24px; 
  background-color: #f8fafc;
  display: flex; 
  gap: 12px; 
  justify-content: flex-end; /* Boutons à droite par convention moderne */
  align-items: center;
  border-radius: 0 0 16px 16px;
}

/* Bouton de fermeture (X) */
.btn-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.btn-close:hover {
  background-color: #f1f5f9;
  color: #ef4444;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================
   FORMULAIRES
   ============================================ */
.field { 
  display: flex; 
  flex-direction: column; 
  margin-bottom: 10px; 
}

.field label { 
  font-size: 12px; 
  color: #6b7280; 
  margin-bottom: 4px; 
}

.input, select { 
  border: 1px solid #e5e7eb; 
  border-radius: 10px; 
  padding: 8px; 
}

.input:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.two { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 10px; 
}

/* ============================================
   SUGGESTIONS AUTOCOMPLETE
   ============================================ */
.suggest { 
  position: absolute; 
  background: #fff; 
  border: 1px solid #e5e7eb; 
  border-radius: 10px; 
  width: 100%; 
  max-height: 220px; 
  overflow: auto; 
  z-index: 3000; 
}

.suggest div { 
  padding: 8px 10px; 
  cursor: pointer; 
}

.suggest div:hover { 
  background: #eff6ff; 
}

/* ============================================
   BARRE DE RECHERCHE
   ============================================ */
.search-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding: 0 24px;
}

.search-input {
  flex: 1;
  min-width: 250px;
}

/* ============================================
   CARTES D'ENTITÉS (Élèves, Parents, etc.)
   ============================================ */
.entity-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
  cursor: pointer;
}

.entity-card:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  transform: translateY(-2px);
}

.entity-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}

.entity-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 4px;
  line-height: 1.3;
}

.entity-subtitle {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.4;
}

.entity-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.entity-info-row {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
}

.entity-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  white-space: nowrap;
}

/* ============================================
   GRILLE DE STATISTIQUES
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 0 24px;
}

.stat-item {
  text-align: center;
  padding: 16px 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
}

.stat-item:hover {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #1e40af;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ============================================
   ÉTAT VIDE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #9ca3af;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.loading-spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
}

/* ============================================
   TOOLTIPS
   ============================================ */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: #1f2937;
  color: white;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 6px;
}

[data-tooltip]:hover::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2937;
  z-index: 1000;
}

/* ============================================
   SCROLLBAR PERSONNALISÉE
   ============================================ */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.entity-card,
.stat-item {
  animation: fadeIn 0.3s ease-out;
}

/* ============================================
   MODE SOMBRE
   ============================================ */
@media (prefers-color-scheme: dark) {
  body.dark-mode { 
    background: #111827; 
    color: #f9fafb; 
  }
  
  body.dark-mode aside, 
  body.dark-mode .header, 
  body.dark-mode .card { 
    background: #1f2937; 
    border-color: #374151; 
  }
  
  body.dark-mode .modal { 
    background-color: #1f2937 !important; 
    color: #f9fafb !important; 
  }
  
  body.dark-mode .modal-h, 
  body.dark-mode .modal-f { 
    border-color: #374151 !important; 
    background: #1f2937 !important; 
  }
  
  body.dark-mode .input, 
  body.dark-mode select { 
    background: #374151 !important; 
    color: #f9fafb !important; 
    border-color: #4b5563 !important; 
  }
  
  body.dark-mode .input:focus,
  body.dark-mode select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
  }
  
  body.dark-mode .btn.light { 
    background-color: #4b5563 !important; 
    color: #f9fafb !important; 
    border-color: #6b7280 !important; 
  }
  
  /* Cartes en mode sombre */
  body.dark-mode .entity-card {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }

  body.dark-mode .entity-card:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
  }

  body.dark-mode .entity-title {
    color: #60a5fa;
  }

  body.dark-mode .entity-subtitle,
  body.dark-mode .entity-info-row {
    color: #9ca3af;
  }

  body.dark-mode .stat-item {
    background: #1f2937;
    border-color: #374151;
  }

  body.dark-mode .stat-value {
    color: #60a5fa;
  }

  body.dark-mode .entity-badge {
    background: #374151;
    color: #60a5fa;
  }

  body.dark-mode .empty-state {
    color: #6b7280;
  }
  
  /* Scrollbar en mode sombre */
  body.dark-mode ::-webkit-scrollbar-track {
    background: #1f2937;
  }

  body.dark-mode ::-webkit-scrollbar-thumb {
    background: #374151;
  }

  body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    width: 100%;
  }

  .entity-card {
    padding: 16px;
  }

  .entity-title {
    font-size: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }

  .stat-value {
    font-size: 24px;
  }

  .grid {
    padding: 0 16px;
  }
  
  /* ✅ AMÉLIORATION : Modales responsive */
  .modal-f {
    flex-direction: column;
  }
  
  .modal-f .btn {
    width: 100%;
  }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  /* ========== FORCER TOUTES LES COULEURS À L'IMPRESSION ========== */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Forcer les backgrounds Tailwind à s'imprimer */
  [class*="bg-"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Forcer les gradients à s'imprimer */
  [class*="from-"],
  [class*="to-"],
  [class*="gradient"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  .search-bar,
  .btn,
  aside {
    display: none !important;
  }

  .entity-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* ========== SVG IMPRESSION EXERCICES ========== */

  /* Forcer l'affichage des SVG à l'impression */
  svg {
    display: block !important;
    visibility: visible !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Préserver toutes les couleurs SVG */
  svg *,
  svg path,
  svg line,
  svg circle,
  svg rect,
  svg text,
  svg polygon,
  svg polyline {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    stroke: inherit !important;
    fill: inherit !important;
  }

  /* Container des SVG correction */
  .svg-correction-wrapper,
  .print-svg-visible,
  div[class*="flex justify-center"] {
    display: flex !important;
    visibility: visible !important;
    justify-content: center !important;
    page-break-inside: avoid !important;
  }

  /* Fond vert des corrections */
  .bg-green-50 {
    background-color: #f0fdf4 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Masquer les boutons lors de l'impression */
  button,
  .btn,
  [onclick*="toggle"],
  [onclick*="Modifier"],
  [onclick*="Supprimer"] {
    display: none !important;
  }

  /* ========== CERCLES TRIGONOMÉTRIQUES - IMPRESSION GRANDE TAILLE ========== */

  /* Conteneur des cercles trigo - page dédiée */
  .cercle-trigo-print {
    page-break-inside: avoid !important;
    page-break-before: always !important;
    margin: 0 !important;
    padding: 10px 0 !important;
    text-align: center !important;
    width: 100% !important;
    display: block !important;
    overflow: visible !important;
  }

  /* Premier cercle pas de saut avant */
  .cours-section:first-of-type .cercle-trigo-print {
    page-break-before: auto !important;
  }

  /* Forcer le conteneur flex à être block et centré */
  .cercle-trigo-print > .flex,
  .cercle-trigo-print > div.flex {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
  }

  /* SVG cercle trigo - FORCER GRANDE TAILLE avec transform */
  .cercle-svg-print {
    width: 100% !important;
    height: auto !important;
    max-width: 180mm !important;
    min-height: 500px !important;
    display: block !important;
    margin: 0 auto !important;
    transform: scale(1) !important;
  }

  /* SVG cercle angles associés */
  .cercle-angles-associes-print {
    max-width: 180mm !important;
    min-height: 520px !important;
  }

  /* S'assurer que le cours trigo affiche tout */
  .cours-trigo {
    overflow: visible !important;
  }

  /* ========== FICHE TRIGO COMPACTE - FORMAT A4 ========== */
  .fiche-trigo-print {
    width: 100% !important;
    max-width: 210mm !important;
    margin: 0 auto !important;
    padding: 5mm !important;
    font-size: 10px !important;
    page-break-inside: avoid !important;
  }

  .fiche-trigo-print * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Cercles côte à côte et centrés pour impression A4 */
  .fiche-trigo-print .flex.gap-2 {
    display: flex !important;
    gap: 3mm !important;
    justify-content: center !important;
    margin: 0 auto !important;
  }

  .fiche-trigo-print .flex-1 {
    flex: 0 0 auto !important;
  }

  /* Réduire encore les SVG pour A4 si nécessaire */
  .fiche-trigo-print svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Tableaux compacts */
  .fiche-trigo-print table {
    font-size: 9px !important;
  }

  .fiche-trigo-print th,
  .fiche-trigo-print td {
    padding: 1px 3px !important;
  }

  /* Éviter coupure des sections cours */
  .cours-section {
    page-break-inside: avoid !important;
  }

  /* ========== COURS 6EME ANGLES - IMPRESSION OPTIMISÉE ========== */

  /* Container principal du cours angles */
  .cours-6eme-angles {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Masquer complètement les boutons d'impression */
  .cours-6eme-angles .print\\:hidden,
  .cours-6eme-angles button {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* En-tête compact pour impression */
  .cours-6eme-angles > div:first-of-type {
    margin-bottom: 12px !important;
    padding: 10px !important;
  }

  .cours-6eme-angles h1 {
    font-size: 20px !important;
    margin-bottom: 2px !important;
  }

  /* Sections qui ne doivent pas être coupées */
  .cours-angles-section {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Saut de page avant la section 4 (complémentaires/supplémentaires) */
  .cours-angles-page-break {
    page-break-before: always !important;
    break-before: page !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* Réduire les marges entre sections pour mieux utiliser l'espace */
  .cours-6eme-angles .mb-6 {
    margin-bottom: 10px !important;
  }

  .cours-6eme-angles .mb-4 {
    margin-bottom: 8px !important;
  }

  .cours-6eme-angles .gap-4 {
    gap: 8px !important;
  }

  .cours-6eme-angles .gap-3 {
    gap: 6px !important;
  }

  .cours-6eme-angles .gap-2 {
    gap: 4px !important;
  }

  /* Padding réduit pour les blocs */
  .cours-6eme-angles .p-5 {
    padding: 12px !important;
  }

  .cours-6eme-angles .p-4 {
    padding: 10px !important;
  }

  .cours-6eme-angles .p-3 {
    padding: 8px !important;
  }

  .cours-6eme-angles .p-2 {
    padding: 6px !important;
  }

  /* Texte légèrement plus petit pour tout tenir */
  .cours-6eme-angles .text-xl {
    font-size: 16px !important;
  }

  .cours-6eme-angles .text-lg {
    font-size: 14px !important;
  }

  .cours-6eme-angles .text-sm {
    font-size: 11px !important;
  }

  .cours-6eme-angles .text-xs {
    font-size: 10px !important;
  }

  /* Garder les SVG bien visibles */
  .cours-6eme-angles svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Classification des angles - ajuster la grille pour impression */
  .cours-6eme-angles .grid-cols-5 {
    gap: 4px !important;
  }

  .cours-6eme-angles .grid-cols-5 > div {
    padding: 4px !important;
  }

  /* Section horloge - 4 colonnes compactes */
  .cours-6eme-angles .grid-cols-2.md\\:grid-cols-4 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }

  /* Forcer les couleurs de fond */
  .cours-6eme-angles [class*="bg-"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Éliminer la page vide en fin de document */
  .cours-6eme-angles {
    page-break-after: avoid !important;
  }

  /* Dernière section sans marge bottom */
  .cours-6eme-angles > .cours-angles-section:last-of-type {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Footer compact */
  .cours-6eme-angles > p:last-child {
    margin: 4px 0 0 0 !important;
    padding: 0 !important;
    page-break-after: avoid !important;
  }

  /* ========== COURS SUITES - FICHE 1 PAGE A4 ========== */

  /* Container principal suites - ULTRA COMPACT 1 PAGE */
  .fiche-suites-print {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 2mm !important;
    font-size: 8px !important;
    line-height: 1.15 !important;
    max-height: 260mm !important;
    overflow: hidden !important;
  }

  /* Masquer les boutons */
  .fiche-suites-print .print\\:hidden,
  .fiche-suites-print button {
    display: none !important;
  }

  /* Header gradient - compact */
  .fiche-suites-print .bg-gradient-to-r {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    padding: 5px 8px !important;
    margin-bottom: 4px !important;
  }

  .fiche-suites-print .bg-gradient-to-r h3 {
    font-size: 13px !important;
    margin: 0 !important;
  }

  .fiche-suites-print .bg-gradient-to-r .text-sm {
    font-size: 8px !important;
  }

  .fiche-suites-print .bg-gradient-to-r p {
    font-size: 8px !important;
    margin-top: 1px !important;
  }

  /* Grilles */
  .fiche-suites-print .grid-cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 4px !important;
  }

  .fiche-suites-print .grid-cols-3 {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3px !important;
  }

  /* Cartes principales arithmétique/géométrique */
  .fiche-suites-print .bg-purple-50,
  .fiche-suites-print .bg-indigo-50 {
    padding: 4px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Badges des titres */
  .fiche-suites-print .rounded-full {
    padding: 2px 6px !important;
    font-size: 8px !important;
  }

  /* Formules principales u_{n+1} = ... */
  .fiche-suites-print .text-lg {
    font-size: 10px !important;
  }

  /* Boîtes blanches internes */
  .fiche-suites-print .bg-white.rounded-lg {
    padding: 3px !important;
    margin-bottom: 3px !important;
  }

  /* Sous-sections avec border-left */
  .fiche-suites-print .border-l-4 {
    padding: 2px 4px !important;
  }

  .fiche-suites-print .border-l-4 .font-semibold,
  .fiche-suites-print .border-l-4 .font-bold {
    font-size: 7px !important;
  }

  .fiche-suites-print .border-l-4 .text-sm {
    font-size: 9px !important;
  }

  .fiche-suites-print .border-l-4 .text-xs {
    font-size: 7px !important;
  }

  /* Section formules centrales */
  .fiche-suites-print .from-blue-100 {
    padding: 4px !important;
    margin-bottom: 4px !important;
  }

  .fiche-suites-print .from-blue-100 .text-base {
    font-size: 9px !important;
  }

  /* Section sens de variation */
  .fiche-suites-print .bg-yellow-50 {
    padding: 4px !important;
    margin-bottom: 4px !important;
  }

  /* Section convergence/divergence */
  .fiche-suites-print .bg-green-50 {
    padding: 4px !important;
  }

  /* Graphiques */
  .fiche-suites-print .bg-gray-50 {
    padding: 3px !important;
  }

  .fiche-suites-print svg {
    max-height: 35px !important;
  }

  /* Marges générales ultra-réduites */
  .fiche-suites-print .mb-3 {
    margin-bottom: 4px !important;
  }

  .fiche-suites-print .mb-2 {
    margin-bottom: 3px !important;
  }

  .fiche-suites-print .mb-1 {
    margin-bottom: 2px !important;
  }

  .fiche-suites-print .mt-2 {
    margin-top: 3px !important;
  }

  .fiche-suites-print .gap-6 {
    gap: 12px !important;
  }

  .fiche-suites-print .gap-3 {
    gap: 4px !important;
  }

  .fiche-suites-print .gap-2 {
    gap: 3px !important;
  }

  .fiche-suites-print .space-y-2 > * + * {
    margin-top: 2px !important;
  }

  .fiche-suites-print .space-y-1 > * + * {
    margin-top: 1px !important;
  }

  /* Textes */
  .fiche-suites-print .text-base {
    font-size: 9px !important;
  }

  .fiche-suites-print .text-sm {
    font-size: 8px !important;
  }

  .fiche-suites-print .text-xs {
    font-size: 7px !important;
  }

  /* Préserver les couleurs */
  .fiche-suites-print .bg-green-50,
  .fiche-suites-print .bg-yellow-50,
  .fiche-suites-print .bg-blue-100,
  .fiche-suites-print .bg-white {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Éviter coupure de page */
  .fiche-suites-print {
    page-break-inside: avoid !important;
  }

  /* Graphiques */
  .fiche-suites-print .bg-gray-50 {
    padding: 6px !important;
  }

  .fiche-suites-print svg {
    max-height: 50px !important;
  }

  /* Marges générales réduites */
  .fiche-suites-print .mb-3 {
    margin-bottom: 6px !important;
  }

  .fiche-suites-print .mb-2 {
    margin-bottom: 4px !important;
  }

  .fiche-suites-print .mt-2 {
    margin-top: 4px !important;
  }

  .fiche-suites-print .gap-3 {
    gap: 6px !important;
  }

  .fiche-suites-print .gap-2 {
    gap: 4px !important;
  }

  .fiche-suites-print .space-y-2 > * + * {
    margin-top: 4px !important;
  }

  /* Textes */
  .fiche-suites-print .text-base {
    font-size: 11px !important;
  }

  .fiche-suites-print .text-sm {
    font-size: 10px !important;
  }

  .fiche-suites-print .text-xs {
    font-size: 8px !important;
  }

  /* Préserver les couleurs */
  .fiche-suites-print .bg-green-100,
  .fiche-suites-print .bg-blue-100,
  .fiche-suites-print .bg-orange-100,
  .fiche-suites-print .bg-red-100,
  .fiche-suites-print .bg-white {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .fiche-suites-compact .text-base {
    font-size: 11px !important;
  }

  .fiche-suites-compact .text-lg {
    font-size: 12px !important;
  }

  /* Tableau compact */
  .fiche-suites-compact table {
    font-size: 8px !important;
  }

  .fiche-suites-compact table th,
  .fiche-suites-compact table td {
    padding: 1px 2px !important;
  }

  /* SVG graphiques */
  .fiche-suites-compact svg {
    max-height: 30px !important;
    width: auto !important;
  }

  /* Forcer les couleurs */
  .fiche-suites-compact [class*="bg-"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Bordures visibles */
  .fiche-suites-compact [class*="border-"] {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Éviter saut de page */
  .fiche-suites-compact {
    page-break-inside: avoid !important;
    page-break-after: avoid !important;
  }

  /* Bordures fines pour impression */
  .fiche-suites-compact .border,
  .fiche-suites-compact .border-2 {
    border-width: 1px !important;
  }

  .fiche-suites-compact .rounded,
  .fiche-suites-compact .rounded-lg {
    border-radius: 3px !important;
  }

  /* Forcer la page à ne pas réduire les SVG */
  @page {
    size: A4;
    margin: 10mm;
  }
}

/* ============================================
   BOUTONS MODALES HARMONISÉS (NOUVEAU)
   ============================================ */

/* Bouton Supprimer "Doux" (Fond rouge pâle, texte rouge) */
.btn-danger-soft {
  background-color: #fef2f2;
  color: #ef4444;
  border: 1px solid transparent;
  padding: 8px 12px; /* Assure un padding correct */
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn-danger-soft:hover {
  background-color: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* Bouton Primaire (Bleu solide) */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  color: white;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* Bouton Annuler spécifique pour la modale */
.btn-cancel-modal {
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
}
.btn-cancel-modal:hover {
  background-color: #f3f4f6;
  color: #111827;
}

/* Correction FORCEE pour aligner les boutons (Gauche / Droite) */
.modal-f {
  display: flex !important;
  justify-content: space-between !important; /* Ecarte : Supprimer à gauche <-> Reste à droite */
  align-items: center !important;
  flex-direction: row !important; /* Force la ligne même si le responsive veut une colonne */
  gap: 10px;
}

       /* ====================================
   TOOLTIPS POUR LES BOUTONS DE DEVIS
   ==================================== */

.btn-with-tooltip {
    position: relative;
    cursor: pointer;
}

.btn-with-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background-color: #1f2937;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-with-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-2px);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.btn-with-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-12px);
}

.btn-with-tooltip:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
}

.btn-with-tooltip:hover {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* ============================================
   ♿ ACCESSIBILITÉ - FOCUS VISIBLE
   ============================================ */

/* Style de focus visible pour navigation clavier */
.focus-visible-ring:focus {
  outline: none;
}

.focus-visible-ring:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Focus spécifique pour les boutons */
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Focus pour les inputs */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Skip link pour accessibilité clavier (caché visuellement sauf au focus) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #3b82f6;
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: bold;
  border-radius: 0 0 8px 0;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* Animation subtile pour indiquer le focus */
@keyframes focus-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.1); }
}

.btn:focus-visible {
  animation: focus-pulse 1.5s ease-in-out infinite;
}

/* ============================================
   📱 AMÉLIORATIONS MOBILE
   ============================================ */

/* Modales responsives sur mobile */
@media (max-width: 768px) {
  .modal-overlay .modal {
    max-width: 95vw !important;
    width: 95vw !important;
    margin: 10px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-h {
    padding: 16px !important;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
  }

  .modal-b {
    padding: 16px !important;
  }

  .modal-f {
    padding: 16px !important;
    position: sticky;
    bottom: 0;
    background: inherit;
    border-top: 1px solid #e5e7eb;
  }

  /* Formulaires en colonnes sur mobile */
  .modal .two,
  .modal .grid-cols-2 {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Tables scrollables horizontalement */
  .card table,
  table.w-full {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Boutons tactiles - Taille minimum 44px (Apple HIG) */
@media (max-width: 768px) {
  .btn,
  button,
  .nav button,
  select,
  input[type="submit"],
  input[type="button"] {
    min-height: 44px !important;
    min-width: 44px;
    padding: 12px 16px !important;
    font-size: 16px !important; /* Évite le zoom sur iOS */
  }

  /* Inputs plus grands sur mobile */
  .input,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="tel"],
  select,
  textarea {
    min-height: 44px !important;
    padding: 12px !important;
    font-size: 16px !important; /* Évite le zoom automatique sur iOS */
  }

  /* Espacements tactiles */
  .nav button {
    margin-bottom: 4px;
  }

  /* Actions des tableaux */
  .btn.text-xs {
    min-height: 36px !important;
    padding: 8px 12px !important;
  }
}

/* Petit écran (iPhone SE, etc.) */
@media (max-width: 375px) {
  .modal-overlay .modal {
    max-width: 100vw !important;
    width: 100vw !important;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }

  .header {
    padding: 12px !important;
    flex-direction: column;
    gap: 8px;
  }

  .header .h1 {
    font-size: 20px !important;
  }

  /* Stats en colonne unique */
  .stats,
  .grid.stats {
    grid-template-columns: 1fr !important;
  }
}

/* Animation pour le spinner des boutons */
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: btn-spin 1s linear infinite;
  display: inline-block;
}

/* ============================================
   🔧 LOGGER - Styles pour console customisée
   ============================================ */

/* Badge de version dans le coin */
.app-version-badge {
  position: fixed;
  bottom: 10px;
  left: 10px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: monospace;
  z-index: 9999;
  pointer-events: none;
}

/* ============================================
   📐 MATH - Styles pour affichage mathématique
   ============================================ */

/* Fractions inline avec barre horizontale */
.math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 3px;
  line-height: 1.1;
  text-align: center;
}

/* Numérateur */
.math-frac .num,
.math-frac sup {
  border-bottom: 1.5px solid currentColor;
  padding: 0 3px 2px 3px;
  font-size: 0.9em;
  display: block;
}

/* Dénominateur */
.math-frac .den,
.math-frac sub {
  padding: 2px 3px 0 3px;
  font-size: 0.9em;
  display: block;
}

/* Ajustement pour les fractions dans les options QCM */
.qcm-option .math-frac {
  font-size: 0.95em;
}

/* Exposants bien visibles */
sup {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
}

/* QCM - Amélioration de l'affichage des formules */
.qcm-question {
  font-size: 1.1rem;
  line-height: 1.8;
}

.qcm-question sup,
.qcm-answer sup {
  font-size: 0.7em;
  font-weight: 600;
}

/* Dark mode pour les maths */
.dark .math-frac .num,
.dark .math-frac sup {
  border-color: #e5e7eb;
}

/* ============================================
   EXERCICES MATHÉMATIQUES - STYLE MATHJAX
   ============================================ */

/* Conteneur d'exercice avec MathJax */
.exercice-card {
  font-family: 'Source Sans Pro', 'Segoe UI', system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.75;
}

/* Énoncé des exercices */
.exercice-card .text-gray-700 {
  font-size: 1.08rem;
  line-height: 1.85;
  color: #374151;
}

/* Correction des exercices */
.exercice-card details .bg-orange-50 {
  font-size: 1.05rem;
  line-height: 1.9;
}

/* Ajustement MathJax inline */
.exercice-card .MathJax {
  font-size: 1.1em !important;
}

/* Ajustement MathJax display (formules centrées) */
.exercice-card mjx-container[display="true"] {
  margin: 0.8em 0 !important;
  font-size: 1.15em !important;
}

/* Style pour les boîtes de résultats */
.exercice-card mjx-mstyle[mathvariant="bold"] {
  color: #c2410c;
}

/* Puces et numérotation */
.exercice-card .correction-step {
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 3px solid #fb923c;
}

/* Titres des parties de correction */
.exercice-card strong {
  color: #c2410c;
  font-weight: 700;
}

/* Style des listes dans les exercices */
.exercice-card ol,
.exercice-card ul {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.exercice-card li {
  margin-bottom: 0.4rem;
}

/* Amélioration visuelle des calculs étape par étape */
.exercice-card .math-step {
  display: block;
  margin: 0.3rem 0;
  padding-left: 1rem;
}

/* Résultats encadrés MathJax - couleur orange */
.exercice-card mjx-mrow mjx-menclose {
  border-color: #ea580c !important;
}

/* Espacement après les formules display */
.exercice-card br + mjx-container[display="true"],
mjx-container[display="true"] + br {
  margin-top: 0.5rem;
}

/* Dark mode pour exercices */
.dark .exercice-card .text-gray-700 {
  color: #e5e7eb;
}

.dark .exercice-card strong {
  color: #fb923c;
}

.dark .exercice-card .bg-orange-50 {
  background: rgba(251, 146, 60, 0.1) !important;
}

.dark .exercice-card mjx-menclose {
  border-color: #fb923c !important;
}

/* Tableaux dans les exercices - réduction des marges */
.exercice-card table {
  margin: 8px 0 !important;
  display: table;
}

/* Réduire l'espace avant/après les tableaux dans les énoncés */
.exercice-card br + table,
.text-gray-600 br + table,
.text-gray-700 br + table {
  margin-top: 4px !important;
}

/* Classe text-gray-600/text-gray-700 : réduire les marges pour les tableaux */
.text-gray-600 table,
.text-gray-700 table {
  margin: 8px 0 !important;
}

/* Forcer les tableaux à ne pas avoir d'espaces blancs parasites */
.exercice-card table,
.text-gray-600 table,
.text-gray-700 table {
  border-spacing: 0;
  empty-cells: show;
}

/* Supprimer les marges ajoutées par MathJax avant les tableaux */
.exercice-card mjx-container + table,
.text-gray-600 mjx-container + table,
.text-gray-700 mjx-container + table {
  margin-top: 8px !important;
}

/* ============================================
   TABLEAUX LARGES (Traces d'algorithme, etc.)
   ============================================ */

/* Container scrollable pour tableaux larges */
.exercice-card .table-wrapper,
.correction-content .table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  margin: 8px 0;
}

/* Tableaux de trace d'algorithme - optimisés */
.exercice-card table,
.correction-content table {
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
  width: auto;
  min-width: auto;
  max-width: 100%;
}

/* Cellules compactes pour tableaux larges */
.exercice-card table td,
.exercice-card table th,
.correction-content table td,
.correction-content table th {
  padding: 4px 8px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* En-têtes de tableau - style distinctif */
.exercice-card table th,
.correction-content table th {
  background: linear-gradient(135deg, #4f7df3 0%, #3b5de7 100%);
  color: white;
  font-weight: 600;
  text-align: center;
  padding: 6px 10px;
}

/* Lignes alternées pour lisibilité */
.exercice-card table tr:nth-child(even),
.correction-content table tr:nth-child(even) {
  background-color: #f8fafc;
}

/* Bordures subtiles */
.exercice-card table td,
.exercice-card table th,
.correction-content table td,
.correction-content table th {
  border: 1px solid #e2e8f0;
}

/* Première colonne (labels) - style distinct */
.exercice-card table td:first-child,
.correction-content table td:first-child {
  font-weight: 600;
  background-color: #f1f5f9;
  color: #475569;
  text-align: center;
  min-width: 50px;
}

/* Dark mode pour tableaux */
.dark .exercice-card table th,
.dark .correction-content table th {
  background: linear-gradient(135deg, #4f7df3 0%, #3b5de7 100%);
}

.dark .exercice-card table tr:nth-child(even),
.dark .correction-content table tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.05);
}

.dark .exercice-card table td:first-child,
.dark .correction-content table td:first-child {
  background-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.dark .exercice-card table td,
.dark .exercice-card table th,
.dark .correction-content table td,
.dark .correction-content table th {
  border-color: #475569;
}

/* ============================================
   AMÉLIORATION MISE EN FORME ÉNONCÉS
   ============================================ */

/* Énoncé des exercices - aération */
.exercice-enonce {
  line-height: 1.8;
}

/* Paragraphes dans l'énoncé */
.exercice-enonce p {
  margin-bottom: 0.5rem;
}

/* Transformer les <br> consécutifs en petit espace vertical */
.exercice-enonce br + br {
  display: block;
  content: "";
  margin-top: 0.3rem;
}

/* Réduire l'espace avant les tableaux */
.exercice-enonce table {
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
}

/* Supprimer les <br> juste avant les tableaux */
.exercice-enonce br + table,
.exercice-enonce br + br + table {
  margin-top: 0.25rem !important;
}

/* Masquer les paragraphes vides avant les tableaux */
.exercice-enonce p:empty {
  display: none;
}

/* Supprimer la marge des paragraphes qui précèdent un tableau */
.exercice-enonce p:has(+ table),
.exercice-enonce p.before-table,
.exercice-enonce .before-table {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

/* Réduire l'espace des tableaux qui suivent un paragraphe */
.exercice-enonce p + table {
  margin-top: 0.5rem !important;
}

/* Espacement des listes à puces dans les énoncés */
.exercice-enonce p[class*="ml-4"] {
  margin-top: 0.4rem;
  margin-bottom: 0.2rem;
}

/* Les formules MathJax display ne doivent pas créer trop d'espace */
.exercice-enonce mjx-container[display="true"] {
  margin: 0.5em 0 !important;
}

/* Espace minimal entre les éléments */
.exercice-enonce > * + * {
  margin-top: 0.4rem;
}

/* Container SVG dans l'énoncé - espace réduit */
.exercice-enonce + .mt-3,
.exercice-enonce + div[class*="flex justify-center"] {
  margin-top: 0.75rem !important;
}

/* ============================================
   TOOLTIPS ÉLÉGANTS
   ============================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 9999;
}

/* Bulle du tooltip */
[data-tooltip]::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 8px 12px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Flèche du tooltip */
[data-tooltip]::after {
  content: '';
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: #334155;
}

/* Afficher au survol */
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Variante tooltip en bas */
[data-tooltip-bottom]::before {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-bottom]::after {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #334155;
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-bottom]:hover::before,
[data-tooltip-bottom]:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   BLOCS DE CODE PYTHON (QCM Suites)
   ============================================ */
.python-code-block,
code.python-code-block,
pre.python-code-block {
  background: #e2e8f0 !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
  font-size: 0.9em !important;
  margin: 0 !important;
  white-space: nowrap !important;
  text-align: left !important;
  color: #1e293b !important;
  display: inline-block !important;
  line-height: 1.4;
}

/* Assurer que le code est lisible même dans les boutons colorés */
.qcm-option-suites .python-code-block,
button .python-code-block,
.border-green-500 .python-code-block,
.border-red-500 .python-code-block,
.bg-green-50 .python-code-block,
.bg-red-50 .python-code-block {
  background: #e2e8f0 !important;
  color: #1e293b !important;
}

/* ============================================
   PASS MODULE - FICHES DE COURS
   ============================================ */

/* Onglets QCM/Fiches */
.pass-chapitre-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0;
  margin-bottom: 1.5rem;
}

.pass-tab {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem 0.5rem 0 0;
  font-weight: 600;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  position: relative;
  bottom: -2px;
}

.pass-tab:not(.active) {
  background: #f3f4f6;
  color: #6b7280;
}

.pass-tab:not(.active):hover {
  background: #e5e7eb;
  color: #374151;
}

.pass-tab.active {
  background: #0d9488;
  color: white;
  border-bottom: 2px solid #0d9488;
}

/* Grille de fiches */
.pass-fiches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Cartes fiches */
.pass-fiche-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 4px solid #4CAF50;
}

.pass-fiche-card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.pass-fiche-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

/* Contenu des fiches */
.pass-fiche-body {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  padding: 2rem;
}

.pass-fiche-content {
  line-height: 1.8;
  color: #374151;
}

.pass-fiche-content h1,
.pass-fiche-content h2,
.pass-fiche-content h3,
.pass-fiche-content h4 {
  color: #1f2937;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.pass-fiche-content h2 {
  font-size: 1.5rem;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.pass-fiche-content h3 {
  font-size: 1.25rem;
  color: #0d9488;
}

.pass-fiche-content p {
  margin-bottom: 1rem;
}

.pass-fiche-content ul,
.pass-fiche-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.pass-fiche-content li {
  margin-bottom: 0.5rem;
}

/* Box Formule (bleu/violet) */
.pass-formule-box {
  background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
  border: 2px solid #a78bfa;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-formule-box::before {
  content: '📐 Formule';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #8b5cf6;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

.pass-formule-box .formula {
  font-size: 1.1rem;
  text-align: center;
  padding: 0.5rem;
}

/* Box Définition (vert) */
.pass-definition-box {
  background: linear-gradient(135deg, #d1fae5 0%, #dcfce7 100%);
  border: 2px solid #34d399;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-definition-box::before {
  content: '📖 Définition';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #10b981;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

/* Box Exemple (bleu clair) */
.pass-exemple-box {
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  border: 2px solid #60a5fa;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-exemple-box::before {
  content: '💡 Exemple';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #3b82f6;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

/* Box Attention (orange/jaune) */
.pass-attention-box {
  background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
  border: 2px solid #fbbf24;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-attention-box::before {
  content: '⚠️ Attention';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #f59e0b;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

/* Box Propriété (rose) */
.pass-propriete-box {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  border: 2px solid #f472b6;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-propriete-box::before {
  content: '✨ Propriété';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #ec4899;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

/* Box Théorème (teal) */
.pass-theoreme-box {
  background: linear-gradient(135deg, #ccfbf1 0%, #cffafe 100%);
  border: 2px solid #2dd4bf;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 1.5rem 0;
  position: relative;
}

.pass-theoreme-box::before {
  content: '📜 Théorème';
  position: absolute;
  top: -12px;
  left: 16px;
  background: #14b8a6;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
}

/* Espacement pour les labels des box */
.pass-formule-box,
.pass-definition-box,
.pass-exemple-box,
.pass-attention-box,
.pass-propriete-box,
.pass-theoreme-box {
  padding-top: 1.75rem;
}

/* Note: Les styles d'impression pour cercles trigo sont dans le bloc @media print principal (lignes 968-1016) */
