/* =========================================================
   ESPACE APPRENANT — KARA DIGITAL
   Complète css/style.css (couleurs, police, boutons).
   Pages : connexion.html, mot-de-passe.html, espace.html
   ========================================================= */
[hidden] { display: none !important; }

body.page-apprenant { background: #F4F7FC; min-height: 100vh; display: flex; flex-direction: column; }
.ap-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- En-tête ---------- */
.ap-entete { background: var(--blanc); box-shadow: 0 2px 12px rgba(0, 0, 0, .06); position: sticky; top: 0; z-index: 50; }
.ap-entete__inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ap-entete__titre { font-weight: 700; color: var(--texte-doux); border-left: 2px solid var(--bleu-clair); padding-left: 16px; }
.ap-entete__compte { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--texte-doux); min-width: 0; }
.ap-entete__compte span { overflow-wrap: anywhere; }
.ap-entete .btn { cursor: pointer; }

/* Les boutons WhatsApp gardent leur largeur naturelle dans l'espace apprenant
   (le style général les met en pleine largeur dans les fenêtres de réservation) */
.page-apprenant .btn--whatsapp { width: auto; font-size: .9rem; }

.ap-pied { text-align: center; padding: 22px 16px; font-size: .85rem; color: var(--texte-doux); }
.ap-pied a { color: var(--bleu); font-weight: 600; }

