/* ============================================================
   LMS - Styles Globaux
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ---- Compatibilite multi-navigateurs (Chrome, Firefox, Safari, iOS, Mac) ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
/* Defilement fluide sur iOS */
.sidebar, .main-content, .content-area, .table-responsive,
.card-body, .modal-body { -webkit-overflow-scrolling: touch; }
/* Eviter le zoom auto sur les champs au focus (iOS Safari) : police >= 16px sur mobile */
@media (max-width: 576px) {
    input, select, textarea, .form-control, .form-select, .form-control-lms {
        font-size: 16px !important;
    }
}
/* Images jamais plus larges que leur conteneur */
img { max-width: 100%; height: auto; }


:root {
    --primary:       #1a3c6e;
    --primary-light: #2563a8;
    --primary-dark:  #0f2447;
    --accent:        #f97316;
    --accent-light:  #fb923c;
    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #0284c7;

    --bg-main:       #f0f4f8;
    --bg-card:       #ffffff;
    --bg-sidebar:    #0f2447;

    --text-primary:  #1e293b;
    --text-secondary:#64748b;
    --text-muted:    #94a3b8;
    --text-white:    #ffffff;

    --border-color:  #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 20px;

    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
    --shadow-lg:     0 10px 30px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
    --shadow-xl:     0 20px 50px rgba(0,0,0,.15);

    --transition:    all .25s cubic-bezier(.4,0,.2,1);
    --transition-fast: all .15s ease;

    --sidebar-width: 260px;
    --topbar-height: 68px;

    --font-main: 'DM Sans', sans-serif;
    --font-display: 'Sora', sans-serif;
}

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

body {
    font-family: var(--font-main);
    font-size: 14.5px;
    color: var(--text-primary);
    background: var(--bg-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1000;
    overflow-y: auto;
    transition: var(--transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .brand-logo {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: white;
    flex-shrink: 0;
}
.sidebar-brand .brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    color: white;
    font-size: 15px;
    line-height: 1.2;
}
.sidebar-brand .brand-text span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,.5);
    margin-top: 2px;
}

.sidebar-section {
    padding: 20px 12px 8px;
}
.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,.35);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 0 10px;
    margin-bottom: 6px;
}

.nav-item-sidebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
}
.nav-item-sidebar:hover {
    background: rgba(255,255,255,.08);
    color: white;
}
.nav-item-sidebar.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(249,115,22,.35);
}
.nav-item-sidebar .nav-icon {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
    font-size: 15px;
    flex-shrink: 0;
    transition: var(--transition-fast);
}
.nav-item-sidebar.active .nav-icon {
    background: rgba(255,255,255,.2);
}
.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}
.nav-item-sidebar.active .nav-badge { background: rgba(255,255,255,.3); }

.sidebar-user {
    position: sticky;
    bottom: 0;
    background: var(--primary-dark);
    padding: 14px 16px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: 12.5px; font-weight: 600; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 10.5px; color: rgba(255,255,255,.45);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: var(--transition);
    overflow-x: hidden;
}

/* Layout alternatif utilise par certaines pages (groupes, themes, etc.) */
/* IMPORTANT: pas d'overflow-x ici car la sidebar fixed est enfant de .app-wrapper */
.app-wrapper {
    display: block;
    min-height: 100vh;
}
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}
.content-area {
    padding: 28px;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}
/* Les tableaux larges defilent a l'interieur au lieu de pousser la page */
.content-area .table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* Overlay sombre quand la sidebar est ouverte sur mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 36, 71, .5);
    z-index: 999;
    opacity: 0;
    transition: opacity .25s ease;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}
.topbar-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    text-decoration: none;
}
.topbar-btn:hover { background: var(--bg-main); color: var(--primary); border-color: var(--primary-light); }
.notification-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid white;
}

.page-content {
    padding: 28px;
}

/* ============================================================
   CARDS & STATS
   ============================================================ */
