/* ═══════════════════════════════════════════════════════════════
   2D+ FORMATION — Styles globaux
   Palette : bleu marine #1e40af · bleu vif #3b82f6 · blanc · gris clair
════════════════════════════════════════════════════════════════ */

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

:root {
  --blue-dark:   #1e40af;
  --blue:        #3b82f6;
  --blue-light:  #eff6ff;
  --blue-border: #bfdbfe;
  --green:       #15803d;
  --green-light: #f0fdf4;
  --red:         #be123c;
  --red-light:   #fff1f2;
  --orange:      #d97706;
  --orange-light:#fffbeb;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-400:    #94a3b8;
  --gray-600:    #475569;
  --gray-800:    #1e293b;
  --sidebar-w:   260px;
  --topbar-h:    56px;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ── Utilitaires ── */
.text-muted     { color: var(--gray-400); }
.text-green     { color: var(--green); }
.text-red       { color: var(--red); }
.text-blue      { color: var(--blue); }
.text-sm        { font-size: 12px; }
.fw-bold        { font-weight: 600; }
.mt-8           { margin-top: 8px; }
.mt-16          { margin-top: 16px; }
.mt-24          { margin-top: 24px; }

/* ═══════════════════════════════════════
   BADGES
══════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-light);  color: var(--blue-dark); }
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-orange { background: var(--orange-light);color: var(--orange); }
.badge-gray   { background: var(--gray-100);    color: var(--gray-600); }

/* ═══════════════════════════════════════
   BOUTONS
══════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); }
.btn-primary:hover:not(:disabled)  { background: var(--blue); border-color: var(--blue); }
.btn-success  { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover:not(:disabled)  { background: #166534; }
.btn-danger   { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover:not(:disabled)   { background: #9f1239; }
.btn-secondary{ background: #fff; color: var(--gray-800); border-color: var(--gray-200); }
.btn-secondary:hover:not(:disabled){ background: var(--gray-100); }
.btn-ghost    { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover:not(:disabled)    { background: var(--gray-100); }
.btn-full     { width: 100%; justify-content: center; padding: 12px; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-icon     { padding: 6px; border-radius: 6px; }

/* ═══════════════════════════════════════
   FORMULAIRES
══════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-weight: 500; font-size: 13px; color: var(--gray-600);
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"],
textarea, select {
  width: 100%; padding: 9px 12px; border-radius: 7px;
  border: 1px solid var(--gray-200); background: #fff;
  font-size: 14px; color: var(--gray-800);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.hint { color: var(--gray-400); font-size: 11px; margin-top: 4px; display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.select-sm { padding: 6px 10px; border: 1px solid var(--gray-200); border-radius: 7px; font-size: 13px; }

/* ═══════════════════════════════════════
   ALERTES
══════════════════════════════════════ */
.alert {
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-top: 10px; line-height: 1.5;
}
.alert-error   { background: var(--red-light);   color: var(--red);   border: 1px solid #fecdd3; }
.alert-success { background: var(--green-light);  color: var(--green); border: 1px solid #bbf7d0; }
.alert-info    { background: var(--blue-light);   color: var(--blue-dark); border: 1px solid var(--blue-border); }
.alert-warning { background: var(--orange-light); color: var(--orange); border: 1px solid #fde68a; }

/* ═══════════════════════════════════════
   ÉCRAN DE CONNEXION
══════════════════════════════════════ */
.login-screen {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff; font-size: 20px; font-weight: 800; letter-spacing: -1px;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.login-logo p  { color: var(--gray-400); font-size: 13px; margin-top: 4px; }
.login-footer  { text-align: center; color: var(--gray-400); font-size: 12px; margin-top: 20px; }

/* Code d'accès stagiaire */
.input-code {
  font-size: 28px !important; letter-spacing: 8px;
  text-align: center; font-weight: 700;
}
.trainee-welcome-card {
  text-align: center; padding: 20px;
  background: var(--blue-light); border-radius: 12px;
}
.trainee-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--blue-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; margin: 0 auto 12px;
}
.trainee-welcome-card h2  { font-size: 20px; color: var(--gray-800); }
.trainee-welcome-card p   { color: var(--gray-600); font-size: 13px; margin-top: 4px; }

/* ═══════════════════════════════════════
   APP SHELL
══════════════════════════════════════ */
.app-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); height: 100vh;
  background: #fff; border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow-y: auto;
  z-index: 200;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid var(--gray-200);
  min-height: 56px;
}
.logo-badge-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: #fff; font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.sidebar-brand { font-weight: 700; font-size: 15px; flex: 1; }
.sidebar-close { display: none; border: none; background: none; cursor: pointer; font-size: 16px; color: var(--gray-400); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--gray-100);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--gray-400); }

