/* =========================================================
   BOLTY — Design System
   Palette : Vert forêt profond + Ambre + Blanc cassé
   Typo : Syne (display) + DM Sans (body)
   ========================================================= */

/* ─── VARIABLES ─────────────────────────────────────────── */

/* ─── ROOT INCHANGE ──────────────────────────────────────── */
:root {
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --radius-xl:      28px;
  --radius-full:    999px;
  --sidebar-w:      260px;
  --topbar-h:       68px;
  --transition:     .2s cubic-bezier(.4,0,.2,1);
  --font-display:   'Poppins', sans-serif;
  --font-body:      'DM Sans', sans-serif;

  /* Matières */
  --maths:   #4361EE;
  --fr:      #7209B7;
  --hist:    #E07A5F;
  --geo:     #3D405B;
  --svt:     #2D9B6B;
  --phy:     #F72585;
  --ang:     #4CC9F0;

  /* Niveaux */
  --critique:  #FF3B30;
  --faible:    #FF9500;
  --moyen:     #FFD60A;
  --bon:       #30D158;
  --excellent: #32ADE6;
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.sidebar-logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.logo-img {
  height: 45px;
  width: auto;
  flex-shrink: 0;
}

.logo-TXT {
  height: 35px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.65);
  font-size: 14.5px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  transform: translateX(2px);
}
.nav-item.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  animation: pulse 2s infinite;
}

.navauth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0px;
  margin-bottom: 54px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  isolation: isolate; /* 👈 magie */
  transition: all .2s ease;
  
}
.navauth-back:hover {
  background: rgba(255,255,255,.18);
  transform: translateY(-1px);
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.sidebar-tree {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,.15);
}
.tree-visual { font-size: 32px; animation: sway 4s ease-in-out infinite; }
@keyframes sway {
  0%,100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
.tree-info { display: flex; flex-direction: column; }
.tree-level { font-size: 12px; color: rgba(255,255,255,.5); font-weight: 500; }
.tree-noisettes { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--accent); font-weight: 700; }
.tree-noisettes .noisette-icon { width: 16px; height: 16px; }

/* ─── MAIN WRAPPER ───────────────────────────────────────── */
.main-wrapper {
  margin-left: calc(var(--sidebar-w) + 20px);
  margin-right: 16px; /* ← ajouter cette ligne */
  padding-bottom: 40px; /* ← ajouter */
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 12px; z-index: 50;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(40px) saturate(180%) brightness(1.1);
  -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(1.1);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  margin: 12px 16px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.topbar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}
.topbar-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: all .3s;
}

.topbar-center { flex: 1; max-width: 380px; }
.topbar-search {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  transition: all var(--transition);
}
.topbar-search:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(82,183,136,.15);
}
.search-icon { font-size: 14px; }
.search-input {
  border: none; background: none; outline: none;
  font-size: 14px; color: var(--text);
  width: 100%;
}
.search-input::placeholder { color: var(--text-muted); }

.topbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
}

.topbar-streak, .topbar-noisettes {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: default;
}
.streak-fire { font-size: 16px; }
.streak-num { color: #E74C3C; }
.noisettes-num { color: var(--accent-dark); }
.topbar-noisettes .noisette-icon { width: 18px; height: 18px; }
.topbar-streak .streak-icon { width: 18px; height: 18px; }

.topbar-score {
  cursor: default;
}
.score-ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: conic-gradient(var(--primary-light) calc(var(--pct) * 1%), var(--bg-alt) 0);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 6px;
  background: var(--surface);
  border-radius: 50%;
}
.score-ring span {
  position: relative;
  font-size: 10px;
  font-weight: 800;
  color: var(--primary);
  z-index: 1;
}

