/* Variables de design modernes et claires */
:root {
  --bg: #f8fafc;
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --panel: rgba(255, 255, 255, 0.95);
  --card: rgba(255, 255, 255, 0.9);
  --card-hover: rgba(255, 255, 255, 1);
  --text: #1e293b;
  --text-light: #475569;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --border: rgba(148, 163, 184, 0.2);
  --border-light: rgba(148, 163, 184, 0.1);
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-gradient: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 15px 50px rgba(59, 130, 246, 0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --sidebar-width: 300px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header principal distinct */
.main-header {
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0;
}

.header-content {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Menu burger (mobile seulement) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
}

.menu-toggle:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
}

/* Layout principal avec sidebar */
.page-container {
  display: flex;
  flex: 1;
}

/* Overlay pour sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(4px);
}

/* Sidebar sommaire */
.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--border);
  height: calc(100vh - 70px);
  position: sticky;
  top: 70px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-gradient);
  color: white;
  position: relative;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header h3 i {
  font-size: 18px;
}

.sidebar-close {
  display: none;
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
}

.chapters-list {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.chapter-item {
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.chapter-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
  transform: translateX(4px);
}

.chapter-item.active {
  background: var(--accent-gradient);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chapter-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 28px;
  height: 28px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chapter-item.active .chapter-number {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.chapter-title {
  font-size: 14px;
  line-height: 1.4;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Contenu principal */
.main-content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Header du chapitre */
.chapter-header {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 30px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  margin-bottom: 30px;
}

.badge-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.08);
  padding: 6px 14px;
  border-radius: 999px;
}

.badge-icon {
  font-size: 12px;
}

.progress-badge {
  color: var(--muted);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.6);
}

h1 {
  margin: 0 0 20px;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  color: #1e293b;
  letter-spacing: -0.5px;
}

.chapter-intro {
  color: var(--text-light);
  font-size: 18px;
  line-height: 1.7;
  margin-bottom: 0;
}

.chapter-intro strong {
  color: var(--text);
  font-weight: 600;
}

/* Sections principales */
main section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin: 30px 0;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s ease;
}

main section:hover {
  box-shadow: var(--shadow-card-hover);
}

main section h2 {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

main section h2::before {
  content: '';
  width: 4px;
  height: 22px;
  background: var(--accent-gradient);
  border-radius: 2px;
  display: inline-block;
}

/* Section résumé */
.chapter-summary-section {
  margin-bottom: 40px;
}

.summary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.summary-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(248, 250, 252, 0.8);
  border-radius: 8px;
}

.summary-icon {
  color: var(--success);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.next-chapter-info {
  color: var(--text-light);
  margin-top: 20px;
  text-align: center;
  font-size: 16px;
}

/* Articles dans les sections */
article {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  position: relative;
}

article:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius) 0 0 var(--radius);
}

article h3 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

article h3::before {
  content: '→';
  color: var(--accent);
  font-weight: 700;
}

/* Callouts pédagogiques */
.callout {
  border-left: 4px solid;
  padding: 20px;
  border-radius: var(--radius-sm);
  margin: 20px 0;
  background: rgba(248, 250, 252, 0.8);
  border-color: var(--accent);
  position: relative;
  overflow: hidden;
}

.callout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.03), transparent);
  pointer-events: none;
}

.callout strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 16px;
  color: var(--accent);
}

.callout strong::before {
  content: '💡';
  font-size: 18px;
}

.callout.conseil {
  border-color: var(--success);
}

.callout.conseil strong::before {
  content: '⚡';
}

.callout.conseil strong {
  color: var(--success);
}

.callout.attention {
  border-color: var(--warning);
}

.callout.attention strong::before {
  content: '⚠️';
}

.callout.attention strong {
  color: var(--warning);
}

/* Listes */
ul {
  margin: 16px 0;
  padding-left: 24px;
}

li {
  margin: 10px 0;
  color: var(--text-light);
  line-height: 1.6;
  padding-left: 8px;
}

li::marker {
  color: var(--accent);
  font-weight: 600;
}

p {
  color: var(--text-light);
  margin: 16px 0;
  line-height: 1.7;
}

strong {
  color: var(--text);
  font-weight: 600;
}

/* Code inline */
code:not(pre code) {
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--accent);
}

/* Conteneur de code personnalisé */
.code-container {
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
}

.code-header {
  background: #1a1a1a;
  padding: 12px 20px;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: #aaa;
}

.code-language {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-language::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.copy-button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #aaa;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.copy-button::before {
  content: '📋';
  font-size: 12px;
}

/* Ajustement du thème Prism pour mieux s'intégrer */
.code-container pre[class*="language-"] {
  margin: 0;
  border-radius: 0;
  background: #1a1a1a;
}

.code-container pre[class*="language-"] code {
  font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 15px;
  line-height: 1.5;
  color: #e2e8f0;
  background: transparent;
  border: none;
  padding: 0;
}

