/* =============================================
   QUIZ.CSS — Wikimind AI v5
   ============================================= */

/* ── CANVAS PANEL (côté droit) ── */
#qz-panel {
  position: fixed;
  top: 0; right: 0;
  width: 460px;
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
#qz-panel.open {
  transform: translateX(0);
}
body.qz-panel-open #app {
  margin-right: 460px;
  transition: margin-right 0.32s cubic-bezier(0.4,0,0.2,1);
}

/* ── HEADER ── */
#qz-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg2);
}
#qz-panel-head-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(99,179,237,0.12);
  display: flex; align-items: center; justify-content: center;
}
#qz-panel-head-icon img { width: 22px; height: 22px; object-fit: contain; }
#qz-panel-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#qz-panel-subtitle {
  font-size: 0.7rem;
  color: var(--text3);
  margin-top: 1px;
}
#qz-close-btn {
  width: 28px; height: 28px;
  border: none;
  background: var(--bg3);
  border-radius: 7px;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
}
#qz-close-btn:hover { background: var(--bg4); color: var(--text); }

/* ── SCORE BAR (header droit) ── */
#qz-score-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: rgba(99,179,237,0.1);
  border: 1px solid rgba(99,179,237,0.25);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #63b3ed;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── TOOLBAR ── */
#qz-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
#qz-count {
  font-size: 0.72rem;
  color: var(--text3);
  margin-right: auto;
  white-space: nowrap;
}
.qz-tool-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border2);
  border-radius: 7px;
  background: transparent;
  color: var(--text2);
  font-family: 'Geist', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.12s;
  white-space: nowrap;
}
.qz-tool-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.qz-tool-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.qz-tool-btn.primary {
  background: rgba(99,179,237,0.12);
  border-color: rgba(99,179,237,0.3);
  color: #63b3ed;
}
.qz-tool-btn.primary:hover { background: rgba(99,179,237,0.2); }
.qz-tool-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* ── NAVIGATION ── */
#qz-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}
.qz-nav-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
.qz-nav-btn:hover:not(:disabled) { background: var(--bg4); color: var(--text); }
.qz-nav-btn:disabled { opacity: 0.3; cursor: default; }
#qz-nav-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  min-width: 60px;
  text-align: center;
}

/* ── BARRE DE PROGRESSION ── */
#qz-progress-bar-wrap {
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  margin: 0 14px 2px;
  overflow: hidden;
  flex-shrink: 0;
}
#qz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #63b3ed, #ec4899);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── ZONE DES QUESTIONS ── */
#qz-cards-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#qz-cards-area::-webkit-scrollbar { width: 3px; }
#qz-cards-area::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ── CARTE QUESTION ── */
.qz-card {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  transition: border-color 0.15s;
}
.qz-card.answered-correct { border-color: rgba(74,222,128,0.4); background: rgba(74,222,128,0.04); }
.qz-card.answered-wrong   { border-color: rgba(239,68,68,0.35); background: rgba(239,68,68,0.04); }

.qz-card-num {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 8px;
}
.qz-card-question {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 14px;
}
.qz-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.qz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.12s;
  font-size: 0.84rem;
  color: var(--text2);
  text-align: left;
  line-height: 1.45;
  font-family: 'Geist', sans-serif;
  width: 100%;
}
.qz-option:hover:not(:disabled) {
  background: rgba(99,179,237,0.08);
  border-color: rgba(99,179,237,0.3);
  color: var(--text);
}
.qz-option-letter {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s;
  margin-top: 1px;
}
.qz-option:hover:not(:disabled) .qz-option-letter {
  background: rgba(99,179,237,0.15);
  border-color: rgba(99,179,237,0.4);
  color: #63b3ed;
}
.qz-option.selected {
  border-color: rgba(99,179,237,0.5);
  background: rgba(99,179,237,0.1);
  color: var(--text);
}
.qz-option.selected .qz-option-letter {
  background: #63b3ed;
  border-color: #63b3ed;
  color: #000;
}
.qz-option.correct {
  border-color: rgba(74,222,128,0.5);
  background: rgba(74,222,128,0.1);
  color: #4ade80;
}
.qz-option.correct .qz-option-letter {
  background: #4ade80;
  border-color: #4ade80;
  color: #000;
}
.qz-option.wrong {
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.08);
  color: #f87171;
}
.qz-option.wrong .qz-option-letter {
  background: rgba(239,68,68,0.3);
  border-color: rgba(239,68,68,0.5);
  color: #f87171;
}
.qz-option:disabled { cursor: default; }

/* explication après réponse */
.qz-explanation {
  margin-top: 10px;
  padding: 9px 12px;
  background: var(--bg4);
  border-left: 3px solid rgba(99,179,237,0.5);
  border-radius: 0 8px 8px 0;
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.5;
  display: none;
}
.qz-explanation.show { display: block; }
.qz-explanation strong { color: var(--text); }