.topbar-user { position: relative; }
.user-avatar {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary);
  border-radius: var(--radius-full);
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.user-avatar:hover { background: var(--primary-mid); }
.avatar-emoji {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.avatar-name { font-size: 13px; font-weight: 600; color: #fff; max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
.avatar-chevron { font-size: 10px; color: rgba(255,255,255,.7); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  overflow: hidden;
  display: none;
  animation: dropIn .2s ease;
  z-index: 200;
}
.user-dropdown.open { display: block; }
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-header {
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.dropdown-header strong { font-size: 14px; font-weight: 700; }
.dropdown-header small { font-size: 11px; color: var(--text-muted); }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  font-size: 14px; color: var(--text);
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.logout { color: #E74C3C; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── PAGE CONTENT ───────────────────────────────────────── */
.page-content {
  padding: 20px 32px 30px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  margin-bottom: 32px;
  animation: fadeUp .5s ease both;
}
.page-title {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.2;
}
.page-subtitle { font-size: 15px; color: var(--text-muted); margin-top: 6px; }

/* ─── GRID LAYOUTS ───────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  padding: 24px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-2); }
.card.elevated { box-shadow: var(--shadow-md); }
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}
.card-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.card .tree-img,
[style*="sway"] img {
    width: 80px;
    height: 80px;
}

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  padding: 22px 20px;
  display: flex; flex-direction: column; gap: 6px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { font-size: 28px; margin-bottom: 4px; }
.icon-stats { width: 28px; height: 28px; }
.stat-value {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 800;
  color: var(--stat-color, var(--primary));
  line-height: 1;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-trend { font-size: 12px; color: var(--bon); font-weight: 600; margin-top: auto; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 14.5px; font-weight: 700;
  transition: all var(--transition);
  cursor: pointer; border: none;
  font-family: var(--font-body);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(27,67,50,.3);
}
.btn-primary:hover { background: var(--primary-mid); box-shadow: 0 6px 20px rgba(27,67,50,.4); transform: translateY(-1px); }
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(244,162,97,.3);
}
.btn-accent:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-ghost:hover { background: var(--primary-pale); }
.btn-danger {
  background: #FEE2E2; color: #E74C3C;
  border: 2px solid #FECACA;
}
.btn-danger:hover { background: #FECACA; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 16px 36px; font-size: 16px; }
.btn-icon { padding: 10px 14px; gap: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-full { width: 100%; justify-content: center; }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-easy    { background: rgba(48,209,88,.15); color: #1A8C3A; }
.badge-medium  { background: rgba(255,213,10,.15); color: #A37600; }
.badge-hard    { background: rgba(255,59,48,.15);  color: #C0392B; }
.badge-premium { background: rgba(244,162,97,.2);  color: #A0522D; }
.badge-free    { background: var(--primary-pale);  color: var(--primary-mid); }

/* ─── PROGRESS BAR ───────────────────────────────────────── */
.progress-track {
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  height: 8px;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.progress-sm .progress-track { height: 5px; }
.progress-lg .progress-track { height: 12px; }

/* ─── SECTION HEADER ─────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 14px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  color: var(--text);
}
.section-action {
  font-size: 13px; color: var(--primary-mid); font-weight: 600;
  transition: color var(--transition);
}
.section-action:hover { color: var(--primary); }

/* ─── TOPIC CHIPS ────────────────────────────────────────── */
.topic-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
  border: 1.5px solid currentColor;
  opacity: .8;
  transition: all var(--transition);
  cursor: pointer;
}
.topic-chip:hover, .topic-chip.active { opacity: 1; }
.topic-chip.active { box-shadow: 0 0 0 3px rgba(var(--chip-rgb),.2); }

/* ─── KNOWLEDGE LEVEL ────────────────────────────────────── */
.level-bar-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.level-bar-row:last-child { border-bottom: none; }
.level-bar-topic { width: 90px; font-size: 12px; color: var(--text-muted); }
.level-bar-subtopic { flex: 1; font-size: 14px; font-weight: 600; }
.level-bar-track { flex: 1; height: 6px; background: var(--bg-alt); border-radius: 3px; overflow: hidden; }
.level-bar-fill { height: 100%; border-radius: 3px; transition: width 1s ease; }
.level-bar-pct { width: 36px; text-align: right; font-size: 13px; font-weight: 700; }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; text-align: center;
}
.empty-state-icon { font-size: 64px; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
.empty-state-title { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.empty-state-sub { font-size: 15px; color: var(--text-muted); max-width: 320px; line-height: 1.6; }

/* ─── QUIZ QUESTION CARD ─────────────────────────────────── */
.quiz-container { max-width: 720px; margin: 0 auto; }

.quiz-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.quiz-progress-bar-wrap { flex: 1; }
.quiz-progress-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

.quiz-timer {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  position: relative;
  transition: border-color .5s;
}
.quiz-timer.urgent { border-color: var(--critique); color: var(--critique); animation: tickTock .5s infinite alternate; }
@keyframes tickTock { from { transform: scale(1); } to { transform: scale(1.05); } }

.question-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  padding: 32px;
  box-shadow: var(--shadow-md);
  animation: fadeUp .3s ease;
}
.question-topic-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
  margin-bottom: 16px;
}
.question-text {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 28px;
}
.answers-grid { display: flex; flex-direction: column; gap: 10px; }

.answer-btn {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: var(--font-body);
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--primary-light);
  background: var(--primary-pale);
  transform: translateX(4px);
}
.answer-btn:disabled { cursor: default; }
.answer-btn.correct {
  border-color: var(--bon);
  background: rgba(48,209,88,.08);
}
.answer-btn.wrong {
  border-color: var(--critique);
  background: rgba(255,59,48,.08);
}
.answer-letter {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
  transition: all var(--transition);
}
.answer-btn:hover .answer-letter { background: var(--primary-pale); color: var(--primary); }
.answer-btn.correct .answer-letter { background: var(--bon); color: #fff; }
.answer-btn.wrong .answer-letter { background: var(--critique); color: #fff; }
.answer-text { font-size: 15px; font-weight: 500; flex: 1; }

.explanation-card {
  margin-top: 20px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--primary-light);
  padding: 18px 20px;
  animation: fadeUp .3s ease;
}
.explanation-title { font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.explanation-text { font-size: 14px; color: var(--text-2); line-height: 1.7; }
.explanation-next { margin-top: 20px; display: flex; justify-content: flex-end; }

/* ─── SCORE RESULT ───────────────────────────────────────── */
.score-result-card {
  background: var(--primary);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.score-result-card::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle at 60% 40%, rgba(255,255,255,.08) 0%, transparent 50%);
}
.score-big {
  font-family: var(--font-display);
  font-size: 80px; font-weight: 900;
  line-height: 1;
  position: relative;
}
.score-mention {
  font-size: 22px; font-weight: 700;
  color: var(--accent);
  margin-top: 8px;
  position: relative;
}
.noisettes-earned {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-full);
  padding: 10px 24px;
  margin-top: 16px;
  font-size: 18px; font-weight: 800;
  position: relative;
}

/* ─── FLASHCARD ──────────────────────────────────────────── */
.flashcard-item {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}
.flashcard-item:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.flashcard-item.open { border-color: var(--primary-light); box-shadow: var(--shadow-md); }

.flashcard-header {
  display: flex; align-items: center;
  padding: 18px 22px; gap: 12px;
}
.flashcard-meta { flex: 1; }
.flashcard-title { font-size: 15px; font-weight: 700; color: var(--text); }
.flashcard-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.flashcard-badges { display: flex; gap: 6px; margin-top: 6px; }
.flashcard-chevron { font-size: 12px; color: var(--text-muted); transition: transform .3s; }
.flashcard-item.open .flashcard-chevron { transform: rotate(180deg); }

.flashcard-body {
  padding: 0 22px 22px;
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  animation: fadeUp .2s ease;
}
.flashcard-item.open .flashcard-body { display: block; }
.flashcard-content {
  font-size: 14.5px; line-height: 1.8;
  color: var(--text-2);
  white-space: pre-line;
}
.flashcard-content strong { font-weight: 700; color: var(--primary); }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.form-control {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px; color: var(--text);
  font-family: var(--font-body);
  transition: all var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(82,183,136,.15);
}
.form-control.error { border-color: var(--critique); }
.form-error { font-size: 12px; color: var(--critique); margin-top: 6px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A9A7A' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

/* ─── AUTH PAGES ─────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-visual {
  background: var(--primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px;
  position: relative; overflow: hidden;
}
.auth-visual::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.04' fill-rule='evenodd'/%3E%3C/svg%3E");
}
.auth-visual-content { position: relative; text-align: center; color: #fff; }
.auth-mascot { font-size: 80px; animation: float 4s ease-in-out infinite; }
.auth-brand-name { font-family: var(--font-display); font-size: 40px; font-weight: 900; margin: 16px 0 8px; }
.auth-brand-tagline { font-size: 16px; color: rgba(255,255,255,.7); line-height: 1.6; }
.auth-features { margin-top: 36px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-feature { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255,255,255,.85); }
.auth-feature-icon { font-size: 20px; }

.auth-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
}
.auth-form-wrap { width: 100%; max-width: 420px; }
.auth-form-title { font-family: var(--font-display); font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.auth-form-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.auth-divider { text-align: center; color: var(--text-muted); font-size: 13px; margin: 20px 0; position: relative; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { background: var(--bg); padding: 0 12px; position: relative; }
.auth-switch { text-align: center; margin-top: 24px; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--primary); font-weight: 600; }

.dots::after {
  content: '';
  animation: dots 1.2s steps(3, end) infinite;
}

@keyframes dots {
  0%   { content: ''; }
  33%  { content: '.'; }
  66%  { content: '..'; }
  100% { content: '...'; }
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────── */
#toast-container {
  position: fixed; top: 80px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight .3s ease, fadeOut .3s ease 3.5s forwards;
  max-width: 320px;
  min-width: 220px;
}
.toast.success { background: var(--bon); }
.toast.error { background: var(--critique); }
.toast.warning { background: var(--accent-dark); }
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* ─── LOADING SPINNER ────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; z-index: 9000;
}

/* ─── ANIMATIONS ─────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}

.animate-up { animation: fadeUp .5s ease both; }
.animate-up-1 { animation: fadeUp .5s .1s ease both; }
.animate-up-2 { animation: fadeUp .5s .2s ease both; }
.animate-up-3 { animation: fadeUp .5s .3s ease both; }
.animate-up-4 { animation: fadeUp .5s .4s ease both; }

/* =========================================================
   BOLTY — Responsive System (Refonte complète)
   Breakpoints :
     xs  : < 480px   (petits mobiles)
     sm  : < 640px   (mobiles)
     md  : < 768px   (tablettes portrait)
     lg  : < 1024px  (tablettes paysage / petits laptops)
     xl  : < 1280px  (laptops)
     2xl : ≥ 1280px  (desktop)
   ========================================================= */

/* ─── BASE RESPONSIVE VARS ───────────────────────────────── */
:root {
  --sidebar-w: 260px;
  --topbar-h: 68px;
  --content-px: 28px;
  --content-py: 24px;
}

/* ─── LARGE DESKTOP (≥ 1280px) ───────────────────────────── */
@media (min-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .main-wrapper { margin-right: 32px; }
  .topbar { margin: 16px 40px 0; }
}

/* ─── LAPTOP / TABLETTE PAYSAGE (< 1280px) ───────────────── */
@media (max-width: 1279px) {
  :root { --sidebar-w: 240px; }

  .page-content { padding: 28px 56px 44px 44px; }
  .main-wrapper { margin-right: 24px; }
  .topbar { margin: 14px 32px 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .page-title { font-size: 28px; }
  .stat-value { font-size: 28px; }
}

/* ─── TABLETTE PAYSAGE (< 1024px) ────────────────────────── */
@media (max-width: 1023px) {
  :root { --sidebar-w: 220px; }

  .page-content { padding: 24px 40px 40px 36px; }
  .main-wrapper { margin-right: 20px; }
  .topbar { margin: 12px 28px 0; padding: 0 28px; gap: 12px; }
  .topbar-center { max-width: 280px; }
  .topbar-streak,
  .topbar-noisettes { padding: 5px 10px; font-size: 12px; }

  /* Grids */
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Cards */
  .card { padding: 22px 20px; }
  .stat-card { padding: 20px 18px; }
  .stat-value { font-size: 26px; }

  /* Quiz */
  .quiz-container { max-width: 100%; }
  .question-text { font-size: 19px; }
}

/* ─── TABLETTE PORTRAIT (< 768px) ────────────────────────── */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 260px;
    --topbar-h: 60px;
  }

  /* ── BODY ── */
  body { overflow-x: hidden; }

  /* ── SIDEBAR : slide-in depuis la gauche ── */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    box-shadow: none;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,.18);
  }

  /* Overlay derrière la sidebar */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    backdrop-filter: blur(2px);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .sidebar.open + .sidebar-overlay,
  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
  }

  /* ── MAIN WRAPPER ── */
  .main-wrapper {
    margin-left: 0 !important;
    margin-right: 0;
    padding-right: 0;
    width: 100%;
  }

  /* ── TOPBAR : belles marges latérales ── */
  .topbar {
    margin: 12px 28px 0;
    padding: 0 28px;
    gap: 10px;
    height: var(--topbar-h);
    border-radius: 16px;
  }
  .topbar-toggle { display: flex; }
  .topbar-center { display: none; }

  /* Masquer certains éléments topbar sur mobile */
  .score-ring { display: none; }
  .topbar-streak span:not(.streak-num):not(.streak-fire) { display: none; }
  .topbar-noisettes span:not(.noisettes-num) { display: none; }

  /* ── PAGE CONTENT : marges généreuses ── */
  .page-content {
    padding: 24px 36px 88px;
  }

  /* ── PAGE HEADER ── */
  .page-title { font-size: 24px; }
  .page-subtitle { font-size: 14px; }
  .page-header { margin-bottom: 20px; }

  /* ── GRIDS → 1 colonne ── */
  .grid-2,
  .grid-3 { grid-template-columns: 1fr; gap: 14px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

  /* ── CARDS ── */
  .card { padding: 20px 18px; border-radius: 16px; }
  .stat-card { padding: 18px 16px; }
  .stat-value { font-size: 26px; }
  .stat-icon, .icon-stats { font-size: 24px; width: 24px; height: 24px; }

  /* ── AUTH PAGES ── */
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-form-side { padding: 40px 36px; }
  .auth-form-wrap { max-width: 100%; }

  /* ── QUIZ ── */
  .quiz-container { max-width: 100%; padding: 0; }
  .quiz-header { gap: 12px; }
  .question-card { padding: 24px 20px; }
  .question-text { font-size: 17px; margin-bottom: 20px; }
  .answer-btn { padding: 14px 16px; gap: 12px; font-size: 14px; }
  .answer-letter { width: 30px; height: 30px; font-size: 13px; }
  .quiz-timer { width: 48px; height: 48px; font-size: 16px; }

  /* ── SCORE RESULT ── */
  .score-result-card { padding: 32px 28px; }
  .score-big { font-size: 64px; }
  .score-mention { font-size: 18px; }

  /* ── BUTTONS ── */
  .btn-lg { padding: 14px 28px; font-size: 15px; }
  .btn-full-mobile { width: 100%; justify-content: center; }

  /* ── SECTION HEADER ── */
  .section-header { flex-wrap: wrap; gap: 8px; }

  /* ── FLASHCARD ── */
  .flashcard-header { padding: 16px 18px; }
  .flashcard-body { padding: 0 18px 18px; padding-top: 16px; }

  /* ── TOAST ── */
  #toast-container {
    right: 28px;
    left: 28px;
    top: 76px;
  }
  .toast { min-width: 0; width: 100%; }

  /* ── LEVEL BARS ── */
  .level-bar-topic { width: 70px; }

  /* ── USER DROPDOWN ── */
  .user-dropdown { right: -8px; min-width: 200px; }
}

