/* ================================================
   ONG JCB — Espace formation (LMS)
   Intégré au thème principal : header/footer du site,
   barre de contexte (recherche + compte) et contenus.
   ================================================ */

:root {
  --lms-bg:           #F4F7F5;
  --lms-surface:      #FFFFFF;
  --lms-primary:      #1A9945;
  --lms-primary-dark: #126030;
  --lms-primary-soft: #E7F5EC;
  --lms-border:       #E3EBE6;
  --lms-text:         #0F1B13;
  --lms-text-muted:   #55685C;
  --lms-shadow:       0 4px 20px rgba(6, 15, 8, 0.06);
}

/* Les pages LMS partagent le fond et la typo du site principal
   (clair par défaut, sombre en mode html[data-theme="dark"]). */
.lms-standalone {
  background: var(--color-bg);
}

/* -------------------------------------------------
   Contenu des pages LMS (catalogue, cours, leçons, …)
   ------------------------------------------------- */

/* -------------------------------------------------
   Pages Documents & Paramètres
   ------------------------------------------------- */
.lms-page-header {
  margin-bottom: 26px;
}

.lms-page-header h1 {
  margin: 6px 0 8px;
  font-size: 1.7rem;
  line-height: 1.2;
  color: var(--lms-text);
}

.lms-page-header p {
  margin: 0;
  max-width: 640px;
  color: var(--lms-text-muted);
  font-size: 0.95rem;
}

.lms-doc-section {
  margin-bottom: 34px;
}

.lms-doc-section > h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: var(--lms-text);
}

.lms-card {
  padding: 22px;
  border: 1px solid var(--lms-border);
  border-radius: 16px;
  background: var(--lms-surface);
  box-shadow: var(--lms-shadow);
}

.lms-card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--lms-text);
}

.lms-card p {
  margin: 0 0 12px;
  color: var(--lms-text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.lms-card p:last-child {
  margin-bottom: 0;
}

.lms-card .btn {
  margin-top: 4px;
}

.lms-card-note {
  font-size: 0.85rem;
  color: var(--lms-text-muted);
}

.lms-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.lms-settings-list {
  margin: 0 0 14px;
}

.lms-settings-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--lms-border);
}

.lms-settings-list div:last-child {
  border-bottom: 0;
}

.lms-settings-list dt {
  color: var(--lms-text-muted);
  font-size: 0.88rem;
}

.lms-settings-list dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lms-text);
  text-align: right;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------
   Compléments de contenu hérité (app.css) propres au LMS
   Ces classes sont utilisées par les templates visiteur
   (formations, cours, commander, leçon, avis) mais étaient
   définies uniquement dans admin.css (tableau de bord).
   ------------------------------------------------- */

/* Bouton secondaire */
.btn-secondary {
  background: var(--lms-primary-soft);
  color: var(--lms-primary-dark);
  border: 1px solid rgba(26, 153, 69, 0.25);
}
.btn-secondary:hover {
  background: var(--lms-primary);
  color: #fff;
  border-color: var(--lms-primary);
}

/* Badge de base (variantes --preview/--lock dans app.css) */
.mss-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Carte générique (mss-card) utilisée seule ou avec lms-card */
.mss-card {
  background: var(--lms-surface);
  border: 1px solid var(--lms-border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--lms-shadow);
}

/* Blocs de description d'une formation */
.mss-course-description,
.mss-course-objectives,
.mss-course-prerequisites {
  margin-bottom: 1.75rem;
}
.mss-course-description > h2,
.mss-course-objectives > h2,
.mss-course-prerequisites > h2 {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
  color: var(--lms-text);
}
.mss-course-description > div,
.mss-course-objectives > div,
.mss-course-prerequisites > div {
  color: var(--lms-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}
.mss-course-description p,
.mss-course-objectives p,
.mss-course-prerequisites p {
  margin: 0 0 0.8rem;
}

/* Texte visible uniquement par les lecteurs d'écran */
.ong-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Formulaires inline (inscription gratuite, leçon terminée) */
.mss-enroll-form,
.mss-complete-form {
  display: inline-flex;
  margin: 0;
}
.mss-order-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

/* Champs de formulaire visiteur (copié de admin.css avec vars LMS) */
.mss-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.mss-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lms-text-muted);
  letter-spacing: 0.02em;
}
.mss-field input,
.mss-field select,
.mss-field textarea {
  background: var(--lms-surface);
  border: 1px solid var(--lms-border);
  border-radius: 12px;
  padding: 0.68rem 0.95rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--lms-text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  width: 100%;
}
.mss-field select { cursor: pointer; }
.mss-field textarea { resize: vertical; }
.mss-field input::placeholder,
.mss-field textarea::placeholder { color: var(--lms-text-muted); opacity: 0.75; }
.mss-field input:focus,
.mss-field select:focus,
.mss-field textarea:focus {
  outline: none;
  border-color: var(--lms-primary);
  box-shadow: 0 0 0 4px rgba(26, 153, 69, 0.14);
  background: var(--lms-surface);
}
.mss-field input[type="checkbox"] { width: auto; accent-color: var(--lms-primary); }
.mss-coupon-input { max-width: 280px; }

