/* ===== RESET ET BASES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif;
}

:root {
    --primary: #6a0dad;
    --primary-dark: #4b0082;
    --primary-light: #9b59b6;
    --secondary: #ff6b6b;
    --accent: #00c6ff;
    --text-light: #333;
    --text-dark: #f0f0f0;
    --bg-light: #f8f9ff;
    --bg-dark: #121212;
    --card-light: #ffffff;
    --card-dark: #1e1e1e;
    --success: #27ae60;
    --warning: #f39c12;
    --error: #e74c3c;
    --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --shadow-light: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-dark: 0 10px 30px rgba(0, 0, 0, 0.3);
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-dark));
    --gradient-secondary: linear-gradient(135deg, var(--secondary), #ff4757);
    --gradient-accent: linear-gradient(135deg, var(--accent), #0072ff);
}

html, body {
    background-color: var(--bg-light);
    color: var(--text-light);
    line-height: 1.6;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
    font-size: 16px;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

/* ===== ANIMATIONS AVANCÉES ===== */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-8px) rotate(1deg); }
    66% { transform: translateY(4px) rotate(-1deg); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(106, 13, 173, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(106, 13, 173, 0); }
    100% { box-shadow: 0 0 0 0 rgba(106, 13, 173, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes border-dance {
    0% { background-position: 0 0; }
    100% { background-position: 100% 100%; }
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--primary); }
}

/* ===== LOADER ===== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

body.dark-mode .page-loader {
    background: var(--bg-dark);
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(106, 13, 173, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-text {
    font-size: 1.2rem;
    color: var(--primary);
    position: relative;
    display: inline-block;
}

body.dark-mode .loader-text {
    color: var(--primary-light);
}

.loader-text::after {
    content: '';
    animation: typing 1.5s steps(20, end) infinite, blink 0.8s infinite;
    border-right: 2px solid;
}


/* ===== SECTION PRINCIPALE ===== */
.cours-section {
    max-width: 1400px;
    margin: 120px auto 50px;
    padding: 40px;
    background-color: var(--card-light);
    border-radius: 25px;
    box-shadow: var(--shadow-light);
    animation: fadeIn 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

body.dark-mode .cours-section {
    background-color: var(--card-dark);
    box-shadow: var(--shadow-dark);
}

.cours-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(106, 13, 173, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    animation: float 15s infinite linear;
    z-index: -1;
}

.cours-header {
    margin-bottom: 40px;
    position: relative;
}

.cours-header h1 {
    color: var(--primary-dark);
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
}

body.dark-mode .cours-header h1 {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cours-header p {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 35px;
    max-width: 700px;
    line-height: 1.7;
}

body.dark-mode .cours-header p {
    color: #bbb;
}

/* ===== FILTRES AMÉLIORÉS ===== */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
}

.filters select, 
.filters input {
    flex: 1;
    min-width: 200px;
    padding: 16px 20px;
    border: 2px solid #e0d0ff;
    border-radius: 15px;
    background-color: #faf5ff;
    color: #2e004f;
    font-size: 1rem;
    box-shadow: 0 5px 15px rgba(90, 43, 132, 0.08);
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 1em;
    font-weight: 500;
}

body.dark-mode .filters select,
body.dark-mode .filters input {
    background-color: #2a2a2a;
    color: var(--text-dark);
    border-color: #444;
}

.filters select:focus,
.filters input:focus {
    border-color: var(--primary);
    outline: none;
    background-color: #fff;
    box-shadow: 0 8px 25px rgba(142, 68, 173, 0.2);
    transform: translateY(-3px);
}

body.dark-mode .filters select:focus,
body.dark-mode .filters input:focus {
    background-color: #333;
}

.filters input::placeholder {
    color: #999;
}

/* ===== LISTE DE COURS ===== */
.cours-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.no-result, .error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    font-size: 1.2rem;
    color: #777;
}

body.dark-mode .no-result,
body.dark-mode .error {
    color: #aaa;
}

/* ===== CARTES DE COURS AMÉLIORÉES ===== */
.cours-card {
    background: var(--card-light);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    position: relative;
    transform-style: preserve-3d;
    animation: slideIn 0.6s ease-out;
    animation-fill-mode: backwards;
}

body.dark-mode .cours-card {
    background: var(--card-dark);
    box-shadow: var(--shadow-dark);
}

.cours-card:hover {
    transform: translateY(-10px) rotateX(2deg) rotateY(2deg);
    box-shadow: 0 20px 40px rgba(106, 13, 173, 0.2);
}

.cours-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 2px;
    background: linear-gradient(45deg, var(--primary), var(--secondary), var(--primary));
    background-size: 200% 200%;
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: border-dance 3s linear infinite;
    pointer-events: none;
    z-index: -1;
    opacity: 0;
    transition: var(--transition);
}

.cours-card:hover::before {
    opacity: 1;
}

.image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s ease;
}

.cours-card:hover .image-container img {
    transform: scale(1.1);
}

.rating {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    backdrop-filter: blur(5px);
}

.card-content {
    padding: 25px;
}

.card-content h3 {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--primary-dark);
    font-weight: 700;
    line-height: 1.3;
}

body.dark-mode .card-content h3 {
    color: var(--primary-light);
}

.description {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 18px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body.dark-mode .description {
    color: #bbb;
}

.info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.info span {
    background: #f0e5ff;
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

body.dark-mode .info span {
    background: #3a3a3a;
    color: #d0a3ff;
}

.buttons {
    display: flex;
    gap: 12px;
}

.buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.buttons button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
    transition: transform 0.5s, opacity 0.3s;
}

.buttons button:active::before {
    animation: ripple 0.6s ease-out;
}

.buttons .btn-view {
    background: var(--gradient-primary);
    color: white;
}

.buttons .btn-view:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(106, 13, 173, 0.3);
}