/* ─── PETITS MOBILES (< 480px) ───────────────────────────── */
@media (max-width: 479px) {
  /* ── TOPBAR compact mais avec de l'air ── */
  .topbar { padding: 0 20px; gap: 8px; margin: 10px 20px 0; }
  .user-avatar { padding: 5px 10px 5px 6px; }
  .avatar-name { display: none; }
  .avatar-chevron { display: none; }
  .topbar-streak,
  .topbar-noisettes { padding: 5px 9px; }

  /* ── PAGE : marges confortables ── */
  .page-content { padding: 20px 28px 88px; }
  .page-title { font-size: 22px; letter-spacing: -.5px; }

  /* ── GRIDS ── */
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-auto { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* ── STAT CARDS ── */
  .stat-card { padding: 16px 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 10px; }

  /* ── CARDS ── */
  .card { padding: 18px 16px; border-radius: 14px; }
  .card-title { font-size: 15px; }

  /* ── QUIZ ── */
  .question-card { padding: 20px 18px; }
  .question-text { font-size: 16px; }
  .answer-btn { padding: 13px 14px; font-size: 13px; }
  .answer-letter { width: 28px; height: 28px; font-size: 12px; border-radius: 6px; }
  .quiz-timer { width: 42px; height: 42px; font-size: 14px; border-width: 2px; }
  .explanation-card { padding: 16px 18px; }
  .explanation-text { font-size: 13px; }

  /* ── SCORE RESULT ── */
  .score-result-card { padding: 28px 22px; }
  .score-big { font-size: 52px; }
  .noisettes-earned { font-size: 15px; padding: 8px 18px; }

  /* ── BUTTONS ── */
  .btn { padding: 11px 20px; font-size: 14px; }
  .btn-lg { padding: 13px 24px; font-size: 14px; }
  .btn-sm { padding: 7px 13px; font-size: 12px; }

  /* ── BADGES ── */
  .badge { padding: 2px 8px; font-size: 10px; }

  /* ── FORMS ── */
  .form-control { padding: 12px 16px; font-size: 14px; }

  /* ── AUTH ── */
  .auth-form-side { padding: 32px 28px; }
  .auth-form-title { font-size: 24px; }

  /* ── EMPTY STATE ── */
  .empty-state-icon { font-size: 48px; }
  .empty-state-title { font-size: 19px; }
  .empty-state-sub { font-size: 14px; }
  .empty-state { padding: 48px 28px; }

  /* ── FLASHCARD ── */
  .flashcard-header { padding: 14px 16px; gap: 10px; }
  .flashcard-body { padding: 0 16px 16px; padding-top: 14px; }
  .flashcard-title { font-size: 14px; }

  /* ── SECTION ── */
  .section-title { font-size: 16px; }

  /* ── DROPDOWN ── */
  .user-dropdown { min-width: 180px; }
  .dropdown-item { padding: 10px 16px; font-size: 13px; }

  /* ── TOAST ── */
  #toast-container { right: 20px; left: 20px; }
}

/* ─── TRÈS PETITS ÉCRANS (< 360px) ──────────────────────── */
@media (max-width: 359px) {
  .topbar { margin: 8px 14px 0; }
  .page-content { padding: 16px 20px 88px; }
  .page-title { font-size: 20px; }
  .grid-4 { grid-template-columns: 1fr; }
  .grid-auto { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
  .question-text { font-size: 15px; }
  .score-big { font-size: 44px; }
}

/* ─── HOVER : désactivé sur touch ────────────────────────── */
@media (hover: none) {
  .card.clickable:hover { transform: none; box-shadow: none; }
  .nav-item:hover { transform: none; }
  .answer-btn:hover:not(:disabled) { transform: none; }
  .btn-primary:hover,
  .btn-accent:hover { transform: none; }
  .stat-card:hover { transform: none; box-shadow: none; }
}

/* ─── PRINT ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, #toast-container,
  .sidebar-overlay, .topbar-toggle { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }
  body { background: #fff; color: #000; }
  .card, .stat-card, .question-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ─── ACCESSIBILITÉ ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── MODE SOMBRE SYSTÈME ─────────────────────────────────── */
/* Ajouter ici si --bg etc. ont des variantes dark dans :root */