/* -------------------------------------------------
   Page « Commander » — tunnel d'achat d'une formation
   ------------------------------------------------- */

/* États bloquants (formation introuvable, connexion requise, déjà inscrit,
   formation gratuite) : une seule carte centrée plutôt qu'un texte brut isolé. */
.mss-order-notice {
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
  padding: 2.5rem 2rem;
}
.mss-order-notice__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lms-primary-soft);
  color: var(--lms-primary-dark);
  margin-bottom: 1rem;
}
.mss-order-notice__icon svg { width: 26px; height: 26px; }
.mss-order-notice__icon--success { background: rgba(26,153,69,0.14); }
.mss-order-notice h1 { font-size: 1.3rem; margin: 0 0 0.5rem; color: var(--lms-text); }
.mss-order-notice .ong-empty { padding: 0 0 1.5rem; }

.mss-order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
}
.mss-order-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}
.mss-order-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mss-order-summary__course {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--lms-border);
}
.mss-order-summary__thumb {
  width: 96px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}
.mss-order-summary__info { min-width: 0; }
.mss-order-summary__info h2 { margin: 0 0 0.3rem; font-size: 1.1rem; color: var(--lms-text); }
.mss-order-summary__info .mss-course-excerpt { margin: 0 0 0.5rem; font-size: 0.88rem; color: var(--lms-text-muted); }
.mss-order-summary__meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--lms-text-muted);
}
.mss-order-summary__meta svg { width: 14px; height: 14px; }

.mss-order-lines { margin: 0; }
.mss-order-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
}
.mss-order-line dt { margin: 0; font-size: 0.9rem; color: var(--lms-text-muted); }
.mss-order-line dd { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--lms-text); }
.mss-order-line--discount dd { color: #15803d; }
.mss-order-line--total {
  border-top: 1px solid var(--lms-border);
  margin-top: 0.25rem;
  padding-top: 0.75rem;
}
.mss-order-line--total dt { font-weight: 600; color: var(--lms-text); }
.mss-order-line--total dd { font-size: 1.3rem; color: var(--lms-primary-dark); }

.mss-coupon-row {
  display: flex;
  gap: 0.6rem;
}
.mss-coupon-row .mss-coupon-input { flex: 1; max-width: none; }
.mss-coupon-row .btn { flex-shrink: 0; white-space: nowrap; }
/* Code promo appliqué (readOnly, pas disabled — cf. lms.js) : fond teinté pour
   distinguer visuellement de l'état éditable normal, sans le griser comme un
   champ désactivé (il reste bien envoyé à la soumission). */
.mss-coupon-input:read-only {
  background: var(--lms-primary-soft);
  border-color: rgba(26, 153, 69, 0.3);
  color: var(--lms-primary-dark);
  font-weight: 600;
}

.mss-field-feedback {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  min-height: 1.1em;
}
.mss-field-feedback--success { color: #15803d; }
.mss-field-feedback--error { color: #b63030; }

.mss-payment-methods {
  border: 0;
  padding: 0;
  margin: 0;
}
.mss-payment-methods legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lms-text-muted);
  letter-spacing: 0.02em;
  padding: 0 0 0.6rem;
}
.mss-payment-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--lms-border);
  border-radius: 12px;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.mss-payment-option:last-child { margin-bottom: 0; }
