/**
 * Caly-Quiz IRVE - Thème Habilec Complet
 * Design unifié pour tout le LMS
 * Version 2.1 - Scroll horizontal & esthétique améliorée
 */

/* ============================================
   VARIABLES GLOBALES HABILEC
   ============================================ */
:root {
    /* Couleurs principales Habilec */
    --hab-primary: #f59e0b;
    --hab-primary-dark: #d97706;
    --hab-primary-light: #fbbf24;
    --hab-secondary: #1e3a5f;
    --hab-accent: #e94560;

    /* Fonds */
    --hab-bg-light: #f5f5f5;
    --hab-bg-cream: #fffdf7;
    --hab-bg-white: #ffffff;
    --hab-bg-dark: #1a1a2e;

    /* Textes */
    --hab-text-dark: #1f2937;
    --hab-text-medium: #4b5563;
    --hab-text-light: #6b7280;
    --hab-text-muted: #9ca3af;

    /* Bordures et ombres */
    --hab-border: #e5e7eb;
    --hab-border-light: #f3f4f6;
    --hab-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --hab-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --hab-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --hab-shadow-card: 0 2px 12px rgba(245, 158, 11, 0.15);

    /* États */
    --hab-success: #22c55e;
    --hab-warning: #f59e0b;
    --hab-danger: #ef4444;
    --hab-info: #3b82f6;
}

/* ============================================
   RESET & BASE
   ============================================ */
#lms-parcours-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--hab-bg-light);
    overflow-y: auto;
}

.hab-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#lms-parcours-container *,
#lms-parcours-container *::before,
#lms-parcours-container *::after {
    box-sizing: border-box;
}

/* ============================================
   HEADER HABILEC
   ============================================ */
.hab-header {
    background: var(--hab-bg-white);
    border-bottom: 4px solid var(--hab-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--hab-shadow-sm);
}

.hab-header-inner {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 2.5rem;
}

.hab-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hab-logo-badge {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.hab-logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--hab-secondary);
    letter-spacing: -0.02em;
}

.hab-logo-text span {
    color: #92400e;
}

.hab-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--hab-bg-light);
    padding: 0.25rem;
    border-radius: 10px;
}

.hab-nav-item {
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hab-text-medium);
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hab-nav-item:hover {
    color: #92400e;
}

.hab-nav-item.active {
    color: white;
    background: var(--hab-primary);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.hab-nav-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hab-nav-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--hab-bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hab-text-medium);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.hab-nav-icon:hover {
    background: var(--hab-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.hab-nav-icon svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   PAGE CONTENEUR
   ============================================ */
.hab-page {
    min-height: 100vh;
    background: var(--hab-bg-light);
}

.hab-page-content {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2.5rem 2.5rem 3rem;
}

/* ============================================
   TITRE DE PAGE
   ============================================ */
.hab-page-title {
    text-align: center;
    margin-bottom: 3rem;
}

.hab-page-title h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--hab-text-dark);
    margin: 0 0 0.5rem 0;
}

.hab-page-title p {
    font-size: 1rem;
    color: var(--hab-text-light);
    margin: 0;
    letter-spacing: 0.1em;
}

/* ============================================
   SCROLL HORIZONTAL CONTAINER
   ============================================ */
.hab-scroll-container {
    position: relative;
    margin: 0 -2.5rem;
    padding: 0 2.5rem;
}

.hab-scroll-wrapper {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding: 1rem 0 1.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--hab-primary) var(--hab-border);
}

.hab-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
}

.hab-scroll-wrapper::-webkit-scrollbar-track {
    background: var(--hab-border);
    border-radius: 3px;
}

.hab-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--hab-primary);
    border-radius: 3px;
}

.hab-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--hab-primary-dark);
}

/* Indicateurs de scroll */
.hab-scroll-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hab-text-medium);
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--hab-shadow-md);
    transition: all 0.2s;
}

.hab-scroll-hint:hover {
    background: var(--hab-primary);
    border-color: var(--hab-primary);
    color: white;
}

.hab-scroll-hint.left { left: 0.5rem; }
.hab-scroll-hint.right { right: 0.5rem; }

/* ============================================
   SECTIONS DE CATÉGORIES AVEC COURS
   ============================================ */
.hab-category-section {
    background: var(--hab-bg-white);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    box-shadow: var(--hab-shadow-sm);
    border: 1px solid var(--hab-border);
}

.hab-category-section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    cursor: pointer;
    transition: all 0.2s;
}

.hab-category-section-header:hover {
    filter: brightness(1.05);
}

.hab-category-icon-large {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.hab-category-section-info {
    flex: 1;
}

.hab-category-section-info h2 {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
}

.hab-category-section-info span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

.hab-category-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.3s ease;
}

.hab-category-toggle svg {
    width: 20px;
    height: 20px;
}

.hab-category-toggle.rotated {
    transform: rotate(180deg);
}

.hab-category-courses {
    padding: 1rem;
    background: var(--hab-bg-cream);
    transition: all 0.3s ease;
}

.hab-category-courses.collapsed {
    display: none;
}

.hab-courses-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem 0 1rem;
}

/* ============================================
   CARTE DE COURS
   ============================================ */
.hab-course-card {
    flex: 0 0 280px;
    max-width: 320px;
    background: var(--hab-bg-white);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid var(--hab-border);
}

