/* ===== Guide interactif ===== */

/* ---- Panneau principal (bas-droite par défaut) ---- */
#guide-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: auto;
  width: 360px;
  max-height: 78vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(8, 44, 124, 0.22), 0 2px 12px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  /* Très haut : les fenêtres internes ianseo (recherche, dialogs) montent au-dessus de 10000 */
  z-index: 2147483000;
  font-family: "Poppins", "PoppinsFallback", "Helvetica", sans-serif;
  font-size: 13px;
  overflow: hidden;
  transition: right .25s ease, left .25s ease;
}

#guide-panel.guide-panel-left {
  right: auto;
  left: 20px;
}

#guide-panel.guide-panel-wide {
  width: 720px;
  max-width: calc(100vw - 40px);
}

/* Réduction exceptionnelle (le temps d'un trigger) quand le panneau couvre l'élément des deux côtés.
   Déclaré après .guide-panel-wide pour l'emporter si les deux classes coexistent. */
#guide-panel.guide-panel-half {
  width: 190px;
  max-height: 42vh;
}

/* ---- Header ---- */
#guide-panel-header {
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%);
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#guide-panel-toggle-side {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  padding: 0;
  line-height: 1;
}
#guide-panel-toggle-side:hover { background: rgba(255,255,255,.3); }

#guide-panel-header-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  flex: 1;
  text-align: center;
}

#guide-panel-header-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
#guide-panel-min,
#guide-panel-max,
#guide-panel-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  transition: background .15s;
}
#guide-panel-min:hover,
#guide-panel-max:hover { background: rgba(255,255,255,.3); }
#guide-panel-close:hover { background: #e74c3c; }

/* ---- Nom formation ---- */
#guide-panel-formation-name {
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%);
  color: rgba(255,255,255,.8);
  padding: 0 14px 9px;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  letter-spacing: .2px;
  line-height: 1.3;
}

/* ---- Progression ---- */
#guide-panel-progress {
  padding: 8px 14px 7px;
  border-bottom: 1px solid #eef0f8;
  flex-shrink: 0;
  background: #f7f9ff;
}
#guide-panel-progress-bar {
  height: 4px;
  background: #dde2f5;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}
#guide-panel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0254a8, #082c7c);
  border-radius: 2px;
  transition: width .35s ease;
}
#guide-panel-progress-text {
  font-size: 10px;
  color: #8a94c0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---- Contenu étape ---- */
#guide-panel-step {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 6px;
}

/* ---- Image d'étape (16:9, bandes noires automatiques) ---- */
#guide-panel-step-image { margin-bottom: 10px; }
.guide-img-16x9 {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.guide-img-16x9 img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

#guide-panel-step-title {
  font-size: 14px;
  font-weight: 700;
  color: #082c7c;
  margin-bottom: 10px;
  line-height: 1.3;
}

#guide-panel-step-content { color: #3a3f5c; line-height: 1.6; }
#guide-panel-step-content p { margin: 0 0 8px; clear: both; }
#guide-panel-step-content p:last-child { margin-bottom: 0; }
#guide-panel-step-content ul,
#guide-panel-step-content ol { list-style: none !important; padding: 0 !important; margin: 4px 0 8px 8px !important; }
#guide-panel-step-content li { display: block !important; float: none !important; clear: none !important; margin-bottom: 4px !important; padding-left: 14px !important; }
#guide-panel-step-content ul > li::before {
  content: "•";
  display: inline-block; width: 14px; margin-left: -14px;
}
#guide-panel-step-content ol { counter-reset: guide-ol; }
#guide-panel-step-content ol > li { counter-increment: guide-ol; padding-left: 22px !important; }
#guide-panel-step-content ol > li::before {
  content: counter(guide-ol) ".";
  display: inline-block; width: 22px; margin-left: -22px; font-weight: 600;
}

#guide-panel-step-content code {
  background: #eef2ff;
  border: 1px solid #c5cef5;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: monospace;
  color: #082c7c;
  font-weight: 600;
}
#guide-panel-step-content b { color: #082c7c; }

