/* ==========================================================================
   MATHS CPGE MP - DESIGN SYSTEM & FEUILLE DE STYLE MODERNE
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Palette Principale */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-focus: rgba(37, 99, 235, 0.15);
  
  --secondary: #475569;
  --secondary-light: #f1f5f9;
  
  /* Statuts */
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0284c7;
  --info-light: #f0f9ff;

  /* Surfaces & Fonds */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  
  /* Bordures */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  
  /* Textes */
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  /* Ombres */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  
  /* Typographie & Rayons */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   1. RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-body);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* --------------------------------------------------------------------------
   2. HEADER & NAVIGATION
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-main);
  text-decoration: none;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--secondary);
  font-weight: 500;
  font-size: 0.93rem;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
}

.user-avatar-mini {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   3. CONTENEURS & DISPOSITION
   -------------------------------------------------------------------------- */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 20px 60px 20px;
}

.page-header {
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   4. BOUTONS & COMPOSANTS INTERACTIFS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  user-select: none;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: white;
  box-shadow: 0 4px 6px rgba(30, 64, 175, 0.3);
}

.btn-secondary {
  background: white;
  border-color: var(--border-strong);
  color: var(--text-body);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
}
.btn-success:hover {
  background: #15803d;
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover {
  background: #b45309;
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b91c1c;
  color: white;
}

.btn-indigo {
  background: #6366f1;
  color: white;
}
.btn-indigo:hover {
  background: #4f46e5;
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-action-parcours {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: white;
  border: 1px solid #93c5fd;
  color: #1e40af;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-parcours:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

.btn-action-parcours.added {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}

/* --------------------------------------------------------------------------
   5. CARTES & CONTENEURS (CARDS)
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Compatibilité des anciennes classes roundedcorners */
.roundedcorners0, .roundedcorners, .roundedcornersblack, .roundedcornersblue,
.roundedcorners1, .roundedcorners2, .roundedcorners3, .roundedcorners4, .roundedcorners5 {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.roundedcornersblue {
  border-left: 5px solid var(--primary);
  background: #f8fafc;
}

.roundedcorners1 { border-left: 5px solid #94a3b8; }
.roundedcorners2 { border-left: 5px solid #0284c7; }
.roundedcorners3 { border-left: 5px solid #d97706; }
.roundedcorners4 { border-left: 5px solid #7c3aed; }
.roundedcorners5 { border-left: 5px solid #059669; }

/* --------------------------------------------------------------------------
   6. BRIQUES PÉDAGOGIQUES (COURS, EXERCICES, SOLUTIONS)
   -------------------------------------------------------------------------- */
.parcours-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
}

.linear-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content-brick {
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-left-width: 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  
  position: relative;
}

.content-brick:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.sub-brick {
  margin-left: 32px;
  width: calc(100% - 32px);
  border-left-width: 4px;
}

.brick-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.brick-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brick-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brick-body {
  padding: 18px 20px;
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--text-main);
}

.brick-footer {
  padding: 10px 18px;
  background: #f8fafc;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

/* Couleurs spécifiques par type de Brique */
/* Définition (Vert) */
.type-definition { border-color: #10b981; border-left-color: #059669; }
.type-definition .brick-header { background: #f0fdf4; color: #065f46; border-bottom-color: #dcfce7;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* Théorème / Enoncé (Rouge) */
.type-theoreme, .type-enonce { border-color: #f87171; border-left-color: #dc2626; }
.type-theoreme .brick-header, .type-enonce .brick-header { background: #fef2f2; color: #991b1b; border-bottom-color: #fee2e2;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.type-theoreme-sub, .type-enonce-sub { border-color: #fca5a5; border-left-color: #ef4444; }

/* Exercice (Bleu) */
.type-exercice { border-color: #60a5fa; border-left-color: #2563eb; }
.type-exercice .brick-header { background: #eff6ff; color: #1e40af; border-bottom-color: #dbeafe;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.type-exercice-sub { border-color: #93c5fd; border-left-color: #3b82f6; }
.type-exercice-sub .brick-header { background: #f8fafc; color: #1e3a8a; border-bottom-color: #e2e8f0;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* Remarque / Exemple / Information (Commentaires en Gris) */
.type-information, .type-exemple, .type-remarque { border-color: #94a3b8; border-left-color: #475569; }
.type-information .brick-header, .type-exemple .brick-header, .type-remarque .brick-header { background: #f8fafc; color: #334155; border-bottom-color: #e2e8f0;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* Le reste: Proposition, Propriété, Lemme, Corollaire, Stratégie, Méthode (Violet) */
.type-proposition, .type-propriete, .type-lemme, .type-corollaire, .type-strategie, .type-methode { border-color: #c084fc; border-left-color: #9333ea; }
.type-proposition .brick-header, .type-propriete .brick-header, .type-lemme .brick-header, .type-corollaire .brick-header, .type-strategie .brick-header, .type-methode .brick-header { background: #faf5ff; color: #6b21a8; border-bottom-color: #f3e8ff;   border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* --------------------------------------------------------------------------
   7. ÉTATS DE MAÎTRISE PÉDAGOGIQUE
   -------------------------------------------------------------------------- */
.content-brick.mastered {
  border-style: dashed !important;
  border-width: 2px !important;
  border-left-width: 6px !important;
  opacity: 0.85;
}
.content-brick.mastered::after {
  content: "✔ Acquis";
  position: absolute;
  top: -12px;
  right: auto;
  left: 24px;
  transform: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  pointer-events: none;
  border: 1px solid #a7f3d0;
  z-index: 10;
}

.content-brick.review {
  border-style: double !important;
  border-width: 4px !important;
  border-left-width: 6px !important;
}
.content-brick.review::after {
  content: "⚠ À revoir";
  position: absolute;
  top: -12px;
  right: auto;
  left: 24px;
  transform: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: #d97706;
  background: #fffbeb;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  pointer-events: none;
  border: 1px solid #fde68a;
  z-index: 10;
}

/* --------------------------------------------------------------------------
   8. FILTRES & BRIQUETTES INTERACTIVES
   -------------------------------------------------------------------------- */
.filter-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.filtre-groupe {
  margin-bottom: 16px;
}
.filtre-groupe:last-child {
  margin-bottom: 0;
}

.filtre-label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.briquette {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin: 3px 4px 3px 0;
  background-color: var(--bg-subtle);
  color: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.briquette:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
  border-color: var(--border-strong);
}

.briquette.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(30, 64, 175, 0.2);
}

/* --------------------------------------------------------------------------
   9. PANIER DE PARCOURS
   -------------------------------------------------------------------------- */
.panier-parcours-box {
  background: #f8fafc;
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.panier-parcours-box.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.panier-titre {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panier-select, .panier-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: white;
  font-family: inherit;
  font-size: 0.92rem;
  margin-bottom: 12px;
  transition: var(--transition);
}

.panier-select:focus, .panier-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.panier-liste {
  list-style: none;
  min-height: 50px;
  padding: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.panier-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: grab;
  transition: var(--transition);
}

.panier-item:last-child {
  margin-bottom: 0;
}

.panier-item:hover {
  background: #e2e8f0;
}

/* --------------------------------------------------------------------------
   10. JAUGE & BARRE DE PROGRESSION
   -------------------------------------------------------------------------- */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
  margin: 8px 0;
}

.progress-segment-acquis {
  height: 100%;
  background: #10b981;
  transition: width 0.3s ease;
}

.progress-segment-revoir {
  height: 100%;
  background: #f59e0b;
  transition: width 0.3s ease;
}

/* --------------------------------------------------------------------------
   11. FORMULAIRES & CHAMPS DE SAISIE
   -------------------------------------------------------------------------- */
input[type="text"], input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: white;
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

/* --------------------------------------------------------------------------
   12. SECTIONS DÉPLIABLES (ACCORDÉONS / COLLAPSIBLES)
   -------------------------------------------------------------------------- */
.collapsible {
  background-color: #f1f5f9;
  color: var(--text-main);
  cursor: pointer;
  padding: 14px 18px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  outline: none;
  font-size: 0.98rem;
  font-weight: 600;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.collapsible:hover, .collapsible.active {
  background-color: #e2e8f0;
  color: var(--primary);
}

.content {
  padding: 0 18px;
  display: none;
  overflow: hidden;
  background-color: white;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   13. FOOTER
   -------------------------------------------------------------------------- */
.app-footer {
  background: white;
  border-top: 1px solid var(--border);
  padding: 30px 20px;
  margin-top: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   14. FORMULES MATHÉMATIQUES (MATHJAX)
   -------------------------------------------------------------------------- */
.MathJax {
  outline: none !important;
}

.MathJax_Display, mjx-container[display="true"] {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding: 6px 0 !important;
  margin: 0.8em 0 !important;
  max-width: 100% !important;
}

/* --------------------------------------------------------------------------
   15. RESPONSIVE DESIGN (MOBILE & TABLETTE)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-container {
    height: auto;
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .main-nav {
    overflow-x: auto;
    padding-bottom: 4px;
    justify-content: flex-start;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  
  .main-content {
    padding: 16px 12px 40px 12px;
  }

  .sub-brick {
    margin-left: 12px;
    width: calc(100% - 12px);
  }
  
  }

/* Stylisation des listes et sous-questions */
.content-brick ol, .content-brick ul, .text-content ol, .text-content ul {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}
.content-brick ol ol, .content-brick ol ul, .content-brick ul ol, .content-brick ul ul, .text-content ol ol, .text-content ol ul, .text-content ul ol, .text-content ul ul {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
}
.content-brick li, .text-content li {
  margin-bottom: 0.3rem;
}

.content-brick.in-progress::after {
  content: "⌛ En cours";
  position: absolute;
  top: -12px;
  right: auto;
  left: 24px;
  transform: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0369a1;
  background: #f0f9ff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  pointer-events: none;
  border: 1px solid #bae6fd;
  z-index: 10;
}


.has-dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid var(--border);
    padding: 8px 0;
}

.has-dropdown:hover .dropdown-menu {
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

.dropdown-item:hover {
    background-color: #f1f5f9;
    color: var(--primary);
}

.dropdown-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}