.hab-course-card:hover {
    border-color: var(--hab-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.2);
}

.hab-course-card.completed {
    border-color: var(--hab-success);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.hab-course-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.hab-course-status {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.hab-course-status.pending {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
}

.hab-course-status.done {
    background: linear-gradient(135deg, var(--hab-success) 0%, #16a34a 100%);
    color: white;
}

.hab-course-card-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hab-text-dark);
    line-height: 1.4;
}

.hab-course-card-info {
    margin-bottom: 0.75rem;
}

.hab-slides-count {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.hab-course-card-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.hab-btn-mini {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid var(--hab-border);
    background: var(--hab-bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--hab-text-medium);
}

.hab-btn-mini:hover {
    border-color: var(--hab-primary);
    color: #92400e;
    background: rgba(245, 158, 11, 0.1);
}

.hab-btn-mini svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   GRILLE DE CATÉGORIES - WRAP RESPONSIVE
   ============================================ */
.hab-categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0.5rem 0 1.5rem;
    justify-content: flex-start;
}

/* ============================================
   CARTE DE CATÉGORIE
   ============================================ */
.hab-category-card {
    flex: 0 0 280px;
    max-width: 320px;
    background: var(--hab-bg-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--hab-shadow-card);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.hab-category-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.2);
}

.hab-category-header {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.hab-category-icon {
    width: 46px;
    height: 46px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    backdrop-filter: blur(4px);
}

.hab-category-info h3 {
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.2rem 0;
    line-height: 1.3;
}

.hab-category-info span {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8rem;
}

.hab-category-body {
    padding: 1.25rem;
    background: var(--hab-bg-cream);
}

.hab-category-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.hab-stat {
    text-align: center;
    flex: 1;
}

.hab-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #92400e;
    line-height: 1;
}

.hab-stat-label {
    font-size: 0.65rem;
    color: var(--hab-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.25rem;
}

.hab-progress-bar {
    height: 5px;
    background: var(--hab-border);
    border-radius: 3px;
    overflow: hidden;
}

.hab-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--hab-success) 0%, #4ade80 100%);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============================================
   GRILLE DE CHAPITRES - SCROLL HORIZONTAL
   ============================================ */
.hab-chapters-container {
    padding: 1.5rem 2.5rem 6rem;
}

.hab-chapters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem 0 2rem;
}

/* ============================================
   CARTE DE CHAPITRE
   ============================================ */
.hab-chapter-card {
    flex: 0 0 360px;
    max-width: 400px;
    background: var(--hab-bg-cream);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--hab-shadow-card);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.hab-chapter-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.2);
}

.hab-chapter-header {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    padding: 1.25rem 1.5rem;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hab-chapter-title {
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
    margin: 0;
}

.hab-chapter-body {
    padding: 1rem 1.25rem;
    max-height: 280px;
    overflow-y: auto;
    background: var(--hab-bg-white);
}

.hab-chapter-body::-webkit-scrollbar {
    width: 4px;
}

.hab-chapter-body::-webkit-scrollbar-thumb {
    background: var(--hab-border);
    border-radius: 2px;
}

/* Liste des leçons */
.hab-lessons-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hab-lesson-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--hab-border-light);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.hab-lesson-item:last-child {
    border-bottom: none;
}

.hab-lesson-item:hover {
    background: rgba(245, 158, 11, 0.08);
}

.hab-lesson-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.hab-lesson-icon {
    width: 22px;
    height: 22px;
    background: var(--hab-primary);
    color: white;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.hab-lesson-title {
    font-size: 0.85rem;
    color: var(--hab-text-dark);
    font-weight: 500;
}

.hab-lesson-check {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.hab-lesson-check.completed {
    background: var(--hab-primary);
    color: white;
}

.hab-lesson-check.pending {
    background: var(--hab-border);
    border: 1px solid var(--hab-border);
}

/* Footer du chapitre */
.hab-chapter-footer {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    background: var(--hab-bg-cream);
    border-top: 1px solid var(--hab-border-light);
}

.hab-btn-play {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.hab-btn-play:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.hab-btn-play svg {
    width: 16px;
    height: 16px;
}

.hab-btn-edit {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-border);
    color: var(--hab-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.hab-btn-edit:hover {
    background: var(--hab-primary);
    border-color: var(--hab-primary);
    color: white;
    transform: scale(1.05);
}

.hab-btn-edit svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   BARRE DE NAVIGATION INFÉRIEURE
   ============================================ */
.hab-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--hab-bg-white);
    border-top: 1px solid var(--hab-border);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.hab-btn-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #92400e;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-primary);
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-btn-back:hover {
    background: var(--hab-primary);
    color: white;
}

.hab-btn-back svg {
    width: 18px;
    height: 18px;
}

.hab-parcours-info {
    text-align: center;
}

.hab-parcours-label {
    font-size: 0.75rem;
    color: var(--hab-text-muted);
    margin-bottom: 0.15rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hab-parcours-name {
    font-size: 1rem;
    font-weight: 700;
    color: #92400e;
}

.hab-btn-play-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #92400e;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-primary);
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-btn-play-all:hover {
    background: var(--hab-primary);
    color: white;
}

.hab-btn-play-all svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   BARRE DE PROGRESSION GLOBALE
   ============================================ */
.hab-global-progress {
    position: fixed;
    bottom: 65px;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--hab-border);
}

.hab-global-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--hab-primary) 0%, var(--hab-primary-light) 100%);
    border-radius: 0 3px 3px 0;
    transition: width 0.5s ease;
}

