:root {
  /* Nouvelles couleurs principales */
  --primary: #003366;        /* Bleu foncé */
  --primary-dark: #002244;   /* Bleu encore plus foncé pour les hover */
  --secondary: #ffeb3b;      /* Jaune */
  --secondary-dark: #e6d335; /* Jaune plus foncé pour les hover */
  --accent: #0055a4;         /* Bleu complémentaire */
  --success: #4cc9f0;
  --warning: #f72585;
  --danger: #ff4d6d;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --gray-light: #e9ecef;
  --gray-dark: #343a40;
  --white: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
  --border-radius: 8px;
  --sidebar-width: 300px;    /* Augmenté pour meilleure lisibilité sur desktop */
  --header-height: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f5f7fb;
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column; /* Pour assurer que le footer reste en bas */
}

/* Header */
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background-color: var(--primary);
  box-shadow: var(--shadow);
  z-index: 1000;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);  /* Jaune */
}

.logo i {
  font-size: 1.8rem;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: bold;
}

.search-container {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 50px;
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 400px;
  margin: 0 1rem;
  transition: var(--transition);
  border: 1px solid transparent;
}

.search-container:focus-within {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: var(--secondary);
  box-shadow: 0 0 0 2px rgba(255, 235, 59, 0.25);
}

.search-container input {
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  font-size: 0.95rem;
  color: var(--white);
}

.search-container input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-container button {
  background: transparent;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  transition: var(--transition);
}

.search-container button:hover {
  color: var(--secondary-dark);
  transform: scale(1.1);
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Main container */
.main-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height) - 300px); /* Hauteur minimale pour garder le footer en bas */
  flex: 1; /* Pour que le container prenne tout l'espace disponible */
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--white);
  box-shadow: var(--shadow);
  height: calc(100vh - var(--header-height));
  position: fixed;
  top: var(--header-height);
  left: 0;
  overflow-y: auto;
  transition: var(--transition);
  padding: 1.5rem 0;
  z-index: 900;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

/* Style pour la scrollbar du sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: 6px;
}

.sidebar-header {
  padding: 0 1.5rem 1rem;
  border-bottom: 1px solid var(--gray-light);
}

.sidebar-header h2 {
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: 600;
}

.progress-container {
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  background-color: rgba(0, 51, 102, 0.03);
  border-bottom: 1px solid var(--gray-light);
}

.progress-bar {
  height: 8px;
  background-color: var(--gray-light);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--primary);
  border-radius: 10px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 500;
}

.nav-menu {
  list-style: none;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.chapter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--dark);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.chapter-btn i:first-child {
  margin-right: 10px;
  color: var(--primary);
}

.chapter-btn:hover {
  background-color: rgba(0, 51, 102, 0.05);
  color: var(--primary);
}

.chapter-btn.active {
  background-color: rgba(0, 51, 102, 0.1);
  color: var(--primary);
  font-weight: 600;
  border-left: 4px solid var(--primary);
}

.arrow {
  transition: transform 0.3s ease;
  color: var(--gray);
}

.chapter-btn.active .arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

.sub-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  list-style: none;
  background-color: rgba(0, 51, 102, 0.02);
}

.sub-menu.show {
  max-height: 500px;
}

.sub-item {
  display: block;
  padding: 0.6rem 1.5rem 0.6rem 3rem;
  color: var(--gray-dark);
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
  border-left: 0px solid var(--primary);
}

.sub-item:hover {
  background-color: rgba(0, 51, 102, 0.05);
  color: var(--primary);
  border-left: 2px solid var(--primary);
}

.sub-item.active {
  background-color: rgba(0, 51, 102, 0.1);
  color: var(--primary);
  font-weight: 500;
  border-left: 2px solid var(--primary);
}

/* Content */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem 3rem;  /* Augmenté pour plus d'espace sur desktop */
  transition: var(--transition);
  max-width: calc(100% - var(--sidebar-width));
}

.chapter {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
}

.chapter.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

.chapter-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-light);
}

.chapter-header h2 {
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.chapter-description {
  color: var(--gray);
  font-size: 1.05rem;
}

.section {
  margin-bottom: 3rem;
  animation: fadeIn 0.5s ease;
  background-color: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border-left: 4px solid var(--primary);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-light);
}

.section-header h3 {
  font-size: 1.5rem;
  color: var(--primary);
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.bookmark-btn {
  background: transparent;
  border: none;
  color: var(--gray);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
}

.bookmark-btn:hover, .bookmark-btn.active {
  color: var(--secondary);
}

.completion-badge {
  color: var(--gray-light);
  font-size: 1.2rem;
  transition: var(--transition);
  cursor: pointer;
}

.completion-badge.completed {
  color: var(--success);
}

/* Cards */
.content-card {
  background-color: var(--white);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-bottom: 1.5rem;
  transition: var(--transition);
  border: 1px solid var(--gray-light);
  display: flex;
  flex-direction: column; /* Assure que les cartes s'adaptent correctement */
}

.content-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background-color: rgba(0, 51, 102, 0.03);
  border-bottom: 1px solid var(--gray-light);
}

.card-header i {
  color: var(--primary);
  font-size: 1.2rem;
  margin-right: 0.75rem;
}

.card-header h4 {
  flex: 1;
  font-size: 1.1rem;
  color: var(--primary);
}

.duration, .size {
  font-size: 0.85rem;
  color: var(--white);
  padding: 0.2rem 0.8rem;
  background-color: var(--primary);
  border-radius: 15px;
}