.card-lms {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}
.card-lms:hover { box-shadow: var(--shadow-md); }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--stat-color, var(--primary));
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}
.stat-change {
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 6px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   RESSOURCE CARDS
   ============================================================ */
.resource-card {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}
.resource-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

.resource-cover {
    height: 160px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
    font-size: 52px;
    color: rgba(255,255,255,.8);
    position: relative;
    overflow: hidden;
}
.resource-cover img {
    width: 100%; height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0; left: 0;
}
.resource-type-badge {
    position: absolute;
    top: 10px; right: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
.type-book { background: rgba(37,99,168,.85); color: white; }
.type-ebook { background: rgba(22,163,74,.85); color: white; }
.type-video { background: rgba(220,38,38,.85); color: white; }

.resource-body { padding: 16px; }
.resource-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.resource-author {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.resource-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ============================================================
   TABLES
   ============================================================ */
.table-lms {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.table-lms thead th {
    padding: 12px 16px;
    background: var(--bg-main);
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .6px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.table-lms tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}
.table-lms tbody tr:last-child { border-bottom: none; }
.table-lms tbody tr:hover { background: rgba(26,60,110,.025); }
.table-lms td { padding: 13px 16px; vertical-align: middle; font-size: 13.5px; }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge-lms {
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge-primary   { background: #dbeafe; color: #1d4ed8; }
.badge-success   { background: #dcfce7; color: #15803d; }
.badge-warning   { background: #fef9c3; color: #a16207; }
.badge-danger    { background: #fee2e2; color: #b91c1c; }
.badge-info      { background: #e0f2fe; color: #0369a1; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 7px;
}
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-control-lms {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-main);
    font-size: 13.5px;
    color: var(--text-primary);
    background: white;
    transition: var(--transition-fast);
    outline: none;
}
.form-control-lms:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,.12);
}
.form-control-lms::placeholder { color: var(--text-muted); }
select.form-control-lms { cursor: pointer; }
textarea.form-control-lms { resize: vertical; min-height: 90px; }

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-fast);
    background: var(--bg-main);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-light);
    background: #eff6ff;
}
.upload-zone .upload-icon {
    font-size: 36px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-lms {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-family: var(--font-main);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}
.btn-lms:active { transform: scale(.97); }
.btn-primary-lms {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(26,60,110,.25);
}
.btn-primary-lms:hover { background: var(--primary-light); box-shadow: 0 4px 14px rgba(26,60,110,.3); }
.btn-accent-lms {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(249,115,22,.25);
}
.btn-accent-lms:hover { background: var(--accent-light); }
.btn-outline-lms {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline-lms:hover { background: var(--primary); color: white; }
.btn-danger-lms { background: var(--danger); color: white; }
.btn-danger-lms:hover { background: #b91c1c; }
.btn-sm-lms { padding: 6px 12px; font-size: 12px; }
.btn-icon {
    width: 34px; height: 34px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-icon:hover { background: var(--bg-main); color: var(--primary); border-color: var(--primary); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-lms {
    height: 7px;
    background: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
}
.progress-bar-lms {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    transition: width .6s ease;
}
.progress-bar-success { background: linear-gradient(90deg, var(--success) 0%, #22c55e 100%); }
.progress-bar-warning { background: linear-gradient(90deg, var(--warning) 0%, #f59e0b 100%); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,36,71,.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px) scale(.97);
    transition: transform .25s ease;
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
.modal-header {
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 14px;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    flex: 1;
}
.modal-close {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none; background: var(--bg-main);
    cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.modal-close:hover { background: #fee2e2; color: var(--danger); }
.modal-body { padding: 22px 24px; }
.modal-footer {
    padding: 16px 24px 22px;
    border-top: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
    position: relative;
    flex: 1;
    max-width: 360px;
}
@media (max-width: 768px) {
    /* Sur mobile la barre de recherche est masquee par defaut, affichee au clic */
    .topbar .search-bar { display: none; position: absolute; top: var(--topbar-height); left: 0; right: 0; max-width: none; padding: 10px 16px; background: white; box-shadow: var(--shadow-md); z-index: 99; }
    .topbar .search-bar.mobile-visible { display: block; }
}
.search-bar input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 13px;
    background: var(--bg-main);
    outline: none;
    transition: var(--transition-fast);
}
.search-bar input:focus { border-color: var(--primary-light); background: white; }
.search-bar .search-icon {
    position: absolute;
    left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}
.section-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}
.section-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* ============================================================
   ALERT
   ============================================================ */
.alert-lms {
    padding: 13px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}
.alert-success { background: #dcfce7; color: #15803d; border-left: 3px solid #16a34a; }
.alert-danger   { background: #fee2e2; color: #b91c1c; border-left: 3px solid #dc2626; }
.alert-warning  { background: #fef9c3; color: #a16207; border-left: 3px solid #d97706; }
.alert-info     { background: #e0f2fe; color: #0369a1; border-left: 3px solid #0284c7; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: white;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================================
   TABS
   ============================================================ */
.tabs-lms {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    gap: 4px;
    margin-bottom: 24px;
}
.tab-btn {
    padding: 10px 18px;
    border: none; background: transparent;
    font-family: var(--font-main);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition-fast);
    display: flex; align-items: center; gap: 7px;
    border-radius: 8px 8px 0 0;
}
.tab-btn:hover { color: var(--primary); background: var(--bg-main); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}
.empty-state .empty-icon {
    font-size: 60px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: block;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.empty-state p { font-size: 13.5px; color: var(--text-secondary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Bouton hamburger (cache sur desktop) */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: var(--transition-fast);
}
.mobile-menu-btn:hover { background: var(--bg-main); }

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%) !important;
        box-shadow: var(--shadow-xl);
    }
    .sidebar.open { transform: translateX(0) !important; }

    /* Les deux systemes de layout repassent en pleine largeur */
    .main-wrapper,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .topbar { padding: 0 16px; }
    .page-content,
    .content-area { padding: 16px; }

    .mobile-menu-btn { display: inline-flex; align-items: center; }

    /* Le bouton toggle d'origine reste cache au profit du hamburger topbar */
    #sidebarToggle { display: inline-flex !important; }
}

@media (max-width: 768px) {
    .content-area,
    .page-content { padding: 14px; }

    .page-title { font-size: 20px; }

    /* Les grilles de cartes passent en 1 colonne */
    .row > [class*="col-"] { margin-bottom: 4px; }

    /* Tableaux scrollables horizontalement */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Topbar plus compacte */
    .topbar-title { font-size: 15px; }
    .welcome-title { font-size: 20px !important; }
}

@media (max-width: 576px) {
    .stat-card { flex-direction: row; text-align: left; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }

    /* Boutons d'action pleine largeur sur mobile */
    .content-area .btn-primary,
    .page-content .btn-primary { white-space: nowrap; }

    /* Reduit les paddings des cartes */
    .card-body { padding: 16px; }

    /* Modales plein ecran sur petit mobile */
    .modal-dialog { margin: 8px; }

    /* Stats en grille 2 colonnes */
    .stat-value { font-size: 20px; }

    /* Cache les elements secondaires de la topbar */
    .topbar-actions .search-bar { display: none !important; }
}

/* Tres petits ecrans */
@media (max-width: 380px) {
    .content-area, .page-content { padding: 10px; }
    .display-6 { font-size: 1.5rem; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: rgba(255,255,255,.04);
    top: -200px; right: -200px;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(249,115,22,.08);
    bottom: -100px; left: -100px;
}
.login-card {
    background: white;
    border-radius: 24px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}
.login-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: white;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(26,60,110,.3);
}
.login-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
}
.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

/* ============================================================
   CANDIDAT FRONT STYLES
   ============================================================ */
.candidat-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    padding: 18px 28px;
    display: flex; align-items: center; gap: 16px;
    position: sticky; top: 0; z-index: 100;
}
.course-hero {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 48px 32px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}
.course-hero::after {
    content: '📚';
    position: absolute;
    right: 32px; top: 50%;
    transform: translateY(-50%);
    font-size: 80px;
    opacity: .15;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp .4s ease both; }
.delay-1 { animation-delay: .1s; }
.delay-2 { animation-delay: .2s; }
.delay-3 { animation-delay: .3s; }

/* ============================================================
   RESPONSIVE GLOBAL RENFORCÉ — tous appareils (PC/tablette/mobile)
   ============================================================ */

/* --- Empêcher tout débordement horizontal sur toute l'app --- */
html, body { max-width: 100%; overflow-x: hidden; }
* { box-sizing: border-box; }
img, video, iframe, canvas, object, table { max-width: 100%; }

/* --- Navigation candidat (barre custom en dégradé) --- */
@media (max-width: 992px) {
    .candidat-nav { padding: 0 14px !important; gap: 10px !important; }
    .candidat-nav .brand { font-size: 15px !important; }
    .candidat-nav .nav-links a span,
    .candidat-nav .nav-links a:not(.active) { font-size: 12.5px; }
}
@media (max-width: 768px) {
    /* La nav candidat devient scrollable horizontalement plutôt que de casser */
    .candidat-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .candidat-nav::-webkit-scrollbar { display: none; }
    .candidat-nav .nav-links { gap: 2px !important; }
    .candidat-nav .nav-links a { padding: 6px 9px !important; font-size: 12px !important; }
    /* Le conteneur principal des pages candidat passe en pleine largeur */
    .candidat-nav + div,
    [style*="max-width:1200px"],
    [style*="max-width: 1200px"],
    [style*="max-width:1100px"],
    [style*="max-width: 1100px"] {
        max-width: 100% !important;
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
}

/* --- Lecteur PDF / vidéo : hauteur adaptative --- */
@media (max-width: 992px) {
    #pdfjs-container { height: 70vh !important; }
    .pdf-viewer { height: 70vh !important; }
}
@media (max-width: 768px) {
    #pdfjs-container { height: 60vh !important; }
    .pdf-viewer { height: 60vh !important; }
    #pdfjs-pages canvas { max-width: 99% !important; }
}

/* --- Cartes ressources (bibliothèque) : grille fluide --- */
@media (max-width: 576px) {
    .res-cover { height: 110px !important; }
    .res-card { border-radius: 12px !important; }
}

/* --- Tableaux : toujours scrollables, jamais cassés --- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 768px) {
    table { font-size: 13px; }
    .table td, .table th { padding: 8px 10px; white-space: nowrap; }
}

/* --- Cartes Bootstrap (pages affectations/verrous/candidats/progression) --- */
@media (max-width: 768px) {
    .card-body { padding: 14px !important; }
    .card-header { padding-left: 16px !important; padding-right: 16px !important; }
    /* Boutons groupés passent à la ligne */
    .card-header .btn { margin-top: 4px; font-size: 12px; padding: 4px 8px; }
    /* Panneaux verrous/affectations empilés */
    [style*="max-height:420px"],
    [style*="max-height:460px"] { max-height: 320px !important; }
}

/* --- Formulaires : champs pleine largeur, confortables au doigt --- */
@media (max-width: 768px) {
    .form-control, .form-select, .form-control-lms {
        font-size: 16px !important; /* évite le zoom auto iOS */
    }
    .form-check-input { width: 2.2em; height: 1.2em; }
    .row.g-2 > [class*="col-"],
    .row.g-3 > [class*="col-"] { margin-bottom: 8px; }
}

/* --- Boutons : taille tactile minimale 44px sur mobile --- */
@media (max-width: 576px) {
    .btn, .btn-lms { min-height: 40px; }
    .btn-sm { min-height: 32px; }
    /* Actions empilées dans les en-têtes */
    .d-flex.justify-content-between { flex-wrap: wrap; gap: 8px; }
}

/* --- Modales : confortables sur mobile --- */
@media (max-width: 576px) {
    .modal-dialog { margin: 8px !important; max-width: calc(100% - 16px); }
    .modal-body { padding: 16px; }
    .modal-content { border-radius: 14px; }
}

/* --- Statistiques : grille 2 colonnes sur mobile au lieu de 1 --- */
@media (max-width: 576px) {
    .row.g-3 .col-md-4,
    .row.g-3 .col-md-3 { flex: 0 0 50%; max-width: 50%; }
}
@media (max-width: 380px) {
    .row.g-3 .col-md-4,
    .row.g-3 .col-md-3 { flex: 0 0 100%; max-width: 100%; }
}

/* --- Toasts : ne débordent pas --- */
@media (max-width: 576px) {
    .toast { max-width: calc(100vw - 24px); }
}

/* --- Login : déjà responsive, on assure le confort tactile --- */
@media (max-width: 480px) {
    .login-card { padding: 28px 20px !important; border-radius: 18px !important; }
}

/* --- Sidebar mobile : largeur adaptée aux petits écrans --- */
@media (max-width: 380px) {
    .sidebar { width: 85vw !important; }
}

/* --- Itinéraire général : espace bas pour éviter que le contenu colle --- */
@media (max-width: 768px) {
    .content-area, .page-content { padding-bottom: 40px !important; }
}

/* ============================================================
   SUPPORT RTL (arabe) - inversion droite-a-gauche
   ============================================================ */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .sidebar { left: auto; right: 0; }
[dir="rtl"] .main-content, [dir="rtl"] .main-wrapper { margin-left: 0; margin-right: var(--sidebar-width); }
@media (max-width: 992px) {
    [dir="rtl"] .main-content, [dir="rtl"] .main-wrapper { margin-right: 0 !important; }
    [dir="rtl"] .sidebar { transform: translateX(100%) !important; }
    [dir="rtl"] .sidebar.open { transform: translateX(0) !important; }
}
/* Inverser marges/paddings utilitaires courants */
[dir="rtl"] .me-1,[dir="rtl"] .me-2,[dir="rtl"] .me-3 { margin-right: 0 !important; }
[dir="rtl"] .me-1 { margin-left: .25rem !important; }
[dir="rtl"] .me-2 { margin-left: .5rem !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; }
[dir="rtl"] .ms-1,[dir="rtl"] .ms-2,[dir="rtl"] .ms-3,[dir="rtl"] .ms-auto { margin-left: 0 !important; }
[dir="rtl"] .ms-1 { margin-right: .25rem !important; }
[dir="rtl"] .ms-2 { margin-right: .5rem !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; }
[dir="rtl"] .ms-auto { margin-right: auto !important; }
[dir="rtl"] .ps-4 { padding-left: 0 !important; padding-right: 1.5rem !important; }
[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }
/* Bordures laterales (cartes, listes) */
[dir="rtl"] .border-start { border-left: 0 !important; border-right: 4px solid !important; }
[dir="rtl"] .border-end { border-right: 0 !important; border-left: 1px solid !important; }
/* Police arabe plus lisible */
[dir="rtl"] body, [dir="rtl"] .candidat-nav, [dir="rtl"] .sidebar {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
}
/* Dropdown aligne a gauche en RTL */
[dir="rtl"] .dropdown-menu-end { left: 0; right: auto; }