.buttons .btn-download {
    background: #f0e5ff;
    color: var(--primary);
}

body.dark-mode .buttons .btn-download {
    background: #3a3a3a;
    color: #d0a3ff;
}

.buttons .btn-download:hover {
    background: #e0d0ff;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.btn-connect-popup {
    width: 100%;
    background: linear-gradient(135deg, #2a0147, var(--primary-dark));
    color: white;
}

.btn-connect-popup:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    animation: pulse 1.5s infinite;
}

/* ===== POPUPS ===== */
.auth-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.auth-popup.active {
    opacity: 1;
    pointer-events: all;
}

.popup-content, .popup-content2 {
    background: var(--card-light);
    padding: 2.5rem;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

body.dark-mode .popup-content,
body.dark-mode .popup-content2 {
    background: var(--card-dark);
}

.auth-popup.active .popup-content,
.auth-popup.active .popup-content2 {
    transform: scale(1);
}

.popup-close, .popup-close2 {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.8rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.popup-close:hover, .popup-close2:hover {
    color: var(--secondary);
    background: rgba(0, 0, 0, 0.05);
}

.popup-content h3, .popup-content2 h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary);
    text-align: center;
}

.popup-content p, .popup-content2 p {
    color: #666;
    text-align: center;
    margin-bottom: 25px;
    line-height: 1.6;
}

body.dark-mode .popup-content p,
body.dark-mode .popup-content2 p {
    color: #bbb;
}

.popup-buttons, .popup-buttons2 {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.popup-buttons button, .popup-close-btn2 {
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.popup-buttons .btn-login {
    background: var(--gradient-primary);
    color: white;
}

.popup-buttons .btn-signup {
    background: #f0e5ff;
    color: var(--primary);
}

.popup-buttons button:hover, .popup-close-btn2:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.popup-close-btn2 {
    background: var(--gradient-primary);
    color: white;
    padding: 12px 24px;
}

.error-popup {
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .cours-section {
        padding: 35px;
    }
    
    .cours-header h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 992px) {
    .cours-list {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    
    nav ul {
        gap: 10px;
    }
    
    .nav-link {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .cours-section {
        padding: 25px 20px;
        margin-top: 100px;
        border-radius: 20px;
    }
    
    .filters {
        flex-direction: column;
        gap: 15px;
    }
    
    .cours-header h1 {
        font-size: 2.2rem;
    }
    
    .cours-header p {
        font-size: 1.1rem;
    }
    
    nav ul {
        display: none;
    }
    
    .menu-icon {
        display: flex;
    }
    
    .menu-secret.active {
        display: block;
    }
}

@media (max-width: 576px) {
    .cours-section {
        padding: 20px 15px;
    }
    
    .cours-card {
        min-width: 100%;
    }
    
    .popup-content, .popup-content2 {
        padding: 1.8rem;
    }
    
    .popup-buttons, .popup-buttons2 {
        flex-direction: column;
        gap: 10px;
    }
    
    .buttons {
        flex-direction: column;
    }
    
    .cours-header h1 {
        font-size: 1.8rem;
    }
    
    header {
        padding: 15px;
    }
}

/* ===== ACCESSIBILITÉ ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #0000FF;
        --primary-dark: #00008B;
        --secondary: #FF0000;
    }
    
    .cours-card {
        border: 2px solid var(--primary);
    }
}
.etablissement-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: bold;
  z-index: 2;
}

.universite-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.ecole-badge {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.image-container {
  position: relative;
}
/* Styles pour les nouvelles fonctionnalités */
.btn-detail {
  background: linear-gradient(135deg, #9849d8, #62088c) !important;
  color: white !important;
}

.btn-detail:hover {
  background: linear-gradient(135deg, #ab6ae0, #8b0dc5) !important;
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 114, 255, 0.3);
}

.stats {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: #666;
  background: #f8f5ff;
  padding: 4px 8px;
  border-radius: 8px;
}

body.dark-mode .stat {
  background: #3a3a3a;
  color: #aaa;
}

.stat i {
  font-size: 0.7rem;
}

.rating {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.rating i {
  color: #ffd700;
  font-size: 0.9rem;
}

.rating-number {
  font-weight: 600;
  color: var(--primary);
  margin-left: 5px;
}

.rating-count {
  font-size: 0.8rem;
  color: #666;
}

.no-rating {
  font-size: 0.8rem;
  color: #999;
  font-style: italic;
}

.buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.buttons button {
  flex: 1;
  min-width: 80px;
  padding: 10px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* Responsive pour les boutons */
@media (max-width: 480px) {
  .buttons {
    flex-direction: column;
  }
  
  .buttons button {
    width: 100%;
  }
}
/* Styles pour les boutons avec sécurité */
.btn-connect-popup {
  background: linear-gradient(135deg, #6c757d, #495057) !important;
  color: white !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

.btn-connect-popup:hover {
  background: linear-gradient(135deg, #5a6268, #3d4348) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Animation de pulsation pour attirer l'attention */
.btn-connect-popup {
  animation: pulse-restricted 2s infinite;
}

@keyframes pulse-restricted {
  0% {
    box-shadow: 0 0 0 0 rgba(108, 117, 125, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(108, 117, 125, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(108, 117, 125, 0);
  }
}

/* Tooltip pour les boutons restreints */
.btn-connect-popup {
  position: relative;
}

.btn-connect-popup::after {
  content: "Connexion requise";
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
}

.btn-connect-popup:hover::after {
  opacity: 1;
  visibility: visible;
}