.sidebar-nav  { flex: 1; padding: 8px 0; }
.sidebar-bottom { padding: 8px 0; border-top: 1px solid var(--gray-200); }

.nav-section { padding: 0; }
.nav-section-label {
  padding: 12px 16px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gray-400);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer; border-radius: 0;
  color: var(--gray-600); font-size: 14px;
  text-decoration: none; transition: background .1s;
}
.nav-item:hover  { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--blue-light); color: var(--blue-dark); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 190; display: none;
}
.sidebar-overlay:not(.hidden) { display: block; }

/* ── Main ── */
.main-content {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--gray-100);
}

.topbar {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 20px; height: var(--topbar-h); flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}
.btn-hamburger {
  display: none; border: none; background: none;
  cursor: pointer; font-size: 20px; padding: 4px;
}
.page-title { font-size: 16px; font-weight: 700; flex: 1; }
.topbar-user { font-size: 13px; color: var(--gray-600); }

/* ── Sections ── */
.section { padding: 24px 20px; flex: 1; }
.section-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.section-header h2 { font-size: 20px; font-weight: 700; flex: 1; }

/* ═══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 18px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 8px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--gray-200); padding: 20px;
  text-align: center;
}
.stat-icon  { font-size: 24px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--blue-dark); margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--gray-400); }

/* ═══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
thead tr { background: var(--gray-50); }
th {
  padding: 10px 14px; text-align: left;
  font-weight: 600; font-size: 12px; color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
td {
  padding: 11px 14px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.table-toolbar {
  display: flex; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100); flex-wrap: wrap;
}
.search-input {
  max-width: 280px; padding: 7px 12px;
  border: 1px solid var(--gray-200); border-radius: 7px;
  font-size: 13px;
}

/* ═══════════════════════════════════════
   UPLOAD ZONE
══════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--gray-200); border-radius: 12px;
  padding: 40px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--gray-50);
}
.upload-zone:hover { border-color: var(--blue); background: var(--blue-light); }
.upload-zone.drag-over { border-color: var(--blue); background: var(--blue-light); }
.upload-icon { font-size: 40px; margin-bottom: 12px; }

/* ═══════════════════════════════════════
   MODAL
══════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay:not(.hidden) { display: flex; }
.modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: slideUp .2s ease;
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  border: none; background: none; cursor: pointer;
  font-size: 18px; color: var(--gray-400); padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--gray-100); }
.modal-body  { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer{
  padding: 14px 20px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ═══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  background: #fff; border-radius: 10px; padding: 12px 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; max-width: 340px;
  border-left: 4px solid transparent;
  animation: toastIn .25s ease;
}
.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-info    { border-left-color: var(--blue); }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ═══════════════════════════════════════
   QUIZ SCREEN
══════════════════════════════════════ */
.quiz-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--gray-100);
}
.quiz-header {
  background: #fff; border-bottom: 1px solid var(--gray-200);
  padding: 0 20px; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.quiz-header-left { display: flex; align-items: center; gap: 12px; }
.quiz-title    { font-weight: 700; font-size: 15px; }
.quiz-subtitle { font-size: 12px; color: var(--gray-400); }
.quiz-header-right { display: flex; align-items: center; gap: 16px; }
.quiz-progress-info { font-size: 13px; color: var(--gray-600); font-weight: 600; }
.quiz-timer    { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.quiz-timer.warning { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.quiz-progress-bar { height: 4px; background: var(--gray-200); }
.quiz-progress-fill{ height: 100%; background: var(--blue); transition: width .3s; }

.quiz-tabs-bar { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 0 20px; }
.quiz-tabs     { display: flex; gap: 4px; overflow-x: auto; }
.quiz-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  border-bottom: 3px solid transparent; color: var(--gray-600); white-space: nowrap;
  transition: all .15s;
}
.quiz-tab.active { border-bottom-color: var(--blue-dark); color: var(--blue-dark); font-weight: 600; }
.quiz-tab.done   { color: var(--green); }

.quiz-main { flex: 1; padding: 24px 20px; display: flex; justify-content: center; }
.question-card {
  background: #fff; border-radius: 14px; padding: 28px;
  max-width: 700px; width: 100%;
  box-shadow: var(--shadow);
}
.question-number {
  font-size: 12px; font-weight: 600; color: var(--blue);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px;
}
.question-text {
  font-size: 16px; font-weight: 500; line-height: 1.6;
  color: var(--gray-800); margin-bottom: 24px;
}
.answers-list { display: flex; flex-direction: column; gap: 10px; }
.answer-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: 10px;
  border: 2px solid var(--gray-200); cursor: pointer;
  transition: all .15s; background: #fff;
}
.answer-option:hover { border-color: var(--blue); background: var(--blue-light); }
.answer-option.selected { border-color: var(--blue-dark); background: var(--blue-light); }
.answer-option.correct  { border-color: var(--green); background: var(--green-light); }
.answer-option.wrong    { border-color: var(--red); background: var(--red-light); }
.answer-radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--gray-200); flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
}
.answer-option.selected .answer-radio { border-color: var(--blue-dark); background: var(--blue-dark); }
.answer-radio::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff;
  display: none;
}
.answer-option.selected .answer-radio::after { display: block; }
.answer-text { font-size: 14px; line-height: 1.5; }