/* ============================================
   BOUTON CRÉER COURS
   ============================================ */
.hab-btn-create {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1.25rem;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.hab-btn-create:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 25px rgba(245, 158, 11, 0.45);
}

.hab-btn-create svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   SECTION TITRE CATÉGORIES
   ============================================ */
.hab-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.hab-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--hab-text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hab-section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--hab-primary);
    border-radius: 2px;
}

.hab-scroll-nav {
    display: flex;
    gap: 0.5rem;
}

.hab-scroll-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--hab-bg-white);
    border: 1px solid var(--hab-border);
    color: var(--hab-text-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.hab-scroll-btn:hover {
    background: var(--hab-primary);
    border-color: var(--hab-primary);
    color: white;
}

.hab-scroll-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes habSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes habFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes habPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.hab-chapter-card {
    animation: habSlideIn 0.4s ease forwards;
    opacity: 0;
}

.hab-chapter-card:nth-child(1) { animation-delay: 0.05s; }
.hab-chapter-card:nth-child(2) { animation-delay: 0.1s; }
.hab-chapter-card:nth-child(3) { animation-delay: 0.15s; }
.hab-chapter-card:nth-child(4) { animation-delay: 0.2s; }
.hab-chapter-card:nth-child(5) { animation-delay: 0.25s; }
.hab-chapter-card:nth-child(6) { animation-delay: 0.3s; }
.hab-chapter-card:nth-child(7) { animation-delay: 0.35s; }

.hab-category-card {
    animation: habFadeIn 0.35s ease forwards;
    opacity: 0;
}

.hab-category-card:nth-child(1) { animation-delay: 0.05s; }
.hab-category-card:nth-child(2) { animation-delay: 0.1s; }
.hab-category-card:nth-child(3) { animation-delay: 0.15s; }
.hab-category-card:nth-child(4) { animation-delay: 0.2s; }
.hab-category-card:nth-child(5) { animation-delay: 0.25s; }
.hab-category-card:nth-child(6) { animation-delay: 0.3s; }
.hab-category-card:nth-child(7) { animation-delay: 0.35s; }
.hab-category-card:nth-child(8) { animation-delay: 0.4s; }
.hab-category-card:nth-child(9) { animation-delay: 0.45s; }
.hab-category-card:nth-child(10) { animation-delay: 0.5s; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .hab-header-inner {
        padding: 0.75rem 1.5rem;
    }

    .hab-page-content {
        padding: 2rem 1.5rem;
    }

    .hab-chapters-container {
        padding: 1.5rem 1.5rem 6rem;
    }

    .hab-category-card {
        flex: 0 0 260px;
    }

    .hab-course-card {
        flex: 0 0 260px;
    }

    .hab-chapter-card {
        flex: 0 0 320px;
    }
}

@media (max-width: 768px) {
    .hab-course-card {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .hab-category-card {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .hab-header-inner {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        justify-content: center;
    }

    .hab-logo {
        order: 1;
    }

    .hab-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .hab-nav-icons {
        order: 2;
    }

    .hab-page-title h1 {
        font-size: 1.5rem;
    }

    .hab-page-content {
        padding: 1.5rem 1rem;
    }

    .hab-category-card {
        flex: 0 0 260px;
    }

    .hab-chapter-card {
        flex: 0 0 300px;
    }

    .hab-chapters-container {
        padding: 1rem 1rem 7rem;
    }

    .hab-bottom-bar {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .hab-btn-back,
    .hab-btn-play-all {
        flex: 1;
        justify-content: center;
        min-width: 140px;
    }

    .hab-parcours-info {
        width: 100%;
        order: -1;
    }
}

@media (max-width: 480px) {
    .hab-category-card {
        flex: 0 0 calc(100vw - 2rem);
    }

    .hab-chapter-card {
        flex: 0 0 calc(100vw - 2rem);
    }

    .hab-nav-item {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
}

/* ============================================
   ADMINISTRATION — TABLEAU DE GESTION DES COURS
   ============================================ */

/* Logo subtitle */
.hab-logo-subtitle {
    font-size: 0.7rem;
    color: var(--hab-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 6px;
    color: #92400e;
}

/* Barre de recherche admin */
.admin-search-bar {
    max-width: 500px;
    margin: 0 auto 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-border);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    transition: border-color 0.2s;
}

.admin-search-bar:focus-within {
    border-color: var(--hab-primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.admin-search-bar svg {
    flex-shrink: 0;
    color: var(--hab-text-muted);
}

.admin-search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    color: var(--hab-text-dark);
    background: transparent;
    font-family: inherit;
}

.admin-search-bar input::placeholder {
    color: var(--hab-text-muted);
}

/* Tableau admin */
.admin-course-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-course-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--hab-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--hab-border);
    background: rgba(245, 158, 11, 0.03);
}

.admin-course-row {
    transition: background 0.15s;
}

.admin-course-row:hover {
    background: rgba(245, 158, 11, 0.06);
}

.admin-course-row td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--hab-border-light);
    font-size: 0.9rem;
    color: var(--hab-text-dark);
    vertical-align: middle;
}

.admin-course-title {
    font-weight: 600;
    color: var(--hab-text-dark);
    line-height: 1.3;
}

.admin-slides-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.admin-course-date {
    color: var(--hab-text-muted);
    font-size: 0.85rem;
}

/* Boutons d'action admin */
.admin-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.admin-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 2px solid var(--hab-border);
    background: var(--hab-bg-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hab-text-medium);
    transition: all 0.2s;
}

.admin-btn:hover {
    border-color: var(--hab-primary);
    color: #92400e;
    background: rgba(245, 158, 11, 0.08);
    transform: scale(1.08);
}

.admin-btn svg {
    width: 16px;
    height: 16px;
}

/* Category section en mode admin */
.admin-category-section .hab-category-courses {
    padding: 0;
    background: var(--hab-bg-white);
}

/* Responsive admin table */
@media (max-width: 768px) {
    .admin-course-table thead {
        display: none;
    }

    .admin-course-row {
        display: flex;
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--hab-border-light);
    }

    .admin-course-row td {
        border: none;
        padding: 0.25rem 0;
    }

    .admin-course-row td:first-child {
        flex: 1 1 100%;
        font-size: 0.95rem;
    }

    .admin-course-row td:nth-child(2) {
        flex: 0 0 auto;
    }

    .admin-course-row td:nth-child(3) {
        flex: 1;
        text-align: right;
    }

    .admin-course-row td:last-child {
        flex: 0 0 auto;
        margin-left: auto;
    }
}