.mss-payment-option:hover { border-color: var(--lms-primary); }
.mss-payment-option:has(input:checked) {
  border-color: var(--lms-primary);
  background: var(--lms-primary-soft);
  box-shadow: 0 0 0 3px rgba(26, 153, 69, 0.1);
}
.mss-payment-option:has(input:focus-visible) {
  outline: 2px solid var(--lms-primary);
  outline-offset: 2px;
}
.mss-payment-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--lms-primary);
  flex-shrink: 0;
}
.mss-payment-option__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--lms-surface);
  border: 1px solid var(--lms-border);
  color: var(--lms-primary-dark);
  flex-shrink: 0;
}
.mss-payment-option__icon svg { width: 18px; height: 18px; }
.mss-payment-option__label {
  display: flex;
  flex-direction: column;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--lms-text);
}
.mss-payment-option__label small {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--lms-text-muted);
}

/* .mss-order-form (existant, ~L213) porte margin-top:1.25rem, pensé pour un
   formulaire isolé sous le résumé de commande dans l'ancienne mise en page —
   redondant avec le gap:1.5rem de .mss-order-main ci-dessus, qui espace déjà
   les deux cartes. */
.mss-order-main > .mss-order-form { margin-top: 0; }
.mss-order-form .mss-form-response:empty { display: none; }

@media (max-width: 860px) {
  .mss-order-layout { grid-template-columns: 1fr; }
  .mss-order-aside { order: -1; }
}
@media (max-width: 480px) {
  .mss-order-summary__course { flex-direction: column; }
  .mss-order-summary__thumb { width: 100%; height: 140px; }
  .mss-coupon-row { flex-direction: column; }
}

/* Espace apprenant (mon-espace, quiz) */
.mss-student-content {
  margin-top: 1.5rem;
}
.mss-quiz-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.25rem;
}
.mss-quiz-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 1rem;
  background: var(--lms-primary-soft);
  border: 1px solid rgba(26, 153, 69, 0.22);
  border-radius: 12px;
  color: var(--lms-primary-dark);
  font-size: 0.9rem;
  margin: 0.75rem 0;
}
.mss-quiz-best p { margin: 0; }
.mss-badge--closed {
  background: rgba(149, 165, 166, 0.14);
  color: #55685C;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
}
.mss-surveys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* -------------------------------------------------
   Barre de contexte de l'espace formation
   (recherche + accès compte), intégrée à la page.
   ------------------------------------------------- */
.lms-contextbar {
  margin-top: calc(var(--header-h, 80px) + 20px);
}

.lms-contextbar__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: var(--lms-surface);
  border: 1px solid var(--lms-border);
  border-radius: 16px;
  box-shadow: var(--lms-shadow);
}

.lms-contextbar__nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.lms-contextbar__nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--lms-text-muted);
  transition: background 0.16s ease, color 0.16s ease;
}

.lms-contextbar__nav a:hover,
.lms-contextbar__nav a.is-active {
  background: var(--lms-primary-soft);
  color: var(--lms-primary-dark);
}

.lms-contextbar__search {
  flex: 1 1 auto;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  background: var(--lms-bg);
  border: 1px solid var(--lms-border);
  border-radius: 12px;
  color: var(--lms-text-muted);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.lms-contextbar__search:focus-within {
  border-color: var(--lms-primary);
  box-shadow: 0 0 0 3px rgba(26, 153, 69, 0.12);
}

.lms-contextbar__search svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.lms-contextbar__search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--lms-text);
  outline: none;
}

.lms-contextbar__search input::placeholder {
  color: var(--lms-text-muted);
  opacity: 0.8;
}

/* Les pages LMS fournissent leur propre marge haute (barre de contexte) :
   on neutralise le padding-top lié au header fixe du thème. */
body.lms-standalone .mss-page {
  padding-top: 24px;
}

/* -------------------------------------------------
   Mode sombre : les variables LMS suivent le thème.
   ------------------------------------------------- */
html[data-theme="dark"] {
  --lms-bg:           #07140C;
  --lms-surface:      #0C2312;
  --lms-primary:      #3CC469;
  --lms-primary-dark: #86E2A8;
  --lms-primary-soft: rgba(60, 196, 105, 0.14);
  --lms-border:       rgba(255, 255, 255, 0.12);
  --lms-text:         #EAF3ED;
  --lms-text-muted:   #9FBFAD;
  --lms-shadow:       0 4px 20px rgba(0, 0, 0, 0.4);
}

/* -------------------------------------------------
   Responsive
   ------------------------------------------------- */
@media (max-width: 1023px) {
  .lms-contextbar {
    margin-top: calc(var(--header-h, 80px) + 16px);
  }
}

@media (max-width: 640px) {
  .lms-contextbar__inner {
    padding: 10px 12px;
  }

  .lms-contextbar__search {
    min-width: 100%;
    order: 3;
  }
}