.guide-tip {
  background: #fff8e6;
  border-left: 3px solid #f5a623;
  padding: 7px 10px;
  margin: 8px 0 4px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: #664d00;
  line-height: 1.5;
}

/* ---- Attente condition état ---- */
#guide-panel-condition-wait {
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px dashed #d8dcf0;
}
.guide-condition-wait {
  background: #f3f0ff;
  border-left: 3px solid #7c5cbf;
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  margin: 0;
  color: #3a2660;
  line-height: 1.5;
}

/* ---- Info mauvaise page ---- */
#guide-panel-page-info {
  margin: 10px 0 4px;
  padding-top: 10px;
  border-top: 1px dashed #d8dcf0;
}
.guide-page-warning {
  background: #eef4ff;
  border-left: 3px solid #0254a8;
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  margin: 0;
  color: #2a2f5a;
  line-height: 1.5;
}
.guide-page-link {
  display: inline-block;
  margin-top: 7px;
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%);
  color: #fff !important;
  padding: 6px 16px;
  border-radius: 6px;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 600;
  transition: opacity .15s;
}
.guide-page-link:hover { opacity: .88; }

/* ---- Bouton "Marquer comme fait" ---- */
#guide-panel-validate {
  padding: 10px 16px 0;
  flex-shrink: 0;
}
#guide-btn-validate {
  width: 100%;
  padding: 8px 0;
  border-radius: 8px;
  border: 2px dashed #0254a8;
  background: transparent;
  color: #0254a8;
  font-family: "Poppins", "Helvetica", sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .2px;
}
#guide-btn-validate:hover { background: #eef4ff; }
#guide-btn-validate.guide-validated {
  border-style: solid;
  border-color: #1a8a4a;
  color: #1a8a4a;
  background: #edfaf3;
}

/* ---- Navigation bas ---- */
#guide-panel-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #eef0f8;
  background: #f7f9ff;
  flex-shrink: 0;
  gap: 6px;
}
#guide-panel-nav button {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid #d0d8f0;
  cursor: pointer;
  font-size: 12px;
  font-family: "Poppins", "Helvetica", sans-serif;
  font-weight: 500;
  background: #fff;
  color: #444;
  transition: all .15s;
  white-space: nowrap;
}
#guide-panel-nav button:disabled { opacity: .35; cursor: default; }
#guide-panel-nav button:hover:not(:disabled) { background: #eef2ff; border-color: #0254a8; color: #0254a8; }

#guide-btn-restart,
#guide-btn-back {
  padding: 7px 9px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

#guide-btn-next {
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%) !important;
  color: #fff !important;
  border: none !important;
  flex: 1;
}
#guide-btn-next:hover:not(:disabled) { opacity: .9; color: #fff !important; }

/* ===== FAB (panneau réduit) ===== */
#guide-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: auto;
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 18px 10px 14px;
  cursor: pointer;
  font-family: "Poppins", "Helvetica", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .4px;
  z-index: 2147482900;
  display: none;
  box-shadow: 0 4px 18px rgba(8, 44, 124, 0.4);
  transition: all .2s;
  align-items: center;
  gap: 7px;
}
#guide-fab.guide-fab-left { right: auto; left: 20px; }
#guide-fab:hover { transform: translateY(-2px); box-shadow: 0 7px 22px rgba(8, 44, 124, 0.5); }

/* ===== Surbrillance avec box-shadow cutout ===== */
/* L'élément se détache en envoyant une ombre géante qui assombrit tout le reste */
.guide-highlight {
  position: relative !important;
  z-index: 9995 !important;
  border-radius: 4px !important;
  animation: guide-glow 1.8s ease-in-out infinite;
}

@keyframes guide-glow {
  0%, 100% {
    box-shadow: 0 0 0 3px #0254a8,
                0 0 0 9999px rgba(8, 28, 100, 0.48) !important;
  }
  50% {
    box-shadow: 0 0 0 5px #0254a8,
                0 0 18px rgba(2, 84, 168, 0.6),
                0 0 0 9999px rgba(8, 28, 100, 0.48) !important;
  }
}