.card-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Video card - OPTIMISÉ POUR MOBILE ET TABLETTE */
.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid var(--gray-light);
  background-color: #000; /* Ajoute un fond noir pour les vidéos */
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-description {
  color: var(--gray);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem; /* Espace entre la description et les boutons */
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn i {
  margin-right: 0.5rem;
}

.quiz-btn {
  background-color: var(--primary);
  color: var(--white);
}

.quiz-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.resource-btn {
  background-color: var(--secondary);
  color: var(--primary);
  font-weight: 600;
}

.resource-btn:hover {
  background-color: var(--secondary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Animation pour les boutons "Marquer comme vu" */
.mark-watched-btn {
  background-color: rgba(0, 51, 102, 0.1);
  color: var(--primary);
  margin-top: auto; /* Place le bouton en bas de la carte */
  font-size: 0.9rem;
  align-self: flex-start; /* Aligne le bouton à gauche */
}

.mark-watched-btn:hover {
  background-color: var(--primary);
  color: var(--white);
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--primary);
  color: var(--white);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 1000;
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background-color: var(--secondary);
  color: var(--primary);
  transform: translateY(-3px);
}

/* Footer - MODIFIÉ */
.footer {
  background-color: var(--primary);
  color: var(--light);
  padding: 3rem 0 1rem;
  position: relative;
  z-index: 800;
  width: 100%;
}

.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-section {
  flex: 1;
  min-width: 250px;
  margin-bottom: 2rem;
}

.footer-section h3 {
  color: var(--secondary);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section a {
  color: var(--gray-light);
  text-decoration: none;
  transition: var(--transition);
}

.footer-section a:hover {
  color: var(--secondary);
}

.social-icons {
  display: flex;
  gap: 1rem;
}

.social-icons a {
  color: var(--gray-light);
  font-size: 1.5rem;
  transition: var(--transition);
}

.social-icons a:hover {
  color: var(--secondary);
  transform: translateY(-3px);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Améliorations specifiques pour desktop */
@media screen and (min-width: 1025px) {
  .content {
    padding: 2rem 4rem;
  }
  
  .section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
  }
  
  .section-header {
    grid-column: 1 / -1;
    margin-bottom: 1rem;
  }
  
  .content-card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  
  .card-body .btn {
    margin-top: auto;
  }
  
  /* SUPPRESSION du footer en version desktop */
  .footer {
    display: none;
  }
}

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

/* Media Queries */
@media screen and (max-width: 1200px) {
  .content {
    padding: 2rem;
  }
}

@media screen and (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .content {
    padding: 1.5rem;
  }
  
  .section {
    display: block;
  }
  
  /* Amélioration des vidéos en version tablette */
  .video-container {
    margin-bottom: 1.5rem;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  }
  
  /* Footer en version tablette */
  .footer {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }
}

@media screen and (max-width: 768px) {
  :root {
    --sidebar-width: 0;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .sidebar {
    left: -280px;
    width: 280px;
  }

  .sidebar.active {
    left: 0;
  }

  .content {
    margin-left: 0;
    max-width: 100%;
    padding: 1.5rem 1rem;
  }

  .search-container {
    max-width: 200px;
  }

  .chapter-header h2 {
    font-size: 1.8rem;
  }

  .section-header h3 {
    font-size: 1.3rem;
  }
  
  /* Optimisations des vidéos pour mobile */
  .video-container {
    padding-bottom: 56.25%; /* Maintient le ratio 16:9 */
    margin-bottom: 1.2rem;
    border-radius: 4px;
  }
  
  .video-description {
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
  }
  
  /* Ajustement des boutons pour les vidéos sur mobile */
  .card-body .btn {
    display: block;
    width: 100%;
    margin-bottom: 0.8rem;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
  }
  
  /* Footer en version mobile */
  .footer {
    margin-left: 0;
    width: 100%;
  }
}

@media screen and (max-width: 576px) {
  .main-header {
    padding: 0 1rem;
  }

  .logo h1 {
    display: none;
  }

  .search-container {
    max-width: none;
    flex: 1;
  }

  .content {
    padding: 1rem;
  }

  .section {
    padding: 1rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-actions {
    margin-top: 0.5rem;
  }
  
  /* Optimisations supplémentaires pour les petits écrans */
  .card-header {
    padding: 0.8rem 1rem;
  }
  
  .card-header h4 {
    font-size: 1rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .video-container {
    border-width: 1px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  }
  
  .duration, .size {
    font-size: 0.75rem;
    padding: 0.15rem 0.6rem;
  }
}

/* Style pour les éléments en survol */
.highlight {
  animation: highlightAnimation 2s ease;
}

@keyframes highlightAnimation {
  0% {
    background-color: rgba(255, 235, 59, 0.2);
  }
  70% {
    background-color: rgba(255, 235, 59, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

/* Optimisation du chargement des vidéos */
.video-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  color: white;
  font-size: 1.2rem;
  border-radius: 6px;
}

.video-loader::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--secondary);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Amélioration pour les vidéos qui ne se chargent pas */
.video-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--dark);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--white);
  padding: 1rem;
  text-align: center;
  border-radius: 6px;
}

.video-fallback i {
  font-size: 2.5rem;
  color: var(--secondary);
  margin-bottom: 1rem;
}

.video-fallback-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.video-fallback-text {
  font-size: 0.9rem;
  opacity: 0.8;
  max-width: 80%;
}

.video-retry-btn {
  margin-top: 1rem;
  background-color: var(--secondary);
  color: var(--dark);
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
}

.video-retry-btn:hover {
  background-color: var(--secondary-dark);
  transform: scale(1.05);
}