/*
  ===================================================================
  FICHIER CSS GLOBAL HARMONISÉ POUR LES COURS DE MATHÉMATIQUES
  Contient les styles pour toutes les pages de cours (Analyse, Algèbre, etc.).
  ===================================================================
*/

:root {
  /* Couleurs principales */
  --primary-orange: #ff7b00;
  --secondary-yellow: #ffe066;

  /* Couleurs de texte */
  --text-primary: #222;
  --text-secondary: #555;

  /* Ombres et arrières-plans généraux */
  --shadow-light: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.15);

  /* Fond par défaut (conservé en #fff2beff comme convenu pour la série Science) */
  --background-solid: #fff2beff;

  /* Fond des boîtes de table des matières */
  --card-background: linear-gradient(145deg, hsl(46, 100%, 89%), #fff8cf);

  /* --- COULEURS DES BOÎTES SÉMANTIQUES --- */

  /* Définitions / Propriétés d'Unicité (Bleu/Cyan) */
  --color-definition-bg: linear-gradient(145deg, #e0f7fa, #b2ebf2);
  --color-definition-border: #00acc1;

  /* Propositions / Théorèmes (Rouge/Rose) */
  --color-proposition-bg: linear-gradient(145deg, #ffebee, #ffcdd2);
  --color-proposition-border: #e53935;

  /* Exemples / Méthodes (Vert) */
  --color-example-bg: linear-gradient(145deg, #e8f5e9, #c8e6c9);
  --color-example-border: #4CAF50;

  /* Remarques / Méthodes (Jaune) */
  --color-remarque-bg: linear-gradient(145deg, #fffde7, #fff9c4);
  --color-remarque-border: #fbc02d;
  /* Jaune foncé */

  /* Attention / Mise en garde (Orange) */
  --color-attention-bg: linear-gradient(145deg, #fff3e0, #ffe0b2);
  --color-attention-border: #ff9800;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ----------------------------------- */
/* Styles du Corps et du Conteneur Principal */
/* ----------------------------------- */
body {
  font-family: 'Poppins', sans-serif;
  background: var(--background-solid);
  color: var(--text-primary);
  margin: 0;
  text-align: center;
  padding: 0;
  line-height: 1.8;
}

.cours-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.hero-section {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 40px;
}

.hero-content h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 15px;
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.content-wrapper {
  background: white;
  border-radius: 20px;
  padding: 50px;
  box-shadow: var(--shadow-light);
  margin-bottom: 40px;
  text-align: left;
  position: relative;
}

/* ----------------------------------- */
/* Bouton de Téléchargement PDF */
/* ----------------------------------- */
.btn-pdf-download {
  position: absolute;
  top: 30px;
  right: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0f0f0; /* Fond grisé */
  color: #999; /* Texte grisé */
  border: 1px solid #ccc;
  padding: 8px 15px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  pointer-events: none; /* Désactive le clic */
  cursor: not-allowed;
}

/* Masquer le texte original */
.btn-pdf-download span {
  display: none;
}

/* Ajouter le nouveau texte */
.btn-pdf-download::after {
  content: "Téléchargement PDF bientôt disponible";
}

.btn-pdf-download:hover {
  background: #f0f0f0;
  color: #999;
  box-shadow: none;
}

.btn-pdf-download svg {
  stroke: currentColor;
  width: 18px;
  height: 18px;
}

/* ----------------------------------- */
/* Titres et Table des Matières */
/* ----------------------------------- */
.course-header {
  border: 3px double var(--primary-orange);
  padding: 20px;
  text-align: center;
  margin-bottom: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, #fff9e6, #ffffff);
}

.course-header h2 {
  font-size: 1.8rem;
  margin: 0;
  color: var(--text-primary);
}

.table-of-contents {
  background: var(--card-background);
  padding: 25px;
  border-radius: 15px;
  margin: 30px 0;
  border-left: 4px solid var(--primary-orange);
}

.table-of-contents h3 {
  margin-top: 0;
  color: var(--primary-orange);
  font-size: 1.3rem;
}

.table-of-contents ul {
  list-style: none;
  padding-left: 0;
}

.table-of-contents li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 123, 0, 0.1);
}

/* Style pour les sous-listes de la table des matières */
.table-of-contents ul ul {
  padding-left: 20px;
  list-style-type: none;
}

.table-of-contents ul ul li {
  border-bottom: none;
}


.table-of-contents a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.3s;
  font-weight: 500;
}

.table-of-contents a:hover {
  color: var(--primary-orange);
}

.section-title {
  font-size: 2rem;
  color: var(--primary-orange);
  margin-top: 50px;
  margin-bottom: 25px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--primary-orange);
}

.subsection-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-top: 35px;
  margin-bottom: 20px;
}

h4.subsubsection-title {
  font-size: 1.3rem;
  color: var(--text-secondary);
  margin-top: 30px;
  margin-bottom: 15px;
  font-weight: 600;
}

/* NOUVEAU: Sous-section de preuve/démonstration */
h5 {
  font-size: 1.15rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-top: 25px;
  margin-bottom: 10px;
  border-bottom: 1px dashed #ccc;
  padding-bottom: 5px;
}


/* ----------------------------------- */
/* Boîtes de Contenu Sémantiques */
/* ----------------------------------- */
.definition-box,
.proposition-box,
.example-box,
.remarque-box,
.attention-box {
  padding: 20px;
  margin: 25px 0;
  border-radius: 10px;
}

/* Titre des boîtes sémantiques */
.definition-box h4,
.proposition-box h4,
.example-box h4,
.remarque-box h4 {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

/* 1. Définitions (Bleu/Cyan) */
.definition-box {
  background: var(--color-definition-bg);
  border-left: 5px solid var(--color-definition-border);
}

.definition-box h4 {
  color: var(--color-definition-border);
}

/* 2. Propositions/Théorèmes (Rouge/Rose) */
.proposition-box {
  background: var(--color-proposition-bg);
  border-left: 5px solid var(--color-proposition-border);
}

.proposition-box h4 {
  color: var(--color-proposition-border);
}

/* 3. Exemples/Méthodes (Vert) */
.example-box {
  background: var(--color-example-bg);
  border-left: 5px solid var(--color-example-border);
}

.example-box h4 {
  color: var(--color-example-border);
}

/* 4. Remarques (Jaune) */
/* J'utilise la classe 'remarque-box' pour les remarques avec titre H4 et 'remarque' pour le texte simple */
.remarque-box {
  background: var(--color-remarque-bg);
  border-left: 5px solid var(--color-remarque-border);
}

.remarque-box h4 {
  color: var(--color-remarque-border);
}

.remarque {
  background: #fff9e6;
  border-left: 4px solid var(--secondary-yellow);
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  font-style: italic;
}

.remarque strong {
  color: var(--primary-orange);
  font-style: normal;
}

/* 5. Attention (Orange) */
.attention-box {
  background: var(--color-attention-bg);
  border-left: 5px solid var(--color-attention-border);
  font-weight: 500;
}

.attention-box strong {
  color: #e65100;
}

/* Style pour les preuves */
.proof-box {
  background: #fdfdfd;
  border-left: 4px solid #999;
  /* Couleur neutre pour les preuves */
  padding: 15px 25px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.proof-box p {
  margin-top: 10px;
  margin-bottom: 10px;
}

.proof-box p:first-child {
  margin-top: 0;
}

.proof-box p>b {
  /* Unicité / Existence */
  color: #333;
}


/* Style pour les boîtes de formules */
.formula-box {
  background: #fffcf5;
  padding: 20px 20px 20px 25px;
  margin: 20px 0;
  text-align: center;
  overflow-x: auto;
  border-left: 4px solid var(--primary-orange);
  border-radius: 0 8px 8px 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}


/* ----------------------------------- */
/* Images et Tableaux */
/* ----------------------------------- */
.image-container {
  text-align: center;
  margin: 30px 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: var(--shadow-light);
}

/* Conteneur pour images côte-à-côte (trouvé dans continuite-cours.css) */
.image-container-flex {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 30px 0;
}

.image-container-flex .image-box {
  flex: 1;
  min-width: 280px;
  max-width: 45%;
  text-align: center;
}

.image-container-flex .image-box img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: var(--shadow-light);
}

.image-container-flex .image-box p {
  font-style: italic;
  font-weight: 500;
  text-align: center;
}


table {
  width: 100%;
  border-collapse: collapse;
  margin: 25px 0;
  background: white;
  box-shadow: var(--shadow-light);
  border-radius: 10px;
  overflow: hidden;
}

table th {
  background: var(--primary-orange);
  color: white;
  padding: 15px;
  text-align: center;
  font-weight: 600;
}

table td {
  padding: 12px 15px;
  /* Ajusté pour une meilleure lisibilité */
  text-align: left;
  /* Aligné à gauche par défaut pour le contenu long */
  border: 1px solid #e0e0e0;
}

table tr:nth-child(even) {
  background: #fafafa;
}


/* ----------------------------------- */
/* Boutons de Navigation */
/* ----------------------------------- */
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary-orange), #ff9500);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 15px rgba(255, 123, 0, 0.3);
  transition: all 0.3s ease;
  margin: 0;
}