/* Flèche indicatrice + bulle hint positionnées par JS */
#guide-highlight-arrow {
  position: fixed;
  /* Au-dessus des fenêtres internes ianseo ET du panneau (qui s'écarte automatiquement) */
  z-index: 2147483100;
  pointer-events: none;
  text-align: left;
  animation: guide-bounce .8s ease-in-out infinite alternate;
}
#guide-highlight-arrow > div:first-child {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(8,44,124,.4));
}
#guide-highlight-hint {
  margin-top: 5px;
  background: #fff;
  border: 1.5px solid #0254a8;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: "Poppins", "Helvetica", sans-serif;
  color: #2a2f5a;
  line-height: 1.45;
  max-width: 220px;
  white-space: normal;
  text-align: left;
  box-shadow: 0 3px 14px rgba(8,44,124,.14);
}
@keyframes guide-bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-5px); }
}

/* ===== Bouton Suivant verrouillé ===== */
#guide-btn-next.guide-btn-locked {
  background: #b8c4dc !important;
  color: #6b7db3 !important;
  cursor: not-allowed !important;
}
#guide-btn-next.guide-btn-locked::after {
  content: " 🔒";
  font-size: 10px;
}

/* Flash panneau (mode non-permissif : clic hors cible) */
@keyframes guide-panel-flash {
  0%, 100% { box-shadow: 0 8px 40px rgba(8, 44, 124, 0.22), 0 2px 12px rgba(0,0,0,.08); }
  30%, 70%  { box-shadow: 0 0 0 3px #c0392b, 0 8px 30px rgba(192, 57, 43, 0.5); }
}
#guide-panel.guide-panel-flash { animation: guide-panel-flash .4s ease; }

/* ===== Vues du panneau : boutons d'action (fin, QCM, défi, checklist, FAQ) ===== */
.guide-cta {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #c8d4ec;
  background: #fff;
  color: #2a2f5a;
  font-family: "Poppins", "Helvetica", sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
}
.guide-cta:hover:not(:disabled) { border-color: #0254a8; background: #eef4ff; color: #0254a8; }
.guide-cta-main {
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%) !important;
  color: #fff !important;
  border: none !important;
}
.guide-cta-main:hover:not(:disabled) { opacity: .9; }
.guide-cta-ghost { background: #f7f9ff; color: #666; font-weight: 500; }

/* QCM */
.guide-quiz-good { border-color: #1a8a4a !important; background: #e8faf0 !important; color: #1a5a33 !important; opacity: 1 !important; }
.guide-quiz-bad  { border-color: #c0392b !important; background: #fdecea !important; color: #8a1a1a !important; opacity: 1 !important; }
.guide-quiz-choice:disabled { opacity: .55; cursor: default; }
.guide-quiz-fb {
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  margin: 8px 0;
  line-height: 1.5;
}
.guide-quiz-fb.ok { background: #e8faf0; border-left: 3px solid #1a8a4a; color: #1a5a33; }
.guide-quiz-fb.ko { background: #fdecea; border-left: 3px solid #c0392b; color: #8a1a1a; }

/* Défi */
.guide-defi-cond {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 9px;
  margin: 5px 0;
  background: #f7f9ff;
  border: 1px solid #e6e9f5;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.guide-defi-cond.met { background: #e8faf0; border-color: #bfe8d0; }
.guide-defi-hint { font-size: 11px; color: #999; margin: 6px 0 0; }

/* Checklist */
.guide-ck-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 7px 4px;
  border-bottom: 1px dashed #eef0f8;
  font-size: 12.5px;
  line-height: 1.45;
  cursor: pointer;
}
.guide-ck-item input { margin-top: 2px; flex-shrink: 0; }
.guide-ck-item.done span { color: #999; text-decoration: line-through; }
.guide-ck-item.done span a { text-decoration: none; }
.guide-ck-link { color: #0254a8 !important; font-weight: 700; text-decoration: none !important; }

/* FAQ */
.guide-faq-sol {
  background: #eef4ff;
  border-left: 3px solid #0254a8;
  padding: 9px 11px;
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  margin-bottom: 8px;
  line-height: 1.55;
}

/* Badges cibles */
.guide-badge-bronze { color: #a05a2c; }
.guide-badge-argent { color: #7a828e; }
.guide-badge-or     { color: #b8860b; }

/* FAB avec pastille d'aide contextuelle */
#guide-fab.guide-fab-ctx::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: #f5a623;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ===== Enregistreur de triggers ===== */
#guide-rec {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  max-height: 70vh;
  background: #fff;
  border: 2px solid #c0392b;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(192,57,43,.28), 0 2px 12px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  z-index: 2147483200;
  font-family: "Poppins", "PoppinsFallback", "Helvetica", sans-serif;
  font-size: 13px;
  overflow: hidden;
}
#guide-rec-header {
  background: #c0392b;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.guide-rec-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: guide-rec-blink 1s steps(2, start) infinite;
}
@keyframes guide-rec-blink { 50% { opacity: .2; } }
#guide-rec.guide-rec-paused .guide-rec-dot { animation: none; opacity: .4; }
#guide-rec-title { flex: 1; font-weight: 700; font-size: 12px; letter-spacing: .3px; }
#guide-rec-close {
  background: rgba(255,255,255,.2);
  border: none; color: #fff; cursor: pointer;
  width: 24px; height: 24px; border-radius: 50%;
  flex-shrink: 0; line-height: 1; padding: 0;
}
#guide-rec-close:hover { background: rgba(255,255,255,.4); }
#guide-rec-hint {
  padding: 9px 12px;
  font-size: 11px; color: #8a4b44; line-height: 1.4;
  background: #fff4f2; border-bottom: 1px solid #f3d6d1;
  flex-shrink: 0;
}
#guide-rec-list {
  flex: 1; overflow-y: auto;
  padding: 6px 12px; min-height: 40px;
}
.guide-rec-item {
  font-size: 11px; color: #444;
  padding: 4px 8px; margin-bottom: 4px;
  background: #f7f9ff; border: 1px solid #e6e9f5; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#guide-rec-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 12px; border-top: 1px solid #eee; background: #faf6f5;
  flex-shrink: 0;
}
.guide-rec-btn {
  flex: 1 1 calc(50% - 3px);
  padding: 7px 8px; border-radius: 7px;
  border: 1px solid #d8c2bf; background: #fff; color: #444;
  cursor: pointer; font-size: 11px; font-family: inherit; font-weight: 600;
}
.guide-rec-btn:hover { background: #fdecea; border-color: #c0392b; color: #c0392b; }
.guide-rec-btn-done { background: #1a8a4a; color: #fff; border: none; }
.guide-rec-btn-done:hover { background: #157a40; color: #fff; }

/* ===== Bannière "Apprendre à utiliser ianseo" (accueil sans compétition) ===== */
#guide-learn-banner { margin: 14px 0 20px; }
#guide-learn-banner a {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 640px;
  padding: 18px 26px;
  background: linear-gradient(80deg, #0254a8 10%, #082c7c 100%);
  color: #fff !important;
  border-radius: 14px;
  text-decoration: none !important;
  font-family: "Poppins", "PoppinsFallback", "Helvetica", sans-serif;
  box-shadow: 0 6px 26px rgba(8, 44, 124, 0.35);
  transition: transform .15s, box-shadow .15s;
}
#guide-learn-banner a:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(8, 44, 124, 0.45); }
#guide-learn-banner .glb-emoji { font-size: 34px; flex-shrink: 0; }
#guide-learn-banner .glb-txt b { display: block; font-size: 19px; letter-spacing: .3px; }
#guide-learn-banner .glb-txt span { font-size: 12.5px; opacity: .85; }
#guide-learn-banner .glb-arrow { margin-left: auto; font-size: 26px; opacity: .8; }

/* Choix sélectionné (QCM à réponses multiples, avant validation) */
.guide-quiz-choice.sel {
  border-color: #0254a8 !important;
  background: #dcebff !important;
  color: #082c7c !important;
}

@media print {
  #guide-panel, #guide-fab, #guide-highlight-arrow, #guide-learn-banner { display: none !important; }
  .guide-highlight { animation: none !important; box-shadow: none !important; }
}