/* ---------- Cartes de connexion / mot de passe ---------- */
.ap-centre { min-height: 62vh; display: grid; place-items: center; }
.ap-carte { background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 26px; }
.ap-auth { width: min(440px, 100%); display: grid; gap: 14px; }
.ap-auth h1 { font-size: 1.5rem; }
.ap-auth label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.ap-auth input {
  font: inherit; font-weight: 400; font-size: 16px;   /* 16px : pas de zoom automatique sur iPhone */
  padding: 12px 14px; border: 1.5px solid #CBD6E6; border-radius: 10px;
  background: var(--blanc); color: var(--texte); width: 100%;
}
.ap-auth input:focus { outline: none; border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(11, 94, 215, .15); }
.ap-auth .btn { width: 100%; text-align: center; cursor: pointer; font-size: 1rem; }
.ap-aide { color: var(--texte-doux); font-size: .88rem; font-weight: 400; }
.ap-erreur { color: #B3261E; background: #FDECEA; border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.ap-succes { color: #1B7A3D; background: #E3F6EA; border-radius: 10px; padding: 10px 14px; font-size: .9rem; }
.ap-lien { background: none; border: none; padding: 0; font: inherit; font-size: .9rem; font-weight: 600; color: var(--bleu); cursor: pointer; text-decoration: underline; justify-self: start; }
.ap-regles { list-style: none; display: grid; gap: 4px; font-size: .85rem; color: var(--texte-doux); }
.ap-regles li::before { content: "○ "; }
.ap-regles li.ok { color: #1B7A3D; }
.ap-regles li.ok::before { content: "✓ "; }
.ap-voir { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.ap-voir input { width: 18px; height: 18px; }

/* ---------- Chargement ---------- */
.ap-chargement { width: 40px; height: 40px; border: 4px solid var(--bleu-clair); border-top-color: var(--bleu); border-radius: 50%; animation: ap-tourne .9s linear infinite; }
@keyframes ap-tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ap-chargement { animation: none; } }
.ap-etat { display: grid; justify-items: center; gap: 12px; padding: 60px 16px; text-align: center; color: var(--texte-doux); }

/* ---------- Tableau de bord ---------- */
.ap-bonjour h1 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
.ap-bonjour p { color: var(--texte-doux); margin-top: 4px; }
.ap-section { margin-top: 30px; }
.ap-section > h2 { font-size: 1.25rem; margin-bottom: 14px; }
.ap-message { background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 22px; display: grid; gap: 12px; justify-items: start; }
.ap-message--attention { border-left: 4px solid #F2A900; }
.ap-message p { color: var(--texte-doux); }

.ap-formations { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 22px; }
.ap-fo {
  background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre);
  overflow: hidden; display: flex; flex-direction: column;
}
.ap-fo__image { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; background: var(--bleu-clair); display: block; }
.ap-fo__corps { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ap-fo__titre { font-size: 1.15rem; overflow-wrap: anywhere; }
.ap-fo__infos { color: var(--texte-doux); font-size: .88rem; }
.ap-fo .btn { margin-top: auto; text-align: center; cursor: pointer; }
.ap-fo--suspendu { opacity: .75; }
.ap-fo--suspendu .ap-fo__image { filter: grayscale(1); }

.ap-progres { display: grid; gap: 6px; }
.ap-progres__barre { height: 10px; background: var(--bleu-clair); border-radius: 50px; overflow: hidden; }
.ap-progres__barre span { display: block; height: 100%; background: var(--bleu); border-radius: 50px; transition: width .4s; }
.ap-progres__texte { font-size: .85rem; font-weight: 600; color: var(--texte-doux); }

.ap-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 50px; white-space: nowrap; }
.ap-badge--vert { background: #E3F6EA; color: #1B7A3D; }
.ap-badge--orange { background: #FFF1D6; color: #8A5A00; }
.ap-badge--bleu { background: var(--bleu-clair); color: var(--bleu); }
.ap-badge--gris { background: #ECEFF3; color: #5B6B82; }

.ap-reservations { list-style: none; display: grid; gap: 10px; }
.ap-reservation {
  background: var(--blanc); border-radius: 12px; box-shadow: 0 4px 14px rgba(11, 94, 215, .07);
  padding: 14px 16px; display: flex; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; align-items: center;
}
.ap-reservation__info { display: grid; gap: 2px; min-width: 0; flex: 1 1 240px; }
.ap-reservation__info strong { overflow-wrap: anywhere; }
.ap-reservation__info span { color: var(--texte-doux); font-size: .85rem; }
.ap-reservation .btn { cursor: pointer; }
.ap-note { color: var(--texte-doux); font-size: .85rem; margin-top: 10px; }

/* ---------- Page d'une formation ---------- */
.ap-retour { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--bleu); cursor: pointer; margin-bottom: 14px; }
.ap-cours__entete { display: grid; gap: 10px; margin-bottom: 20px; }
.ap-cours__entete h1 { font-size: clamp(1.3rem, 3vw, 1.8rem); overflow-wrap: anywhere; }
.ap-cours__entete .ap-progres { max-width: 420px; }
.ap-cours { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }

/* Plan des modules et leçons */
.ap-plan { background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 8px; position: sticky; top: 86px; max-height: calc(100vh - 110px); overflow-y: auto; }
.ap-plan > summary { list-style: none; cursor: pointer; font-weight: 700; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ap-plan > summary::-webkit-details-marker { display: none; }
.ap-plan > summary::after { content: "▾"; color: var(--bleu); }
.ap-plan[open] > summary::after { content: "▴"; }
.ap-module { padding: 6px 4px 10px; }
.ap-module__titre { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--bleu); padding: 6px 8px; }
.ap-lecons { list-style: none; display: grid; gap: 2px; }
.ap-lecon {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font: inherit; font-size: .9rem; color: var(--texte);
  display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start;
  padding: 8px 10px; border-radius: 10px;
}
.ap-lecon:hover { background: #F4F7FC; }
.ap-lecon[aria-current="true"] { background: var(--bleu-clair); font-weight: 700; color: var(--bleu-fonce); }
.ap-lecon__coche {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #CBD6E6;
  display: grid; place-items: center; font-size: .7rem; font-weight: 800; margin-top: 1px;
}
.ap-lecon--faite .ap-lecon__coche { background: var(--bleu); border-color: var(--bleu); color: var(--blanc); }

/* Contenu de la leçon */
.ap-lecon-vue { background: var(--blanc); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 22px; display: grid; gap: 16px; min-width: 0; }
.ap-lecon-vue__module { color: var(--bleu); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.ap-lecon-vue h2 { font-size: clamp(1.2rem, 2.6vw, 1.5rem); overflow-wrap: anywhere; }
.ap-lecon-vue__description { color: var(--texte-doux); white-space: pre-line; overflow-wrap: anywhere; }
.ap-video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0B1B33; border-radius: 12px; overflow: hidden; }
.ap-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Vidéo verticale (YouTube Shorts) : format 9:16, centrée, sans dépasser la hauteur de l'écran */
.ap-video--verticale { aspect-ratio: 9 / 16; width: min(100%, 360px, calc(72vh * 9 / 16)); margin: 0 auto; }
.ap-sans-video { background: var(--bleu-clair); border-radius: 12px; padding: 18px; color: var(--texte-doux); font-size: .92rem; }

.ap-docs { display: grid; gap: 8px; }
.ap-docs h3 { font-size: 1rem; }
.ap-doc {
  display: flex; align-items: center; gap: 12px; width: 100%; flex-wrap: wrap;
  background: #F7FAFE; border: 1px solid #DCE6F5; border-radius: 12px; padding: 10px 12px;
  font: inherit; text-align: left; color: var(--texte);
}
.ap-doc__icone { flex: none; width: 38px; height: 38px; border-radius: 8px; background: var(--bleu); color: var(--blanc); display: grid; place-items: center; font-size: .7rem; font-weight: 800; }
.ap-doc__infos { display: grid; gap: 2px; flex: 1 1 180px; min-width: 0; }
.ap-doc__nom { font-weight: 600; overflow-wrap: anywhere; }
.ap-doc__taille { color: var(--texte-doux); font-size: .8rem; white-space: nowrap; }
.ap-doc__actions { display: flex; gap: 8px; flex: none; }
.ap-doc__actions .btn { padding: 8px 14px; font-size: .85rem; }
.ap-doc__actions a[aria-disabled="true"] { opacity: .55; }
@media (max-width: 480px) {
  .ap-doc__actions { flex: 1 1 100%; }
  .ap-doc__actions .btn { flex: 1; text-align: center; }
}

.ap-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; border-top: 1px solid #EEF2F8; padding-top: 16px; }
.ap-actions .btn { cursor: pointer; }
.ap-actions__nav { display: flex; gap: 8px; flex-wrap: wrap; }
.btn--fait { background: #1B7A3D; border-color: #1B7A3D; }
.btn--fait:hover { background: #15652F; border-color: #15652F; }
.ap-felicitations { background: #E3F6EA; color: #1B7A3D; border-radius: 12px; padding: 14px 16px; font-weight: 600; }

/* ---------- Message temporaire ---------- */
.ap-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--texte); color: var(--blanc); padding: 12px 20px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 600; max-width: calc(100% - 32px); text-align: center;
}
.ap-toast--erreur { background: #B3261E; }

/* ---------- Tablettes et téléphones ---------- */
@media (max-width: 900px) {
  .ap-cours { grid-template-columns: 1fr; }
  .ap-plan { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .ap-entete__titre { display: none; }
  .ap-entete__compte span { display: none; }
  .ap-main { padding: 18px 14px 50px; }
  .ap-carte, .ap-lecon-vue { padding: 18px; }
  .ap-actions { flex-direction: column-reverse; align-items: stretch; }
  .ap-actions .btn { width: 100%; text-align: center; }
  .ap-actions__nav { display: grid; grid-template-columns: 1fr 1fr; }
  .ap-reservation .btn { width: 100%; text-align: center; }
}
