:root {
  /* Couleurs du logo ESUP Dakar : bleu acier et cyan de l'apostrophe. */
  --esup-primary: #3868a0;
  --esup-primary-dark: #2a5283;
  --esup-sidebar: #1f3d62;
  --esup-accent: #40b0d8;
  --esup-bg: #f4f7fb;
  --esup-sidebar-text: #d3e0ee;

  /* Bootstrap aligné sur la charte. */
  --bs-primary: var(--esup-primary);
  --bs-primary-rgb: 56, 104, 160;
  --bs-link-color: var(--esup-primary);
  --bs-link-color-rgb: 56, 104, 160;
  --bs-link-hover-color: var(--esup-primary-dark);
  --bs-link-hover-color-rgb: 42, 82, 131;
  --bs-info: var(--esup-accent);
  --bs-info-rgb: 64, 176, 216;
}

.btn-primary {
  --bs-btn-bg: var(--esup-primary);
  --bs-btn-border-color: var(--esup-primary);
  --bs-btn-hover-bg: var(--esup-primary-dark);
  --bs-btn-hover-border-color: var(--esup-primary-dark);
  --bs-btn-active-bg: var(--esup-primary-dark);
  --bs-btn-active-border-color: var(--esup-primary-dark);
  --bs-btn-disabled-bg: var(--esup-primary);
  --bs-btn-disabled-border-color: var(--esup-primary);
}

.btn-outline-primary {
  --bs-btn-color: var(--esup-primary);
  --bs-btn-border-color: var(--esup-primary);
  --bs-btn-hover-bg: var(--esup-primary);
  --bs-btn-hover-border-color: var(--esup-primary);
  --bs-btn-active-bg: var(--esup-primary-dark);
  --bs-btn-active-border-color: var(--esup-primary-dark);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #8fb0d6;
  box-shadow: 0 0 0 .2rem rgba(56, 104, 160, .2);
}

.form-check-input:checked {
  background-color: var(--esup-primary);
  border-color: var(--esup-primary);
}

.page-link { color: var(--esup-primary); }

body {
  background: var(--esup-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #27323d;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Barre latérale ---- */
.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--esup-sidebar);
  color: var(--esup-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.1rem;
  background: #fff;
  color: var(--esup-primary);
  text-decoration: none;
  border-bottom: 3px solid var(--esup-accent);
}

/* Le logo a un fond blanc : il est posé sur un bandeau blanc. */
.sidebar-brand img {
  height: 52px;
  width: auto;
}

.sidebar-brand span {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.sidebar-section {
  margin: 1rem 1.25rem .35rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--esup-accent);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: .75rem 0;
  flex: 1 1 auto;
  overflow-y: auto;
}

.sidebar-nav a,
.sidebar-footer a,
.sidebar-footer button {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1.25rem;
  color: var(--esup-sidebar-text);
  text-decoration: none;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  font-size: .95rem;
}

.sidebar-nav a i,
.sidebar-footer a i,
.sidebar-footer button i {
  width: 1.1rem;
  text-align: center;
}

.sidebar-nav a:hover,
.sidebar-footer a:hover,
.sidebar-footer button:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--esup-primary);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--esup-accent);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding: .5rem 0;
}

/* ---- Contenu ---- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.25rem 1.75rem 2.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-chip {
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 999px;
  padding: .35rem .9rem;
  font-size: .85rem;
  line-height: 1.15;
}

.user-chip small {
  display: block;
  color: #7b8794;
  font-size: .72rem;
}

.card {
  border: 1px solid #e6eaef;
  border-radius: .6rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eef1f5;
  font-weight: 600;
}

/* ---- Tuiles de comptage ---- */
.stat-tile {
  background: #fff;
  border: 1px solid #e6eaef;
  border-radius: .6rem;
  padding: 1rem 1.1rem;
  height: 100%;
}

.stat-tile .stat-value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--esup-primary);
}

.stat-link {
  display: block;
  position: relative;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}

.stat-link:hover {
  border-color: var(--esup-accent);
  box-shadow: 0 4px 12px rgba(56, 104, 160, .12);
}

.stat-tile .stat-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: var(--esup-accent);
  opacity: .7;
}