/* ── RÉSULTAT FINAL ── */
#qz-results-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 18px;
  text-align: center;
}
#qz-results-screen.show { display: flex; }

.qz-result-ring {
  width: 88px; height: 88px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 3px solid;
  position: relative;
}
.qz-result-ring.great  { border-color: #4ade80; background: rgba(74,222,128,0.08); }
.qz-result-ring.ok     { border-color: #fbbf24; background: rgba(251,191,36,0.08); }
.qz-result-ring.poor   { border-color: #f87171; background: rgba(248,113,113,0.08); }

.qz-result-pct {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}
.qz-result-ring.great .qz-result-pct { color: #4ade80; }
.qz-result-ring.ok    .qz-result-pct { color: #fbbf24; }
.qz-result-ring.poor  .qz-result-pct { color: #f87171; }

.qz-result-label { font-size: 0.62rem; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.qz-result-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.qz-result-sub   { font-size: 0.82rem; color: var(--text2); line-height: 1.5; }

.qz-result-stats {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.qz-stat-box {
  flex: 1;
  max-width: 100px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.qz-stat-box .qz-stat-n {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}
.qz-stat-box.correct-box .qz-stat-n { color: #4ade80; }
.qz-stat-box.wrong-box   .qz-stat-n { color: #f87171; }
.qz-stat-box .qz-stat-lbl {
  font-size: 0.65rem;
  color: var(--text3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.qz-result-btns {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}
.qz-result-btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 9px;
  font-family: 'Geist', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  transition: all 0.12s;
}
.qz-result-btn:hover { background: var(--bg4); color: var(--text); }
.qz-result-btn.primary {
  background: rgba(99,179,237,0.15);
  border-color: rgba(99,179,237,0.4);
  color: #63b3ed;
}
.qz-result-btn.primary:hover { background: rgba(99,179,237,0.25); }

/* ── MODAL CONFIG ── */
#qz-config-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 10010;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#qz-config-overlay.open { opacity: 1; pointer-events: all; }

#qz-config-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 24px;
  width: 360px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#qz-config-box h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
#qz-config-box h3 img {
  width: 20px; height: 20px; object-fit: contain;
}
.qz-config-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 6px;
}
.qz-config-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.qz-config-pill {
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text2);
  font-family: 'Geist', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.qz-config-pill:hover { background: var(--bg4); color: var(--text); }
.qz-config-pill.active {
  background: rgba(99,179,237,0.15);
  border-color: rgba(99,179,237,0.45);
  color: #63b3ed;
}
.qz-config-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── THINKING QUIZ ── */
.thinking-qz {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid rgba(99,179,237,0.2);
  border-radius: 12px;
  font-size: 0.82rem;
  color: var(--text2);
}
.thinking-qz-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(99,179,237,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.thinking-qz-icon img { width: 18px; height: 18px; object-fit: contain; }

/* ── FILE CARD (dans le chat) ── */
.wm-qz-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid rgba(99,179,237,0.25);
  border-radius: 12px;
  margin-top: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  max-width: 320px;
}
.wm-qz-file-card:hover { background: var(--bg4); border-color: rgba(99,179,237,0.5); }
.wm-qz-file-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: rgba(99,179,237,0.1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wm-qz-file-icon img { width: 24px; height: 24px; object-fit: contain; }
.wm-qz-file-info { flex: 1; min-width: 0; }
.wm-qz-file-name { font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-qz-file-meta { font-size: 0.7rem; color: var(--text3); margin-top: 2px; }
.wm-qz-file-open {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.3);
  border-radius: 7px;
  color: #63b3ed;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.wm-qz-file-open:hover { background: rgba(99,179,237,0.22); }

/* ── CHIP ACTIF ── */
.qz-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.3);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #63b3ed;
  cursor: default;
  flex-shrink: 0;
  height: 24px;
}
.qz-active-chip img { width: 13px; height: 13px; object-fit: contain; }
.qz-active-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
  font-size: 0.7rem;
  margin-left: 1px;
}
.qz-active-chip-remove:hover { opacity: 1; }

/* ── EMPTY STATE ── */
#qz-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text3);
  padding: 20px;
  text-align: center;
}
#qz-empty img { width: 48px; height: 48px; opacity: 0.35; }
#qz-empty p { font-size: 0.82rem; line-height: 1.5; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  #qz-panel {
    width: 100vw;
    border-left: none;
    border-top: 1px solid var(--border2);
    height: 65vh;
    top: auto; bottom: 0;
    transform: translateY(100%);
  }
  #qz-panel.open { transform: translateY(0); }
  body.qz-panel-open #app { margin-right: 0; }
}