/* Navigation entre chapitres */
.chapter-navigation {
  display: flex;
  justify-content: space-between;
  margin: 40px 0;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.final-navigation {
  margin-top: 60px;
  margin-bottom: 20px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  min-width: 200px;
}

.nav-prev {
  background: rgba(248, 250, 252, 0.8);
  border: 1px solid var(--border);
  color: var(--text-light);
}

.nav-prev:hover {
  background: white;
  border-color: var(--accent-light);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.1);
}

.nav-next {
  background: var(--accent-gradient);
  color: white;
  border: none;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.nav-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.nav-icon {
  font-size: 18px;
}

/* Footer distinct */
.main-footer {
  background: white;
  border-top: 1px solid var(--border);
  padding: 40px 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
}

.footer-section h4 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text);
  font-weight: 700;
}

.footer-section p {
  color: var(--muted);
  line-height: 1.6;
}

.footer-meta {
  margin-top: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s ease;
  font-size: 15px;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  max-width: 1200px;
  margin: 40px auto 0;
  padding: 20px 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.footer-links-bottom {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-links-bottom a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-links-bottom a:hover {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 992px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    transform: translateX(-100%);
    width: 300px;
    height: calc(100vh - 70px);
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
    transition: opacity 0.3s ease;
  }

  .main-content {
    padding: 20px;
  }

  .chapter-header {
    padding: 24px;
  }

  h1 {
    font-size: 28px;
  }

  .chapter-intro {
    font-size: 16px;
  }

  main section {
    padding: 24px;
  }

  main section h2 {
    font-size: 20px;
  }

  article {
    padding: 20px;
  }

  .chapter-navigation {
    flex-direction: column;
    gap: 16px;
  }

  .nav-button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 16px;
  }

  .main-content {
    padding: 16px;
  }

  .footer-content {
    padding: 0 16px;
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .code-header {
    padding: 10px 16px;
    font-size: 13px;
  }

  .code-container pre[class*="language-"] code {
    font-size: 14px;
    padding: 16px !important;
  }

  .footer-links-bottom {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }

  .badge-container {
    flex-direction: column;
    align-items: flex-start;
  }

  article h3 {
    font-size: 16px;
  }

  .code-container pre[class*="language-"] code {
    font-size: 13px;
  }

  .logo-text {
    display: none;
  }

  .nav-button {
    min-width: auto;
    padding: 12px 20px;
  }
}

/* Animations subtiles */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chapter-header, section, .chapter-navigation {
  animation: fadeInUp 0.5s ease forwards;
}

section:nth-child(1) { animation-delay: 0.1s; }
section:nth-child(2) { animation-delay: 0.2s; }
section:nth-child(3) { animation-delay: 0.3s; }
section:nth-child(4) { animation-delay: 0.4s; }
section:nth-child(5) { animation-delay: 0.5s; }
section:nth-child(6) { animation-delay: 0.6s; }

/* Ajouter ces styles à la fin du fichier style.css */

/* Section résumé en bas de page */
.chapter-summary-section {
  margin: 60px 0 40px;
  padding-top: 30px;
  border-top: 2px solid var(--border);
}

.chapter-summary-section h2 {
  margin-bottom: 30px;
  color: var(--text);
  font-size: 24px;
}

.summary-callout {
  margin-bottom: 40px;
}

.summary-callout strong {
  font-size: 18px;
  margin-bottom: 20px;
  display: block;
}

.summary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 20px;
}

.summary-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.summary-icon {
  color: var(--success);
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-text {
  color: var(--text-light);
  line-height: 1.6;
  font-size: 16px;
}

/* Preview du prochain chapitre */
.next-chapter-preview {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
  border-radius: var(--radius);
  padding: 30px;
  margin: 40px 0;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.next-chapter-preview h3 {
  color: var(--accent);
  font-size: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.next-chapter-preview h3::before {
  content: '🔜';
  font-size: 18px;
}

.next-chapter-preview p {
  color: var(--text-light);
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 20px;
}

.next-chapter-objectives {
  list-style: none;
  padding-left: 0;
  margin-top: 20px;
}

.next-chapter-objectives li {
  padding: 10px 0 10px 32px;
  position: relative;
  color: var(--text-light);
}

.next-chapter-objectives li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}

/* Navigation finale améliorée */
.final-navigation {
  margin-top: 50px;
  margin-bottom: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

/* Ajustements responsive pour la section résumé */
@media (max-width: 768px) {
  .chapter-summary-section {
    margin: 40px 0 30px;
    padding-top: 20px;
  }
  
  .chapter-summary-section h2 {
    font-size: 22px;
  }
  
  .next-chapter-preview {
    padding: 20px;
  }
  
  .next-chapter-preview h3 {
    font-size: 18px;
  }
  
  .summary-item {
    padding: 14px;
  }
}