.stat-tile .stat-label {
  color: #6b7785;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Pastille « en direct » : repère visuel le plus important de la plateforme. */
.badge-live {
  background: #d93a3a;
  color: #fff;
}

.badge-live::before {
  content: "";
  display: inline-block;
  width: .45rem;
  height: .45rem;
  margin-right: .35rem;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

@media (prefers-reduced-motion: reduce) {
  .badge-live::before { animation: none; }
}

/* ---- Badges de rôle ---- */
.role-admin { background: var(--esup-sidebar); color: #fff; }
.role-teacher { background: var(--esup-primary); color: #fff; }
.role-student { background: #e3f3fa; color: #1d6f8f; }

/* ---- Connexion : fond blanc, comme le logo ---- */
.login-body { background: #fff; }

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 1.5rem;
  border-top: 5px solid var(--esup-primary);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid #e3e9f1;
  border-radius: .75rem;
  padding: 2rem;
  box-shadow: 0 8px 28px rgba(31, 61, 98, .08);
}

.login-card .brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo {
  width: 130px;
  height: auto;
}

.login-card .brand h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--esup-primary);
  margin: .75rem 0 .15rem;
}

.login-card .input-group-text {
  background: #f4f7fb;
  color: var(--esup-primary);
  min-width: 2.6rem;
  justify-content: center;
}

.login-footer {
  margin: 1.5rem 0 0;
  color: #9aa6b2;
  font-size: .8rem;
}

.login-card .brand p {
  color: #7b8794;
  margin: 0;
  font-size: .9rem;
}

/* ==================================================================
   Formations (e-learning en autonomie)
   ================================================================== */
.progress-bar { background-color: var(--esup-primary); }
.progress-thin { height: 6px; }
.min-w-0 { min-width: 0; }

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: .85rem;
  color: var(--esup-sidebar);
}

.header-back { color: inherit; margin-right: .35rem; font-size: 1.1rem; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  background: #fff;
  border: 1px dashed #cfd9e5;
  border-radius: .6rem;
  color: #6b7785;
}
.empty-state i { font-size: 2rem; color: var(--esup-accent); margin-bottom: .5rem; }

/* ---- Catalogue ---- */
.catalogue-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid #e3e9f1;
  margin-bottom: .75rem;
}
.catalogue-tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.catalogue-tabs a {
  padding: .6rem .9rem; color: #5b6774; text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.catalogue-tabs a:hover { color: var(--esup-primary); }
.catalogue-tabs a.active { color: var(--esup-primary); border-bottom-color: var(--esup-primary); font-weight: 600; }

.catalogue-search { position: relative; flex: 0 1 380px; margin-bottom: .5rem; }
.catalogue-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #9aa6b2; font-size: .85rem; }
.catalogue-search input { padding-left: 2.3rem; border-radius: 999px; background: #fff; }

.formation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}

.formation-card {
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid #e6eaef;
  border-radius: .6rem;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.formation-card:hover { border-color: #c9d8e8; box-shadow: 0 4px 14px rgba(31, 61, 98, .08); }

.formation-cover { position: relative; display: block; height: 110px; background: #eaf1f8; }
.formation-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--esup-primary); opacity: .55; font-size: 1.9rem;
}
.cover-badge { position: absolute; top: .5rem; left: .5rem; font-size: .7rem; }

.formation-body { padding: .7rem .85rem .8rem; display: flex; flex-direction: column; flex: 1; }
.formation-title {
  font-size: .92rem; font-weight: 700; line-height: 1.3; color: #1f2a36; text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.formation-title:hover { color: var(--esup-primary); }
.formation-teacher { font-size: .78rem; color: #7b8794; margin: .2rem 0 .4rem; }
.formation-meta { display: flex; flex-wrap: wrap; gap: .2rem .4rem; font-size: .74rem; color: #5b6774; margin-top: auto; }
.formation-meta span + span::before { content: "·"; margin-right: .4rem; color: #b5c0cb; }

.formation-actions {
  display: flex; gap: .9rem;
  margin-top: .6rem; padding-top: .55rem; border-top: 1px solid #eef1f5;
  font-size: .78rem;
}
.formation-actions a { color: var(--esup-primary); text-decoration: none; font-weight: 500; }
.formation-actions a:hover { text-decoration: underline; }

.continue-card {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border: 1px solid #e6eaef; border-left: 3px solid var(--esup-accent);
  border-radius: .6rem; padding: .7rem .9rem; height: 100%;
}
.continue-btn { width: 2.3rem; height: 2.3rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }

/* ---- Fiche formation ---- */
.formation-hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
  background: var(--esup-sidebar);
  color: #fff;
  border-radius: .8rem;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.formation-hero h2 { font-size: 1.7rem; font-weight: 700; margin: .2rem 0 .5rem; }
.formation-hero .lead { font-size: 1.05rem; opacity: .9; }
.hero-kicker { color: var(--esup-accent); font-weight: 600; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .9rem; opacity: .95; }
.hero-meta i { color: var(--esup-accent); margin-right: .3rem; }
.formation-hero-card { background: #fff; color: #27323d; border-radius: .6rem; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.hero-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.curriculum-item a { color: inherit; text-decoration: none; }
.curriculum-item a:hover { color: var(--esup-primary); }
.accordion-button:not(.collapsed) { background: #f1f6fb; color: var(--esup-sidebar); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(56, 104, 160, .2); }

.avatar {
  width: 3rem; height: 3rem; border-radius: 50%;
  background: var(--esup-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase; flex: none;
}

/* Contenus rédigés par les formateurs */
.rich-text { line-height: 1.65; }
.rich-text h3, .rich-text h4, .rich-text h5 { color: var(--esup-sidebar); font-weight: 700; margin: 1.2rem 0 .5rem; }
.rich-text h3 { font-size: 1.3rem; }
.rich-text h4 { font-size: 1.12rem; }
.rich-text h5 { font-size: 1rem; }
.rich-text pre {
  background: #1e2a38; color: #e6edf5;
  padding: .9rem 1rem; border-radius: .5rem; overflow-x: auto; font-size: .87rem;
}
.rich-text :not(pre) > code { background: #eef3f9; color: #1d5a8f; padding: .1rem .35rem; border-radius: .25rem; }
.rich-text p:last-child { margin-bottom: 0; }

/* ---- Lecteur de leçon ---- */
.player-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.player-sidebar { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; }
.player-curriculum { overflow-y: auto; }
.curriculum-section {
  padding: .6rem 1rem; background: #f4f7fb; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: #5b6774; border-top: 1px solid #eef1f5;
}
.curriculum-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1rem; font-size: .88rem; color: #27323d; text-decoration: none;
  border-left: 3px solid transparent;
}
.curriculum-link i { width: 1rem; text-align: center; color: #8996a3; }
.curriculum-link small { color: #8996a3; }
a.curriculum-link:hover { background: #f4f7fb; color: var(--esup-primary); }
.curriculum-link.current { background: #eaf2fa; border-left-color: var(--esup-accent); font-weight: 600; }
.curriculum-link.locked { color: #9aa6b2; }

.video-frame {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border-radius: .6rem; overflow: hidden; margin-bottom: 1rem;
}
.video-frame video, .video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.lesson-title { font-size: 1.35rem; font-weight: 700; margin: .2rem 0 0; }
.lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }

.attachment-link {
  display: inline-flex; align-items: center; gap: .8rem;
  padding: .75rem 1rem; border: 1px solid #dbe4ee; border-radius: .6rem;
  color: inherit; text-decoration: none; background: #f8fafc;
}
.attachment-link i { font-size: 1.6rem; color: var(--esup-primary); }
.attachment-link:hover { border-color: var(--esup-accent); }

/* ---- Tests ---- */
.quiz-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1rem; }
.quiz-facts > div {
  background: #f4f7fb; border-radius: .5rem; padding: .6rem; text-align: center;
  font-size: .78rem; color: #5b6774;
}
.quiz-facts span { display: block; font-size: 1.25rem; font-weight: 700; color: var(--esup-primary); }

.quiz-timer {
  background: var(--esup-sidebar); color: #fff; border-radius: 999px;
  padding: .35rem .9rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.quiz-timer.urgent { background: #d93a3a; }

.question-card { border-left: 4px solid var(--esup-primary); }
.question-card.is-correct { border-left-color: #2f9e62; }
.question-card.is-wrong { border-left-color: #d93a3a; }
.question-title { font-size: 1rem; font-weight: 600; line-height: 1.45; display: flex; gap: .6rem; }
.question-number {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: #eaf2fa; color: var(--esup-primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: .82rem;
}

.choice-option {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .9rem; margin-top: .45rem;
  border: 1px solid #dbe4ee; border-radius: .5rem; cursor: pointer;
}
.choice-option:hover { border-color: var(--esup-accent); background: #f6fbfd; }
.choice-option:has(input:checked) { border-color: var(--esup-primary); background: #eaf2fa; }
.choice-option input { margin: 0; flex: none; }

.choice-review { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-radius: .4rem; margin-top: .3rem; }
.choice-review.correct { background: #e7f6ee; }
.choice-review.wrong { background: #fdecec; }
.explanation { margin-top: .8rem; padding: .6rem .8rem; background: #fff8e6; border-radius: .4rem; font-size: .9rem; }

.result-hero {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 1.5rem; border-radius: .8rem; color: #fff;
}
.result-hero.passed { background: #23845a; }
.result-hero.failed { background: var(--esup-sidebar); }
.result-hero h2 { font-size: 1.35rem; font-weight: 700; margin: 0 0 .25rem; }
.result-score {
  width: 6.5rem; height: 6.5rem; border-radius: 50%; flex: none;
  border: 4px solid rgba(255, 255, 255, .6);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800;
}
.result-score small { font-size: 1rem; }

/* ---- Création de contenu ---- */
.builder-section .card-header { background: #f8fafc; }
.section-title-input { font-weight: 600; border-color: transparent; background: transparent; }
.section-title-input:hover, .section-title-input:focus { border-color: #ced4da; background: #fff; }
.builder-section form { margin: 0; }

.classes-checklist ul, .classes-checklist > div { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow-y: auto; }
.classes-checklist label { display: flex; gap: .5rem; align-items: center; padding: .2rem 0; }

.choice-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.choice-row .form-check { margin: 0; padding-left: 1.6rem; }
.choice-row .form-check-input { width: 1.25rem; height: 1.25rem; }

.gradebook th { font-size: .8rem; white-space: nowrap; }

/* ---- Enregistreur ---- */
.record-box { background: #f6fbfd; border: 1px dashed var(--esup-accent); border-radius: .6rem; padding: .85rem 1rem; }
.recorder.is-recording { animation: recglow 1.6s ease-in-out infinite; border-radius: .4rem; }
.rec-timer { font-weight: 700; color: #d93a3a; font-variant-numeric: tabular-nums; }
.rec-timer::before { content: "● "; }
.rec-preview { width: 100%; max-width: 480px; border-radius: .5rem; background: #000; }
@keyframes recglow { 50% { box-shadow: 0 0 0 4px rgba(217, 58, 58, .15); } }
@media (prefers-reduced-motion: reduce) { .recorder.is-recording { animation: none; } }

/* ---- Certificat ---- */
.certificate-body { background: #eef2f7; padding: 1.5rem; }
.certificate-actions { max-width: 960px; margin: 0 auto 1rem; display: flex; justify-content: space-between; }
.certificate {
  max-width: 960px; margin: 0 auto; background: #fff; text-align: center;
  padding: 3rem 3.5rem; border: 10px solid var(--esup-primary);
  outline: 2px solid var(--esup-accent); outline-offset: -22px;
}
.certificate-logo { width: 140px; margin-bottom: 1rem; }
.certificate-kicker { font-size: 1.6rem; font-weight: 300; letter-spacing: .2em; text-transform: uppercase; color: var(--esup-primary); }
.certificate h1 { font-size: 2.4rem; font-weight: 700; color: var(--esup-sidebar); margin: .5rem 0 1rem; }
.certificate h2 { font-size: 1.5rem; color: var(--esup-primary); margin: .5rem 0 2rem; }
.certificate-footer { display: flex; justify-content: space-around; gap: 1rem; border-top: 1px solid #dbe4ee; padding-top: 1.5rem; font-size: .9rem; }
.certificate-footer small { color: #7b8794; }
@media print {
  .certificate-body { background: #fff; padding: 0; }
  .certificate-actions { display: none; }
  @page { size: landscape; margin: 1cm; }
}

@media (max-width: 992px) {
  .formation-hero, .player-layout { grid-template-columns: 1fr; }
  .player-sidebar { position: static; max-height: none; }
}
@media (max-width: 576px) {
  .quiz-facts { grid-template-columns: repeat(2, 1fr); }
  .formation-hero { padding: 1.25rem; }
  .certificate { padding: 1.5rem; }
  .certificate-footer { flex-direction: column; }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: .25rem .5rem;
  }

  .sidebar-nav a { padding: .5rem .75rem; }
  .sidebar-section { width: 100%; margin: .5rem .75rem .1rem; }
  .sidebar-brand img { height: 40px; }
  .sidebar-nav a.active { box-shadow: inset 0 -3px 0 var(--esup-accent); }
  .sidebar-footer { display: flex; }
  .content { padding: 1rem; }
}
