/* =========================================================
   DESL Consulting — Phase 2
   1. Boutons flottants (quiz bas-gauche, chat bas-droite)
   2. Modale du quiz de diagnostic
   3. Panneau de l'assistant conversationnel
   4. Adaptation du site au profil (réordonner + surligner)
   S'appuie sur les variables de styles.css.
   ========================================================= */

/* ---------- 1. Boutons flottants ---------- */

.fab {
  position: fixed; bottom: 22px; z-index: 80;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  font-family: var(--font-head); font-size: .85rem; font-weight: 600;
  color: var(--ink); background: rgba(13,16,24,.85);
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; backdrop-filter: blur(12px);
  transition: transform .25s ease, border-color .25s ease, background .25s ease;
}
.fab:hover, .fab:focus-visible { transform: translateY(-2px); border-color: var(--accent); }
.fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fab-ico { color: var(--accent); font-size: 1rem; }
.fab-quiz { left: 22px; }
.fab-chat { right: 22px; }
body.chat-open .fab-chat { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  .fab { bottom: 14px; padding: 11px 14px; }
  .fab-quiz { left: 12px; }
  .fab-chat { right: 12px; }
  .fab .fab-label { font-size: .78rem; }
}

/* ---------- 2. Modale du quiz ---------- */

/* L'attribut hidden doit gagner sur les display explicites ci-dessous */
.quiz-overlay[hidden], .chat-panel[hidden] { display: none !important; }

.quiz-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3,4,7,.72); backdrop-filter: blur(6px);
  padding: 18px;
}
.quiz-panel {
  width: min(520px, 100%); max-height: 86vh; overflow-y: auto;
  background: #0d1018; border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 26px 20px;
  animation: quiz-in .3s ease;
}
@keyframes quiz-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .quiz-panel { animation: none; } }

.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.quiz-step { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.quiz-close, .chat-close {
  background: none; border: none; color: var(--dim);
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.quiz-close:hover, .chat-close:hover { color: var(--ink); }

.quiz-progress { height: 2px; background: rgba(255,255,255,.08); border-radius: 2px; margin-bottom: 22px; overflow: hidden; }
.quiz-progress span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

.quiz-title { font-size: 1.25rem; margin-bottom: 6px; }
.quiz-sub { font-size: .85rem; color: var(--dim); margin-bottom: 14px; }

.quiz-options { display: grid; gap: 10px; margin: 16px 0 20px; }
.quiz-option {
  text-align: left; padding: 13px 16px;
  font-family: var(--font-body); font-size: .92rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color .2s ease, background .2s ease;
}
.quiz-option:hover, .quiz-option:focus-visible { border-color: var(--accent); }
.quiz-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quiz-option.is-selected {
  border-color: var(--accent); background: rgba(110,168,255,.12); color: var(--accent-2);
}

.quiz-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.quiz-foot-result { margin-top: 18px; justify-content: flex-start; }
.quiz-back {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: .85rem; padding: 8px 0;
}
.quiz-back:hover { color: var(--ink); }
.quiz-forget { color: var(--faint); margin-left: auto; }
.quiz-next { margin-left: auto; }
.quiz-next:disabled { opacity: .4; cursor: not-allowed; }

.quiz-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.quiz-actions .btn-solid, .quiz-actions .btn-line { font-size: .88rem; }
.quiz-rgpd { margin-top: 16px; font-size: .72rem; color: var(--faint); }

/* Boutons génériques dans la modale (reprend le style du site) */
.quiz-panel .btn-solid {
  display: inline-block; padding: 12px 20px; border: none; border-radius: 999px;
  background: var(--accent); color: #06070b; font-weight: 600; cursor: pointer;
  font-family: var(--font-head);
}
.quiz-panel .btn-solid:hover { background: var(--accent-2); }
.quiz-panel .btn-line {
  display: inline-block; padding: 11px 20px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--ink); font-family: var(--font-head); font-weight: 600;
}
.quiz-panel .btn-line:hover { border-color: var(--accent); }

/* ---------- 3. Assistant conversationnel ---------- */

.chat-panel {
  position: fixed; bottom: 22px; right: 22px; z-index: 90;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 44px));
  display: flex; flex-direction: column;
  background: #0d1018; border: 1px solid var(--line); border-radius: 16px;
  overflow: hidden; animation: quiz-in .3s ease;
}
@media (prefers-reduced-motion: reduce) { .chat-panel { animation: none; } }
@media (max-width: 640px) {
  .chat-panel { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
}

.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: rgba(110,168,255,.06);
}
.chat-title strong { font-family: var(--font-head); font-size: .95rem; display: block; }
.chat-title span { font-size: .72rem; color: var(--dim); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 14px;
  font-size: .88rem; line-height: 1.5; white-space: pre-wrap;
}
.chat-msg-bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg-user { align-self: flex-end; background: rgba(110,168,255,.16); border: 1px solid rgba(110,168,255,.3); border-bottom-right-radius: 4px; }

.chat-typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--dim);
  animation: chat-blink 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 14px 6px; border-top: 1px solid var(--line);
}
.chat-input {
  flex: 1; resize: none; max-height: 90px;
  padding: 10px 14px; font-family: var(--font-body); font-size: .88rem;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send {
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; border-radius: 50%; background: var(--accent); color: #06070b;
  font-size: 1.1rem; cursor: pointer; transition: background .2s ease;
}
.chat-send:hover { background: var(--accent-2); }
.chat-send:disabled { opacity: .4; cursor: wait; }
.chat-rgpd { padding: 4px 16px 10px; font-size: .68rem; color: var(--faint); }

/* ---------- 4. Adaptation au profil ---------- */

[data-pains], [data-profiles] { position: relative; }

.is-adapted {
  border-color: rgba(110,168,255,.45) !important;
  box-shadow: 0 0 32px rgba(110,168,255,.10);
}
.adapt-badge {
  display: inline-block; width: fit-content; align-self: flex-start;
  margin-bottom: 12px;
  padding: 4px 10px; border-radius: 999px;
  font-family: var(--font-head); font-size: .68rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-2); background: rgba(110,168,255,.14);
  border: 1px solid rgba(110,168,255,.35);
}

/* Empêche les curseurs personnalisés de masquer les widgets tactiles */
body.quiz-open { overflow: hidden; }