.btn-nav:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 123, 0, 0.4);
}

.navigation-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 50px;
  margin-bottom: 20px;
  /* Espace après le début du contenu */
}

/* S'assure que le dernier groupe de boutons est bien espacé */
.content-wrapper>.navigation-buttons:last-of-type {
  margin-top: 50px;
  margin-bottom: 0;
}

/* ----------------------------------- */
/* Media Queries (Mobile) */
/* ----------------------------------- */
@media (max-width: 768px) {
  body {
    font-size: 0.95rem;
    /* Slightly smaller body text */
  }

  .content-wrapper {
    padding: 20px;
    /* Reduced padding */
    overflow-x: hidden;
    /* Prevent horizontal scroll on wrapper */
  }

  .hero-content h1 {
    font-size: 1.8rem;
    /* Smaller main title */
  }

  .course-header {
    padding: 15px;
  }

  .course-header h2 {
    font-size: 1.4rem;
    /* Smaller header title */
  }

  .section-title {
    font-size: 1.5rem;
    margin-top: 30px;
  }

  .subsection-title {
    font-size: 1.2rem;
    margin-top: 25px;
  }

  h4.subsubsection-title {
    font-size: 1.1rem;
    margin-top: 20px;
  }

  /* Semantic boxes mobile adjustments */
  .definition-box,
  .proposition-box,
  .example-box,
  .remarque-box,
  .attention-box,
  .proof-box {
    padding: 15px;
    margin: 20px 0;
    overflow-x: auto;
    /* Allow horizontal scroll if content overflows */
    max-width: 100%;
    word-wrap: break-word;
    /* Break long words */
    overflow-wrap: break-word;
  }

  .definition-box h4,
  .proposition-box h4,
  .example-box h4,
  .remarque-box h4 {
    font-size: 1.1rem;
  }

  /* Formula box optimization */
  .formula-box {
    padding: 15px;
    margin: 15px 0;
    overflow-x: auto;
    /* Ensure scrolling */
    white-space: nowrap;
    max-width: 100%;
    display: block;
  }

  /* Ensure images don't overflow (except header logo) */
  img:not(.logo) {
    max-width: 100% !important;
    height: auto !important;
  }

  .image-container,
  .image-container-flex,
  .image-box {
    max-width: 100% !important;
  }

  /* Règle mobile pour le bouton PDF */
  .btn-pdf-download {
    position: relative;
    top: auto;
    right: auto;
    display: block;
    text-align: center;
    margin-bottom: 20px;
  }

  /* Règle mobile pour les boutons de navigation */
  .navigation-buttons {
    flex-direction: row;
    gap: 10px;
    margin-top: 30px;
  }

  /* If screen is wide enough (tablet), row is fine. For phone, maybe column is safer? 
     Let's keep row but allow wrap as defined in .navigation-buttons base style. 
     Just ensure gap is small. */
  .navigation-buttons {
    flex-direction: row;
  }

  .btn-nav {
    width: 100%;
    /* Full width buttons on mobile for easier tapping */
    justify-content: center;
    padding: 12px 15px;
    font-size: 0.9rem;
  }

  /* RÈGLES MOBILES POUR IMAGES CÔTE-À-CÔTE */
  .image-container-flex .image-box {
    max-width: 100%;
    min-width: 100%;
  }

  /* Amélioration mobile pour les tables */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%;
  }

  table td,
  table th {
    text-align: left;
    /* Aligne le texte à gauche pour lisibilité */
    white-space: normal;
    padding: 10px;
    /* Reduced padding in tables */
  }

  /* Handle MathJax formula overflow on mobile */
  .formula-box {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Only apply overflow to block display equations, not inline math */
  mjx-container[display="true"] {
    overflow-x: auto !important;
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  .hero-content h1 {
    font-size: 1.6rem;
  }

  .content-wrapper {
    padding: 15px;
  }
}

/* AJOUTS RÉCENTS */

/* Justification du texte dans le contenu */
.content-wrapper p {
  text-align: justify;
}

/* Styles pour les preuves déroulantes */
/* Styles pour les preuves déroulantes */
.proof-box details summary {
  cursor: pointer;
  font-weight: bold;
  font-style: italic;
  color: #333;
  outline: none;
  list-style: none;
  /* Masque la flèche par défaut */
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Masquer la flèche par défaut sur Webkit */
.proof-box details summary::-webkit-details-marker {
  display: none;
}

/* Ajout d'une flèche personnalisée */
.proof-box details summary::before {
  content: '▶';
  font-size: 0.8em;
  transition: transform 0.2s ease;
  display: inline-block;
}

/* Rotation de la flèche quand ouvert */
.proof-box details[open] summary::before {
  transform: rotate(90deg);
}

.proof-box details[open] summary {
  margin-bottom: 10px;
}

.proof-box details summary:hover {
  color: var(--primary-orange);
}

/* Styles pour les liens dans le contenu du cours */
.content-wrapper a:not(.btn-pdf-download):not(.btn-nav):not(.table-of-contents a) {
  color: var(--primary-orange);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

.content-wrapper a:not(.btn-pdf-download):not(.btn-nav):not(.table-of-contents a):hover {
  color: #e65100; /* Orange un peu plus foncé au survol */
  border-bottom: 1px solid var(--primary-orange);
}