.quiz-footer {
  background: #fff; border-top: 1px solid var(--gray-200);
  padding: 12px 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  position: sticky; bottom: 0;
}
.dot-nav { display: flex; gap: 6px; flex-wrap: wrap; max-width: 300px; justify-content: center; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--gray-200); cursor: pointer; transition: all .15s;
}
.dot.current  { background: var(--blue-dark); transform: scale(1.2); }
.dot.answered { background: var(--blue); }
.dot.passed   { background: var(--green); }
.dot.failed   { background: var(--red); }

/* Résultats quiz */
.results-header {
  background: #fff; padding: 20px; text-align: center;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 12px; justify-content: center;
}
.results-header h1 { font-size: 22px; font-weight: 700; }
.results-content { padding: 24px; max-width: 680px; margin: 0 auto; }
.result-score-circle {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; margin: 0 auto 16px;
  font-weight: 800; border: 6px solid;
}
.result-score-circle.pass { border-color: var(--green); color: var(--green); }
.result-score-circle.fail { border-color: var(--red);   color: var(--red);   }
.result-score-circle.neutral { border-color: var(--blue); color: var(--blue); }
.result-pct   { font-size: 32px; line-height: 1; }
.result-label { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ═══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -100%; top: 0;
    transition: left .25s ease; z-index: 200;
  }
  .sidebar.open { left: 0; }
  .sidebar-close { display: block; }
  .btn-hamburger { display: block; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row   { grid-template-columns: 1fr; }
  .modal      { margin: 10px; max-height: 95vh; }
  .section    { padding: 16px 12px; }
  .topbar     { padding: 0 12px; }
  .quiz-main  { padding: 16px 12px; }
  .question-card { padding: 20px 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 28px 20px; }
}