/* ============================================
   ÉTATS SPÉCIAUX
   ============================================ */
.hab-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--hab-text-muted);
}

.hab-empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--hab-text-muted);
}

.hab-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ============================================
   VIEWER REVEAL.JS - STYLE HABILEC
   ============================================ */

/* Container général du viewer */
#lms-screen.hab-viewer-active {
    background: var(--hab-bg-cream);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
}

/* Cacher le footer et la barre XP quand le viewer est actif */
#lms-screen.hab-viewer-active ~ .app-footer,
.hab-viewer-active ~ .app-footer,
body:has(.hab-viewer-active) .app-footer,
body:has(.hab-viewer-active) .xp-bar-container,
body:has(.hab-viewer-active) #gamification-xp-bar {
    display: none !important;
}

/* Cacher aussi le footer global */
#app:has(.hab-viewer-active) > .app-footer {
    display: none !important;
}

/* Cacher la barre XP dans l'interface LMS Parcours */
body:has(#lms-parcours-container:not(.hidden)) .xp-bar-container,
body:has(#lms-parcours-container:not(.hidden)) #gamification-xp-bar,
#lms-parcours-container:not(.hidden) ~ .xp-bar-container,
#lms-parcours-container:not(.hidden) ~ #gamification-xp-bar {
    display: none !important;
}

/* Cacher la barre XP dans le LMS screen */
body:has(#lms-screen:not(.hidden)) .xp-bar-container,
body:has(#lms-screen:not(.hidden)) #gamification-xp-bar {
    display: none !important;
}

/* Cacher la barre XP quand l'éditeur de cours est ouvert */
body:has(.course-editor-container) .xp-bar-container,
body:has(.course-editor-container) #gamification-xp-bar,
body:has(#course-editor-container:not(.hidden)) .xp-bar-container,
body:has(#course-editor-container:not(.hidden)) #gamification-xp-bar {
    display: none !important;
}

/* Header du viewer */
.hab-viewer-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #ffffff 0%, #fef7ed 100%);
    border-bottom: 3px solid var(--hab-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 2001;
    box-shadow: 0 2px 15px rgba(245, 158, 11, 0.15);
}

.hab-viewer-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hab-viewer-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-primary);
    border-radius: 8px;
    color: #92400e;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-viewer-back:hover {
    background: var(--hab-primary);
    color: white;
    transform: translateX(-3px);
}

.hab-viewer-back svg {
    width: 18px;
    height: 18px;
}

.hab-viewer-title {
    display: flex;
    flex-direction: column;
}

.hab-viewer-title h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--hab-secondary);
    margin: 0;
    line-height: 1.2;
}

.hab-viewer-title span {
    font-size: 0.8rem;
    color: var(--hab-text-muted);
}

.hab-viewer-header-center {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.hab-viewer-progress-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
}

.hab-viewer-slide-number {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: #92400e;
}

.hab-viewer-slide-number span {
    color: var(--hab-text-muted);
    font-weight: 400;
}

.hab-viewer-progress-bar {
    width: 150px;
    height: 8px;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.hab-viewer-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--hab-primary) 0%, var(--hab-accent) 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.hab-viewer-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.hab-viewer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--hab-bg-white);
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    color: var(--hab-text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-viewer-btn:hover {
    border-color: var(--hab-primary);
    color: #92400e;
    transform: scale(1.05);
}

.hab-viewer-btn.active {
    background: var(--hab-primary);
    border-color: var(--hab-primary);
    color: white;
}

.hab-viewer-btn svg {
    width: 20px;
    height: 20px;
}

.hab-viewer-close {
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hab-viewer-close:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Barre de contrôle inférieure */
.hab-viewer-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(135deg, #ffffff 0%, #fef7ed 100%);
    border-top: 3px solid var(--hab-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 2001;
    box-shadow: 0 -2px 15px rgba(245, 158, 11, 0.15);
}

.hab-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: var(--hab-bg-white);
    border: 2px solid var(--hab-primary);
    border-radius: 12px;
    color: #92400e;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hab-nav-btn:hover:not(:disabled) {
    background: var(--hab-primary);
    color: white;
    transform: scale(1.1);
}

.hab-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hab-nav-btn svg {
    width: 24px;
    height: 24px;
}

.hab-nav-btn.prev svg {
    transform: rotate(180deg);
}

.hab-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

.hab-play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(245, 158, 11, 0.5);
}

.hab-play-btn svg {
    width: 28px;
    height: 28px;
}

.hab-controls-divider {
    width: 2px;
    height: 30px;
    background: rgba(245, 158, 11, 0.3);
    border-radius: 1px;
}

.hab-zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(245, 158, 11, 0.1);
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
}

