/* =============================================================================
   ALM Formation Campus — feuille de style à la charte d'almformation31.fr
   Brun profond #34150F · caramel #D39858 · beiges #EEE0CF / #EACEAA
   Titres : Playfair Display · Texte : Albert Sans
   Contrastes vérifiés (WCAG AA) : le caramel n'est jamais utilisé pour du
   texte courant sur fond clair (on emploie alors --alm-caramel-fonce).
   ============================================================================= */

:root {
  --alm-brun: #34150F;
  --alm-brun-2: #4A2219;
  --alm-brun-rouge: #773D29;
  --alm-caramel: #D39858;
  --alm-caramel-fonce: #8E5A22;   /* texte sur fond clair : contraste 5,6:1 */
  --alm-beige: #EEE0CF;
  --alm-sable: #EACEAA;
  --alm-ivoire: #FAF5EE;
  --alm-texte: #2B211E;
  --alm-gris: #6B5E59;
  --alm-bord: #E6D9CB;
  --alm-succes: #2F6B3F;
  --alm-alerte: #A33A1F;

  --bs-body-font-family: "Albert Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--alm-texte);
  --bs-body-bg: var(--alm-ivoire);
  --bs-link-color: var(--alm-brun-rouge);
  --bs-link-color-rgb: 119, 61, 41;
  --bs-link-hover-color: var(--alm-brun);
  --bs-border-color: var(--alm-bord);
  --bs-primary: var(--alm-brun);
  --bs-primary-rgb: 52, 21, 15;
  --bs-focus-ring-color: rgba(211, 152, 88, .45);
}

body { font-size: 1rem; line-height: 1.6; }
h1, h2, h3, .h1, .h2, .h3, .font-titre {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-weight: 500;
  color: var(--alm-brun);
  letter-spacing: -.01em;
}
h4, h5, h6, .h4, .h5, .h6 { font-weight: 600; color: var(--alm-brun); }
.text-caramel { color: var(--alm-caramel-fonce) !important; }
.text-muted { color: var(--alm-gris) !important; }
.bg-brun { background: var(--alm-brun) !important; color: #fff; }
.bg-ivoire { background: var(--alm-ivoire) !important; }
.bg-beige { background: var(--alm-beige) !important; }
.bg-caramel { background-color: var(--alm-caramel) !important; color: var(--alm-brun) !important; }
.text-bg-caramel { background-color: var(--alm-sable) !important; color: var(--alm-brun) !important; }
.border-caramel { border-color: var(--alm-caramel) !important; }

a { text-underline-offset: .15em; }
:focus-visible { outline: 3px solid var(--alm-caramel); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 2000; background: #fff; color: var(--alm-brun); padding: .5rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }

/* --- Boutons ------------------------------------------------------------------ */
.btn { border-radius: 999px; font-weight: 500; padding: .5rem 1.15rem; }
.btn-sm { padding: .3rem .8rem; }
.btn-primary {
  --bs-btn-bg: var(--alm-brun); --bs-btn-border-color: var(--alm-brun);
  --bs-btn-hover-bg: var(--alm-brun-rouge); --bs-btn-hover-border-color: var(--alm-brun-rouge);
  --bs-btn-active-bg: var(--alm-brun-2); --bs-btn-active-border-color: var(--alm-brun-2);
  --bs-btn-disabled-bg: #8b7a74; --bs-btn-disabled-border-color: #8b7a74;
}
.btn-caramel {
  --bs-btn-color: var(--alm-brun); --bs-btn-bg: var(--alm-caramel); --bs-btn-border-color: var(--alm-caramel);
  --bs-btn-hover-color: var(--alm-brun); --bs-btn-hover-bg: #E0AE76; --bs-btn-hover-border-color: #E0AE76;
  --bs-btn-active-bg: #C38646; --bs-btn-active-color: var(--alm-brun);
  font-weight: 600;
}
.btn-outline-primary {
  --bs-btn-color: var(--alm-brun); --bs-btn-border-color: var(--alm-brun);
  --bs-btn-hover-bg: var(--alm-brun); --bs-btn-hover-border-color: var(--alm-brun); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--alm-brun);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--alm-bord); --bs-btn-hover-bg: var(--alm-beige); }

