/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --violet: #7c3aed;
  --violet-light: #ede9fe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --gold: #ca8a04;
  --gold-light: #fef9c3;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --gray-border: #d1d5db;
  --dark: #1f2937;
  --bg: #f8fafc;
  --white: #ffffff;
  --radius: 10px;
}

html { font-size: 80%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
}

#app { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--gray-border);
  margin-bottom: 24px;
}
.app-header h1 { font-size: 1.6rem; color: var(--dark); }

.filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.filter-btn {
  padding: 6px 14px;
  border: 2px solid var(--gray-border);
  border-radius: 20px;
  background: var(--white);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--blue); }
.filter-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

.shuffle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--gray);
}
.shuffle-label input { cursor: pointer; }

/* ===== Screens ===== */
.screen { animation: fadeIn 0.3s ease; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== Start screen ===== */
.start-card, .result-card {
  max-width: 600px;
  margin: 60px auto;
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.start-card h2, .result-card h2 { margin-bottom: 16px; }
.start-card ul {
  list-style: none;
  text-align: left;
  margin: 20px 0;
  padding: 16px;
  background: var(--gray-light);
  border-radius: var(--radius);
}
.start-card ul li { padding: 6px 0; }

/* ===== Buttons ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: var(--gray-border); cursor: not-allowed; }
.btn-secondary { background: var(--gray-light); color: var(--dark); border: 1px solid var(--gray-border); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-large { font-size: 1.1rem; padding: 14px 32px; margin-top: 20px; }
.btn-small { padding: 4px 10px; font-size: 0.8rem; }

/* ===== Quiz layout ===== */
.quiz-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.quiz-panel { flex: 1 1 60%; min-width: 0; }
.reference-panel {
  flex: 0 0 40%;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
  position: sticky;
  top: 16px;
}
.reference-panel.collapsed .reference-iframe-container { display: none; }
.reference-panel.collapsed .reference-info { display: none; }

.reference-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-light);
  border-bottom: 1px solid var(--gray-border);
}
.reference-header h3 { font-size: 1rem; }
.reference-actions { display: flex; gap: 6px; }
.reference-info {
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--gray);
  border-bottom: 1px solid var(--gray-border);
}
.reference-iframe-container { height: 600px; }
.reference-iframe-container iframe { width: 100%; height: 100%; border: none; }

/* ===== Progress ===== */
.progress-bar-container {
  height: 6px;
  background: var(--gray-border);
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ===== Question ===== */
.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.question-number { font-size: 0.9rem; color: var(--gray); font-weight: 600; }

.badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-officielle { background: var(--blue-light); color: var(--blue); }
.badge-ia { background: var(--violet-light); color: var(--violet); }

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ===== Options ===== */
.options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--white);
}
.option:hover { border-color: var(--blue); background: var(--gray-light); }
.option input[type="radio"] { margin-top: 3px; cursor: pointer; flex-shrink: 0; }
.option.selected { border-color: var(--blue); background: var(--blue-light); }
.option.correct { border-color: var(--green); background: var(--green-light); }
.option.wrong { border-color: var(--red); background: var(--red-light); }
.option.disabled { cursor: default; }
.option.disabled:hover { border-color: var(--gray-border); background: var(--white); }
.option-label { font-weight: 600; min-width: 20px; }
.option-text { flex: 1; }

/* ===== Feedback ===== */
.feedback {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.95rem;
  min-height: 20px;
}
.feedback.correct { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.feedback.wrong { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.feedback.idk { background: var(--orange-light); color: var(--orange); border: 1px solid var(--orange); }
.feedback:empty { display: none; }

/* ===== Actions ===== */
.quiz-actions { display: flex; gap: 12px; }

/* ===== Score tracker dots ===== */
.score-tracker {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.score-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-border);
}
.score-dot.correct { background: var(--green); }
.score-dot.wrong { background: var(--red); }
.score-dot.idk { background: var(--orange); }

/* ===== Result screen ===== */
.result-score {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 20px 0;
}
.result-details {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.result-detail-item {
  text-align: center;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--gray-light);
}
.result-detail-item .num { font-size: 1.5rem; font-weight: 700; display: block; }
.result-detail-item .label { font-size: 0.8rem; color: var(--gray); }

.result-breakdown {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.result-message {
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 1.05rem;
  line-height: 1.6;
}
.result-message.congrats { background: var(--green-light); border: 2px solid var(--green); color: var(--green); }
.result-message.exam { background: var(--gold-light); border: 2px solid var(--gold); color: var(--gold); }
.result-message.encourage { background: var(--orange-light); border: 2px solid var(--orange); color: var(--orange); }
.result-message p { margin: 4px 0; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .quiz-layout { flex-direction: column; }
  .quiz-panel, .reference-panel { flex: 1 1 100%; }
  .reference-panel { position: relative; top: 0; }
  .reference-iframe-container { height: 400px; }
}
@media (max-width: 600px) {
  .app-header h1 { font-size: 1.2rem; }
  .question-text { font-size: 1rem; }
  .start-card, .result-card { padding: 24px 16px; margin: 20px auto; }
  .result-score { font-size: 1.8rem; }
  .filters { gap: 4px; }
  .filter-btn { padding: 4px 10px; font-size: 0.8rem; }
}

/* ===== PDF Modal (plein écran) ===== */
.pdf-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}
.pdf-modal.hidden { display: none !important; }

.pdf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--dark);
  color: white;
  flex-shrink: 0;
}
.pdf-modal-title { font-size: 1rem; font-weight: 600; }
.pdf-modal-header .btn { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); }
.pdf-modal-header .btn:hover { background: rgba(255,255,255,0.25); }

.pdf-modal-body {
  flex: 1;
  overflow: hidden;
}
.pdf-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}