.hab-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--hab-bg-white);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: var(--hab-text-dark);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.hab-zoom-btn:hover {
    border-color: var(--hab-primary);
    color: #92400e;
}

.hab-zoom-label {
    min-width: 45px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #92400e;
}

/* Drawer latéral style Habilec */
.lms-drawer.hab-drawer {
    background: linear-gradient(180deg, #ffffff 0%, #fef7ed 100%);
    border-right: 3px solid var(--hab-primary);
}

.lms-drawer.hab-drawer .drawer-header {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    border-bottom: none;
}

.lms-drawer.hab-drawer .drawer-header h3 {
    color: white;
}

.lms-drawer.hab-drawer .drawer-header .btn-icon {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border: none;
}

.lms-drawer.hab-drawer .drawer-header .btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lms-drawer.hab-drawer #drawer-search {
    background: var(--hab-bg-white);
    border: 2px solid #e5e7eb;
    color: var(--hab-text-dark);
}

.lms-drawer.hab-drawer #drawer-search:focus {
    border-color: var(--hab-primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.lms-drawer.hab-drawer #drawer-search::placeholder {
    color: var(--hab-text-muted);
}

.lms-drawer.hab-drawer .toc-section-title {
    color: var(--hab-secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(245, 158, 11, 0.3);
}

.lms-drawer.hab-drawer .toc-item {
    margin-bottom: 0.25rem;
}

.lms-drawer.hab-drawer .toc-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--hab-text-dark);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.lms-drawer.hab-drawer .toc-link::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--hab-primary);
    border-radius: 50%;
    opacity: 0.5;
    transition: all 0.2s ease;
}

.lms-drawer.hab-drawer .toc-link:hover {
    background: rgba(245, 158, 11, 0.1);
}

.lms-drawer.hab-drawer .toc-link:hover::before {
    opacity: 1;
    transform: scale(1.2);
}

.lms-drawer.hab-drawer .toc-link.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
    color: #92400e;
    font-weight: 600;
}

.lms-drawer.hab-drawer .toc-link.active::before {
    opacity: 1;
    background: var(--hab-accent);
}

.lms-drawer.hab-drawer .toc-link.completed::after {
    content: '✓';
    margin-left: auto;
    color: var(--hab-success);
    font-weight: 700;
}

.lms-drawer.hab-drawer .drawer-footer {
    background: rgba(245, 158, 11, 0.05);
    border-top: 2px solid rgba(245, 158, 11, 0.2);
}

.lms-drawer.hab-drawer .drawer-footer .btn-secondary {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.lms-drawer.hab-drawer .drawer-footer .btn-secondary:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

/* Bouton toggle drawer style Habilec */
.drawer-toggle.hab-toggle {
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    font-weight: 600;
    box-shadow: 2px 2px 10px rgba(245, 158, 11, 0.3);
}

.drawer-toggle.hab-toggle:hover {
    transform: translateX(3px);
}

/* ===========================================
   VIEWER HABILEC - MODE SANS SCALING (Option 1)
   Scale = 1.0 pour permettre le scroll CSS natif
   =========================================== */

/* Conteneur principal - positionné entre header (60px) et footer (70px) */
#lms-screen.hab-viewer-active #reveal-container {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 70px !important;
    width: 100% !important;
    height: calc(100vh - 130px) !important;
    z-index: 1500 !important;
    overflow: hidden !important;
}

#lms-screen.hab-viewer-active .reveal-viewport {
    background: var(--hab-bg-cream) !important;
}

/* Reveal en mode sans scaling - slides scrollables */
#lms-screen.hab-viewer-active .reveal {
    width: 100% !important;
    height: 100% !important;
}

#lms-screen.hab-viewer-active .reveal .slides {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    /* Réinitialiser complètement Reveal.js */
    transform: none !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    position: absolute !important;
    display: flex !important;
    justify-content: center !important;
    /* Centrage VERTICAL aussi */
    align-items: center !important;
    /* Supprimer le padding-top XP bar (cachée en mode LMS) */
    padding-top: 0 !important;
}

/* Section de slide - LARGE, responsive et CENTRÉ */
#lms-screen.hab-viewer-active .reveal .slides section {
    /* Largeur maximale - marges reduites ~2cm (20px) de chaque cote */
    width: calc(100% - 40px) !important;
    max-width: none !important;
    padding: 20px 25px 25px !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(100vh - 130px) !important;
    scrollbar-width: thin;
    scrollbar-color: var(--hab-primary) rgba(0,0,0,0.1);
    /* Centrage avec flexbox - pas de transform */
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    margin: 0 auto !important;
}

/* ==========================================
   TYPOGRAPHIE RESPONSIVE - Texte sur une ligne
   ========================================== */