.form-control, .form-select { border-color: #D8C7B5; border-radius: .6rem; }
.form-control:focus, .form-select:focus { border-color: var(--alm-caramel); box-shadow: 0 0 0 .2rem rgba(211,152,88,.25); }
.form-check-input:checked { background-color: var(--alm-brun); border-color: var(--alm-brun); }
.form-label { font-weight: 500; }
.form-text { color: var(--alm-gris); }

.card { border-color: var(--alm-bord); border-radius: 1rem; box-shadow: 0 1px 2px rgba(52,21,15,.04); }
.card-header { background: transparent; border-bottom-color: var(--alm-bord); font-weight: 600; }
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--alm-gris); font-weight: 600; border-bottom-width: 1px; }
.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.badge.text-bg-secondary { background: #E9E2DC !important; color: #4B3F3A !important; }
.badge.text-bg-warning { background: #F6DFB7 !important; color: #6A3D06 !important; }
.badge.text-bg-info { background: #DCE9EF !important; color: #20485A !important; }
.badge.text-bg-success { background: #D8EBDD !important; color: #1F4D2B !important; }
.badge.text-bg-danger { background: #F4D6CE !important; color: #7A2412 !important; }
.badge.text-bg-dark { background: #4B3F3A !important; color: #fff !important; }
.badge-demo { background: #FFF1D6; color: #7A4A00; border: 1px dashed #C8902E; }
.alert { border-radius: .8rem; }
.progress { height: .55rem; border-radius: 999px; background: #EFE4D8; }
.progress-bar { background: var(--alm-caramel); }
.progress-bar.bg-success { background: var(--alm-succes) !important; }

/* --- Authentification ------------------------------------------------------------ */
.auth-body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #5a2a1e 0%, transparent 60%), var(--alm-brun);
  display: flex; align-items: center; justify-content: center; padding: 2rem 1rem;
}
.auth-card { width: 100%; max-width: 440px; }
.auth-card .card { border: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-logo { width: 240px; max-width: 70%; display: block; margin: 0 auto 1.5rem; }
.auth-tagline { color: var(--alm-sable); text-align: center; font-family: "Playfair Display", serif; margin-bottom: 1.5rem; }

/* --- Gestion : barre latérale ----------------------------------------------------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 260px; flex: 0 0 260px; background: var(--alm-brun); color: #F3E7DA;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.admin-sidebar .brand { padding: 1.25rem 1.25rem .5rem; }
.admin-sidebar .brand img { width: 180px; }
.admin-sidebar .brand small { display: block; color: var(--alm-caramel); letter-spacing: .14em; text-transform: uppercase; font-size: .68rem; margin-top: .25rem; }
.admin-nav { list-style: none; padding: .75rem .75rem 1rem; margin: 0; }
.admin-nav .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #B99A86; padding: 1rem .75rem .35rem; }
.admin-nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: .6rem;
  color: #F3E7DA; text-decoration: none; font-size: .95rem;
}
.admin-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-nav a.active { background: var(--alm-caramel); color: var(--alm-brun); font-weight: 600; }
.admin-nav .count { margin-left: auto; background: var(--alm-caramel); color: var(--alm-brun); border-radius: 999px; font-size: .72rem; padding: .05rem .5rem; font-weight: 700; }
.admin-nav a.active .count { background: var(--alm-brun); color: #fff; }
.admin-nav svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.admin-sidebar .sidebar-foot { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .85rem; }
.admin-sidebar .sidebar-foot a, .admin-sidebar .sidebar-foot button { color: var(--alm-sable); }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  background: #fff; border-bottom: 1px solid var(--alm-bord); padding: .75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 1010;
}
.admin-content { padding: 1.75rem 1.5rem 3rem; max-width: 1400px; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; font-size: 1.9rem; }
.page-head .lead-sm { color: var(--alm-gris); margin: .25rem 0 0; }

@media (max-width: 991.98px) {
  .admin-sidebar { position: fixed; left: -280px; z-index: 1050; transition: left .2s ease; height: 100vh; }
  .admin-sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .admin-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1040; }
  .admin-backdrop.show { display: block; }
  .admin-content { padding: 1.25rem 1rem 3rem; }
}
@media (min-width: 992px) { .menu-toggle { display: none; } }

/* --- Indicateurs --------------------------------------------------------------- */
.stat-card { padding: 1.1rem 1.25rem; border-radius: 1rem; background: #fff; border: 1px solid var(--alm-bord); height: 100%; text-decoration: none; display: block; color: inherit; }
a.stat-card:hover { border-color: var(--alm-caramel); }
.stat-card .stat-label { font-size: .8rem; color: var(--alm-gris); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .stat-value { font-family: "Playfair Display", serif; font-size: 2.1rem; color: var(--alm-brun); line-height: 1.15; }
.stat-card .stat-hint { font-size: .82rem; color: var(--alm-gris); }
.stat-card.is-alert { border-left: 4px solid var(--alm-caramel); }

.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #F1E8DE; font-size: .92rem; }
.activity li:last-child { border-bottom: 0; }
.activity .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--alm-caramel); margin-top: .55rem; flex: 0 0 8px; }
.activity time { color: var(--alm-gris); font-size: .8rem; white-space: nowrap; }

/* --- Espace stagiaire ----------------------------------------------------------- */
.learner-header { background: var(--alm-brun); color: #fff; }
.learner-header .navbar-brand img { height: 46px; }
.learner-header .nav-link { color: #F3E7DA; border-radius: 999px; padding: .4rem .9rem !important; }
.learner-header .nav-link:hover, .learner-header .nav-link.active { color: var(--alm-brun); background: var(--alm-sable); }
.learner-header .navbar-toggler { border-color: rgba(255,255,255,.4); }
.learner-header .navbar-toggler-icon { filter: invert(1); }
.preview-banner { background: #FFF1D6; color: #5E3A00; border-bottom: 1px solid #E8C98E; font-size: .9rem; }
.learner-hero { background: linear-gradient(180deg, var(--alm-beige), var(--alm-ivoire)); padding: 2.25rem 0 1.5rem; }
.course-card { border-radius: 1.1rem; overflow: hidden; background: #fff; border: 1px solid var(--alm-bord); display: flex; flex-direction: column; height: 100%; }
.course-card .course-band { background: var(--alm-brun); color: var(--alm-sable); padding: 1rem 1.25rem; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.course-card .course-body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.course-card h2 { font-size: 1.35rem; }

.module-block { border: 1px solid var(--alm-bord); border-radius: 1rem; background: #fff; margin-bottom: 1rem; overflow: hidden; }
.module-block .module-head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: #FDF9F4; border-bottom: 1px solid var(--alm-bord); }
.module-block .module-num { width: 38px; height: 38px; border-radius: 50%; background: var(--alm-brun); color: var(--alm-sable); display: grid; place-items: center; font-family: "Playfair Display", serif; flex: 0 0 38px; }
.module-block.locked .module-num { background: #B8A79D; }
.lesson-row { display: flex; align-items: center; gap: .85rem; padding: .7rem 1.25rem; border-bottom: 1px solid #F3EBE2; text-decoration: none; color: inherit; }
.lesson-row:last-child { border-bottom: 0; }
a.lesson-row:hover { background: #FBF6F0; }
.lesson-status { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #D6C4B2; display: grid; place-items: center; flex: 0 0 26px; font-size: .8rem; }
.lesson-status.done { background: var(--alm-succes); border-color: var(--alm-succes); color: #fff; }
.lesson-status.exempt { border-style: dashed; color: var(--alm-gris); }
.lesson-status.current { border-color: var(--alm-caramel); background: #FFF4E6; }

.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 1199.98px) { .lesson-layout { grid-template-columns: 1fr; } }
.lesson-body { font-size: 1.05rem; }
.lesson-body h1 { font-size: 1.7rem; margin-top: 1.5rem; }
.lesson-body h2 { font-size: 1.4rem; margin-top: 1.4rem; }
.lesson-body h3 { font-size: 1.15rem; margin-top: 1.2rem; font-family: "Albert Sans", sans-serif; font-weight: 700; }
.lesson-body ul, .lesson-body ol { padding-left: 1.4rem; }
.side-panel { position: sticky; top: 1rem; }
.notes-area { min-height: 220px; resize: vertical; font-size: .95rem; background: #FFFDF9; }
.save-status { font-size: .82rem; color: var(--alm-gris); }
.save-status.is-dirty { color: #7A4A00; }
.save-status.is-error { color: var(--alm-alerte); font-weight: 600; }
.save-status.is-ok { color: var(--alm-succes); }
.exchange { border-left: 3px solid var(--alm-sable); padding: .5rem 0 .5rem .85rem; margin-bottom: .85rem; }
.exchange .answer { background: #F7F0E7; border-radius: .6rem; padding: .6rem .8rem; margin-top: .5rem; }

/* --- Lecteurs vidéo ------------------------------------------------------------ */
.player-shell { background: #120806; border-radius: 1rem; overflow: hidden; position: relative; }
.player-frame { position: relative; aspect-ratio: 16 / 9; width: 100%; }
.player-frame > video, .player-frame > iframe, .player-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-message { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 2rem; color: #F3E7DA; background: rgba(18,8,6,.92); z-index: 5; }
.player-message.show { display: flex; }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding: .7rem 1rem; background: #FDF9F4; border: 1px solid var(--alm-bord); border-top: 0; border-radius: 0 0 1rem 1rem; font-size: .88rem; }
.player-bar .progress { flex: 1 1 160px; }
.player-shell + .player-bar { margin-top: -1rem; padding-top: 1.7rem; }

/* --- QCM ----------------------------------------------------------------------- */
.quiz-question { border: 1px solid var(--alm-bord); border-radius: 1rem; background: #fff; padding: 1.25rem; margin-bottom: 1rem; }
.quiz-option { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid #E3D5C6; border-radius: .75rem; padding: .7rem .9rem; margin-bottom: .5rem; cursor: pointer; background: #fff; }
.quiz-option:hover { border-color: var(--alm-caramel); }
.quiz-option input { margin-top: .3rem; }
.quiz-option.is-correct { border-color: var(--alm-succes); background: #EEF7F0; }
.quiz-option.is-wrong { border-color: var(--alm-alerte); background: #FBEDE9; }
.quiz-media img { max-width: 100%; max-height: 420px; border-radius: .75rem; }
.explanation { background: #F7F0E7; border-radius: .75rem; padding: .75rem 1rem; margin-top: .75rem; font-size: .95rem; }

/* --- Éditeur de formation ------------------------------------------------------- */
.editor-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1199.98px) { .editor-shell { grid-template-columns: 1fr; } }
.editor-toolbar-sticky { position: sticky; top: 57px; z-index: 1000; background: var(--alm-ivoire); padding: .75rem 0; margin-top: -.75rem; border-bottom: 1px solid var(--alm-bord); margin-bottom: 1.25rem; }
.outline { background: #fff; border: 1px solid var(--alm-bord); border-radius: 1rem; padding: .75rem; position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; }
.outline .outline-item { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; background: none; border: 0; border-radius: .55rem; padding: .45rem .6rem; color: var(--alm-texte); font-size: .92rem; }
.outline .outline-item:hover { background: #FBF6F0; }
.outline .outline-item.active { background: var(--alm-beige); font-weight: 600; }
.outline .outline-module { font-weight: 600; }
.outline .outline-lesson { padding-left: 1.6rem; font-size: .88rem; }
.outline .tag { font-size: .7rem; color: var(--alm-gris); margin-left: auto; white-space: nowrap; }
.editor-panel { background: #fff; border: 1px solid var(--alm-bord); border-radius: 1rem; padding: 1.5rem; }
.rte { border: 1px solid #D8C7B5; border-radius: .7rem; background: #fff; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; padding: .4rem; border-bottom: 1px solid #EADDCF; background: #FCF8F3; border-radius: .7rem .7rem 0 0; }
.rte-toolbar button { border: 1px solid transparent; background: none; border-radius: .4rem; padding: .25rem .55rem; font-size: .85rem; color: var(--alm-brun); min-width: 34px; }
.rte-toolbar button:hover { background: var(--alm-beige); }
.rte-toolbar button[aria-pressed="true"] { background: var(--alm-sable); border-color: var(--alm-caramel); }
.rte-toolbar .sep { width: 1px; background: #E2D3C3; margin: .2rem .25rem; }
.rte-area { min-height: 260px; padding: .9rem 1rem; outline: none; }
.rte-area:focus { box-shadow: inset 0 0 0 2px rgba(211,152,88,.35); border-radius: 0 0 .7rem .7rem; }
.rte-area h1 { font-size: 1.6rem; } .rte-area h2 { font-size: 1.35rem; } .rte-area h3 { font-size: 1.1rem; font-family: "Albert Sans", sans-serif; font-weight: 700; }
.rte-area:empty::before { content: attr(data-placeholder); color: #A99A91; }
.option-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.option-row .form-check-input { margin: 0; width: 1.25rem; height: 1.25rem; flex: 0 0 1.25rem; }
.media-preview { background: #FAF5EE; border: 1px dashed #D8C7B5; border-radius: .75rem; padding: .75rem; margin-top: .5rem; }
.media-preview img { max-width: 100%; max-height: 220px; border-radius: .5rem; }
.media-preview iframe, .media-preview video { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: .5rem; background: #000; }
.save-indicator { font-size: .85rem; }
.error-list { max-height: 220px; overflow: auto; }

/* --- Divers -------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--alm-gris); }
.empty-state .font-titre { font-size: 1.4rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
.mail-body { white-space: pre-wrap; background: #FBF7F2; border: 1px solid var(--alm-bord); border-radius: .75rem; padding: 1rem; font-size: .92rem; }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl-grid dt { color: var(--alm-gris); font-weight: 500; }
.dl-grid dd { margin: 0; }
.table-responsive { border-radius: 1rem; }
.filters { background: #fff; border: 1px solid var(--alm-bord); border-radius: 1rem; padding: 1rem; margin-bottom: 1rem; }
.nav-pills .nav-link { border-radius: 999px; color: var(--alm-brun); }
.nav-pills .nav-link.active { background: var(--alm-brun); }
.nav-tabs .nav-link { color: var(--alm-gris); }
.nav-tabs .nav-link.active { color: var(--alm-brun); font-weight: 600; border-bottom-color: #fff; }
.toast-zone { position: fixed; right: 1rem; bottom: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast-zone .alert { box-shadow: 0 10px 30px rgba(52,21,15,.18); margin: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .admin-sidebar, .admin-topbar, .learner-header, .no-print { display: none !important; } }