/* Tailles de base responsive avec clamp() */
#lms-screen.hab-viewer-active .reveal .slides section {
    font-size: clamp(14px, 1.5vw, 20px) !important;
}

/* Titres H1 - jamais de retour à la ligne */
#lms-screen.hab-viewer-active .reveal h1 {
    font-size: clamp(24px, 3.5vw, 48px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    line-height: 1.2 !important;
    margin-bottom: 15px !important;
}

/* Titres H2 - sur une ligne */
#lms-screen.hab-viewer-active .reveal h2 {
    font-size: clamp(18px, 2.5vw, 32px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    line-height: 1.25 !important;
    margin-bottom: 12px !important;
}

/* Titres H3 */
#lms-screen.hab-viewer-active .reveal h3 {
    font-size: clamp(16px, 2vw, 26px) !important;
    line-height: 1.3 !important;
    margin-bottom: 10px !important;
}

/* Paragraphes et listes - texte fluide */
#lms-screen.hab-viewer-active .reveal p,
#lms-screen.hab-viewer-active .reveal li {
    font-size: clamp(14px, 1.4vw, 20px) !important;
    line-height: 1.5 !important;
    margin-bottom: 8px !important;
}

/* Listes - espacement réduit */
#lms-screen.hab-viewer-active .reveal ul,
#lms-screen.hab-viewer-active .reveal ol {
    margin-left: 1.2em !important;
}

#lms-screen.hab-viewer-active .reveal ul li {
    padding-left: 1em !important;
    margin-bottom: 6px !important;
}

/* Tableaux responsive */
#lms-screen.hab-viewer-active .reveal table {
    font-size: clamp(12px, 1.2vw, 16px) !important;
    width: 100% !important;
}

#lms-screen.hab-viewer-active .reveal table th,
#lms-screen.hab-viewer-active .reveal table td {
    padding: clamp(6px, 0.8vw, 12px) clamp(8px, 1vw, 16px) !important;
    white-space: nowrap !important;
}

/* Blockquotes */
#lms-screen.hab-viewer-active .reveal blockquote {
    font-size: clamp(14px, 1.3vw, 18px) !important;
    padding: 15px 20px !important;
    margin: 15px auto !important;
}

/* Scrollbar personnalisée */
#lms-screen.hab-viewer-active .reveal .slides section::-webkit-scrollbar {
    width: 10px;
}

#lms-screen.hab-viewer-active .reveal .slides section::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-radius: 5px;
}

#lms-screen.hab-viewer-active .reveal .slides section::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    border-radius: 5px;
}

#lms-screen.hab-viewer-active .reveal .slides section::-webkit-scrollbar-thumb:hover {
    background: var(--hab-primary-dark);
}

/* Indicateur de scroll pour contenu long — apparait brievement puis disparait */
#lms-screen.hab-viewer-active .reveal .slides section.has-overflow::after {
    content: '▼ Défiler pour voir plus';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--hab-primary) 0%, var(--hab-primary-dark) 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 12px;
    font-weight: 600;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    opacity: 0;
    animation: habScrollHint 3.5s ease-in-out forwards;
}

@keyframes habScrollHint {
    0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    10% { opacity: 0.9; transform: translateX(-50%) translateY(0); }
    70% { opacity: 0.9; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* Masquer immediatement au scroll ou apres l'animation */
#lms-screen.hab-viewer-active .reveal .slides section.has-overflow.scrolled::after {
    display: none;
}

/* Slide active - centrée avec flexbox */
#lms-screen.hab-viewer-active .reveal .slides > section.present {
    transform: none !important;
    display: block !important;
}

/* Slides non-actives masquées */
#lms-screen.hab-viewer-active .reveal .slides > section:not(.present) {
    display: none !important;
    visibility: hidden !important;
}

/* Hide default Reveal controls quand Habilec active */
#lms-screen.hab-viewer-active .reveal .controls,
#lms-screen.hab-viewer-active .reveal .navigate-left,
#lms-screen.hab-viewer-active .reveal .navigate-right,
#lms-screen.hab-viewer-active .reveal .navigate-up,
#lms-screen.hab-viewer-active .reveal .navigate-down {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#lms-screen.hab-viewer-active .reveal .progress {
    display: none !important;
}

/* Cacher le bouton Menu drawer quand le viewer Habilec est actif */
#lms-screen.hab-viewer-active #drawer-toggle,
#lms-screen.hab-viewer-active .drawer-toggle,
#lms-screen.hab-viewer-active #right-drawer-toggle {
    display: none !important;
}

/* Cacher les contrôles de zoom par défaut */
#lms-screen.hab-viewer-active #zoom-controls {
    display: none !important;
}

#lms-screen.hab-viewer-active .reveal .slide-number {
    display: none;
}

/* Responsive viewer */
@media (max-width: 900px) {
    .hab-viewer-header {
        height: 50px;
        padding: 0 1rem;
    }

    .hab-viewer-title h2 {
        font-size: 0.95rem;
    }

    .hab-viewer-progress-info {
        display: none;
    }

    .hab-viewer-controls {
        height: 60px;
        gap: 1rem;
    }

    .hab-nav-btn {
        width: 44px;
        height: 44px;
    }

    .hab-play-btn {
        width: 52px;
        height: 52px;
    }

    .hab-zoom-controls {
        display: none;
    }

    #lms-screen.hab-viewer-active .reveal {
        top: 50px !important;
        bottom: 60px !important;
        height: calc(100vh - 110px) !important;
    }

    #lms-screen.hab-viewer-active #reveal-container {
        top: 50px !important;
        bottom: 60px !important;
        height: calc(100vh - 110px) !important;
    }

    /* Sidebar plus petite sur tablette */
    .floating-sidebar {
        width: 110px;
    }
    .floating-vignette {
        padding: 6px;
    }
    .floating-vignette img {
        max-width: 80px;
        max-height: 90px;
    }
    .floating-resources-list a {
        font-size: 0.55rem;
    }

    #lms-screen.hab-viewer-active .reveal .slides section {
        max-height: calc(100vh - 130px) !important;
    }
}

@media (max-width: 600px) {
    .hab-viewer-header-left {
        gap: 0.5rem;
    }

    .hab-viewer-back span {
        display: none;
    }

    .hab-viewer-title {
        max-width: 150px;
    }

    .hab-viewer-title h2 {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hab-viewer-title span {
        display: none;
    }

    .hab-viewer-header-right .hab-viewer-btn:not(:last-child) {
        display: none;
    }

    .hab-viewer-close span {
        display: none;
    }

    /* Mobile : sidebar cachée */
    .floating-sidebar {
        display: none !important;
    }
}

/* ===== SIDEBAR FLOTTANTE (overlay coin supérieur droit) ===== */
.floating-sidebar {
    position: fixed;
    top: 70px;
    right: 12px;
    width: 140px;
    z-index: 2100;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none; /* le conteneur ne bloque pas les clics */
}
.floating-sidebar > * {
    pointer-events: auto; /* les enfants reçoivent les clics */
}

/* --- Vignette image --- */
.floating-vignette {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px 6px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: opacity 0.25s ease;
}

.floating-vignette img {
    max-width: 120px;
    max-height: 140px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    border: 2px solid rgba(245, 158, 11, 0.3);
    cursor: zoom-in;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.floating-vignette img:hover {
    transform: scale(1.08);
    border-color: rgba(245, 158, 11, 0.7);
}

.floating-vignette-label {
    color: var(--hab-text-light);
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.2s;
}

.floating-vignette-label:hover {
    color: #92400e;
}

/* --- Menu ressources flottant --- */
.floating-resources {
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: opacity 0.25s ease;
}

.floating-resources-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.floating-resources-toggle:hover {
    background: rgba(245, 158, 11, 0.1);
}

.floating-resources-icon {
    font-size: 0.75rem;
}

#floating-resources-count {
    color: #92400e;
    font-size: 0.65rem;
    font-weight: 500;
    flex: 1;
}

.floating-resources-arrow {
    color: var(--hab-text-light);
    font-size: 0.55rem;
    transition: transform 0.2s ease;
}

.floating-resources-arrow.open {
    transform: rotate(180deg);
}

.floating-resources-list {
    border-top: 1px solid rgba(245, 158, 11, 0.15);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 200px;
    overflow-y: auto;
}

.floating-resources-list a {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 6px;
    color: #92400e;
    text-decoration: none;
    font-size: 0.6rem;
    line-height: 1.2;
    transition: background 0.2s;
    word-break: break-word;
}

.floating-resources-list a:hover {
    background: rgba(245, 158, 11, 0.1);
    color: var(--hab-text-dark);
}

.floating-resources-list a .res-icon {
    flex-shrink: 0;
    font-size: 0.7rem;
}

/* ═══════════════════════════════════════════════════
   FULLSCREEN MODE — Vrai plein écran + fallback CSS
   ═══════════════════════════════════════════════════ */

/* Vrais plein écran natif (Fullscreen API) */
#lms-screen:fullscreen,
#lms-screen:-webkit-full-screen,
#lms-screen:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    background: var(--hab-bg-cream, #faf9f6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#lms-screen:fullscreen .hab-viewer-header,
#lms-screen:-webkit-full-screen .hab-viewer-header {
    z-index: 100;
    flex-shrink: 0;
}

#lms-screen:fullscreen #reveal-container,
#lms-screen:-webkit-full-screen #reveal-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

#lms-screen:fullscreen .hab-viewer-controls,
#lms-screen:-webkit-full-screen .hab-viewer-controls {
    z-index: 100;
    flex-shrink: 0;
}

/* Backdrop */
#lms-screen::backdrop {
    background: #1a1a2e;
}

/* Fallback CSS "faux plein écran" pour navigateurs sans Fullscreen API */
#lms-screen.fake-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 99999 !important;
    background: var(--hab-bg-cream, #faf9f6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

#lms-screen.fake-fullscreen .hab-viewer-header {
    z-index: 100;
    flex-shrink: 0;
}

#lms-screen.fake-fullscreen #reveal-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

#lms-screen.fake-fullscreen .hab-viewer-controls {
    z-index: 100;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   Panneau Ressources (sous les slides)
   ═══════════════════════════════════════════════════ */

.hab-resources-panel {
    background: #1a2236;
    border-top: 1px solid #2d3a50;
    flex-shrink: 0;
    z-index: 50;
}

.hab-resources-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
    text-align: left;
}

.hab-resources-toggle:hover {
    background: rgba(255,255,255,0.04);
    color: #e2e8f0;
}

.hab-resources-toggle-icon {
    font-size: 1.1rem;
}

.hab-resources-count {
    background: #3b82f6;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.hab-resources-chevron {
    margin-left: auto;
    transition: transform 0.3s;
}

.hab-resources-panel.open .hab-resources-chevron {
    transform: rotate(180deg);
}

.hab-resources-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding: 0 20px;
}

.hab-resources-panel.open .hab-resources-body {
    max-height: 500px;
    padding: 0 20px 16px;
    overflow-y: auto;
}

.hab-res-section h4 {
    color: #60a5fa;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 10px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hab-res-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hab-res-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.hab-res-card:hover {
    background: #334155;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59,130,246,0.15);
}

.hab-res-card.hab-res-api {
    border-color: #475569;
}

.hab-res-card.hab-res-api:hover {
    border-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245,158,11,0.15);
}

.hab-res-icon {
    font-size: 1.1rem;
}

.hab-res-icon-api {
    font-size: 0.7rem;
    font-weight: 800;
    background: #f59e0b;
    color: #1a1a2e;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.hab-res-title {
    font-weight: 500;
}

.hab-res-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #334155;
    border-radius: 6px;
    font-size: 0.78rem;
    color: #94a3b8;
    margin: 3px;
}

@media (max-width: 768px) {
    .hab-res-grid {
        flex-direction: column;
    }
    .hab-res-card {
        white-space: normal;
    }
}

/* ============================================================
   MOBILE COMPACT (≤480px) — slide viewer fully fitted
   ============================================================ */
@media (max-width: 480px) {
    /* ── HEADER (back / title / close) ── */
    .hab-viewer-header {
        height: 44px !important;
        padding: 0 0.5rem !important;
    }
    .hab-viewer-back {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
        border-width: 1.5px !important;
        border-radius: 6px !important;
        gap: 0.25rem !important;
    }
    .hab-viewer-back svg {
        width: 14px !important;
        height: 14px !important;
    }
    .hab-viewer-title { max-width: 50% !important; }
    .hab-viewer-title h2 {
        font-size: 0.78rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .hab-viewer-header-right { gap: 0.25rem !important; }
    .hab-viewer-btn {
        width: 30px !important;
        height: 30px !important;
        border-radius: 6px !important;
        border-width: 1.5px !important;
    }
    .hab-viewer-btn svg {
        width: 14px !important;
        height: 14px !important;
    }
    .hab-viewer-close {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.7rem !important;
        border-radius: 6px !important;
        gap: 0.25rem !important;
    }
    .hab-viewer-close svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* ── BOTTOM CONTROLS (prev / play / next) ── */
    .hab-viewer-controls {
        height: 52px !important;
        gap: 0.6rem !important;
        padding: 0 0.5rem !important;
    }
    .hab-nav-btn {
        width: 36px !important;
        height: 36px !important;
        border-width: 1.5px !important;
        border-radius: 8px !important;
    }
    .hab-nav-btn svg {
        width: 16px !important;
        height: 16px !important;
    }
    .hab-play-btn {
        width: 42px !important;
        height: 42px !important;
        box-shadow: 0 2px 10px rgba(245,158,11,0.4) !important;
    }
    .hab-play-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    .hab-progress-text { font-size: 0.7rem !important; }

    /* ── REVEAL container reserves correct space ── */
    #lms-screen.hab-viewer-active #reveal-container,
    #lms-screen.hab-viewer-active .reveal {
        top: 44px !important;
        bottom: 52px !important;
        height: calc(100vh - 96px) !important;
    }
    #lms-screen.hab-viewer-active .reveal .slides section {
        width: calc(100% - 12px) !important;
        padding: 10px 8px 12px !important;
        max-height: calc(100vh - 96px) !important;
        font-size: 13px !important;
    }
    #lms-screen.hab-viewer-active .reveal h1 {
        font-size: 18px !important;
        white-space: normal !important;
        overflow: visible !important;
        margin-bottom: 8px !important;
    }
    #lms-screen.hab-viewer-active .reveal h2 {
        font-size: 15px !important;
        white-space: normal !important;
        overflow: visible !important;
        margin-bottom: 6px !important;
    }
    #lms-screen.hab-viewer-active .reveal h3 {
        font-size: 13px !important;
        margin-bottom: 5px !important;
    }
    #lms-screen.hab-viewer-active .reveal p,
    #lms-screen.hab-viewer-active .reveal li {
        font-size: 12px !important;
        line-height: 1.4 !important;
        margin-bottom: 5px !important;
    }
    /* Tables: allow horizontal scroll instead of being cropped */
    #lms-screen.hab-viewer-active .reveal table {
        font-size: 11px !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
    #lms-screen.hab-viewer-active .reveal table th,
    #lms-screen.hab-viewer-active .reveal table td {
        padding: 4px 6px !important;
    }
    /* Pre/code blocks scroll horizontally too */
    #lms-screen.hab-viewer-active .reveal pre,
    #lms-screen.hab-viewer-active .reveal code {
        font-size: 10px !important;
        max-width: 100% !important;
        overflow-x: auto !important;
    }

    /* ── FLOATING TRAINER FAB (graduate cap) ── */
    .trainer-fab {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.05rem !important;
        bottom: 60px !important;
        right: 12px !important;
        box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4) !important;
    }

    /* Hide non-essential header buttons on tiny screens */
    .hab-zoom-controls { display: none !important; }
}
