/* ===== Margot Études — charte : indigo/violet, mobile-first, design PRO ===== */
:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --violet: #7C3AED;
  --bg: #F4F5FB;
  --card: #FFFFFF;
  --text: #1E2235;
  --muted: #6B7280;
  --border: #E5E7F0;
  --success: #10B981;
  --error: #EF4444;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 34, 53, .05), 0 8px 24px rgba(30, 34, 53, .06);
  --shadow-lg: 0 12px 40px rgba(30, 34, 53, .12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header / nav ===== */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-wrap {
  max-width: 1080px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; box-shadow: var(--shadow);
}
nav.main {
  display: flex; gap: 4px; overflow-x: auto; flex: 1;
  scrollbar-width: none; -ms-overflow-style: none;
}
nav.main::-webkit-scrollbar { display: none; }
nav.main a {
  color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 10px; white-space: nowrap;
}
nav.main a:hover { color: var(--primary); text-decoration: none; background: #EEF0FB; }
nav.main a.active { color: var(--primary); background: #E8EAFB; }
.user-chip { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ===== Layout ===== */
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

/* ===== Cartes ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ===== Récap des possibilités (page d'accueil) ===== */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.feature-card h3 { display: flex; align-items: center; gap: 10px; font-size: 16.5px; font-weight: 800; margin-bottom: 14px; }
.feature-card .badge {
  margin-left: auto; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  background: #EEF0FB; color: var(--primary-dark); padding: 4px 10px; border-radius: 999px;
}
.feature-card ul { list-style: none; }
.feature-card li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #F1F2F8; font-size: 14px; line-height: 1.45; }
.feature-card li:last-child { border-bottom: 0; }
.feature-card li .ico { font-size: 17px; flex-shrink: 0; }
.feature-card li strong { color: var(--text); }
.feature-card li span.desc { color: var(--muted); }
.feature-card code {
  background: #F1F2F8; border-radius: 6px; padding: 1px 7px; font-size: 12.5px;
  font-family: "SFMono-Regular", Consolas, monospace; color: var(--primary-dark); font-weight: 700;
}
.feature-card .note { margin-top: 14px; font-size: 13px; color: var(--muted); background: #FAFAFE; border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; }

/* ===== Statistiques ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat .num.indigo { color: var(--primary); }
.stat .num.green { color: var(--success); }
.stat .num.violet { color: var(--violet); }

/* ===== Boutons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  color: #fff; font-weight: 700; font-size: 14px;
  border: 0; border-radius: 12px; padding: 11px 18px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79, 70, 229, .4); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: #fff; color: var(--primary); box-shadow: none;
  border: 1.5px solid #D8DBF5;
}
.btn.ghost:hover { background: #F5F6FE; box-shadow: none; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ===== Formulaires ===== */
label.field { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], textarea, select {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit;
  border: 1.5px solid var(--border); border-radius: 12px; background: #FBFBFE;
  transition: border-color .15s, box-shadow .15s; color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.form-group { margin-bottom: 16px; }
.form-card { max-width: 420px; margin: 0 auto; }
.form-card .btn { width: 100%; margin-top: 6px; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #EEF0FB 0%, #F6F1FE 55%, #FDF4FF 100%);
}
.login-card {
  background: #fff; border-radius: 24px; padding: 36px 32px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: 0 10px 26px rgba(79, 70, 229, .35);
}
.login-card h1 { text-align: center; font-size: 22px; font-weight: 800; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 6px 0 24px; }
.alert-error {
  background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C;
  padding: 10px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px;
}
.alert-success {
  background: #ECFDF5; border: 1px solid #A7F3D0; color: #047857;
  padding: 10px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 16px;
}

/* ===== Fiches ===== */
.fiche-block {
  background: #FAFAFE; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; margin-top: 12px;
}
.fiche-block h4 { font-size: 15px; font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); }
.fiche-block p { color: var(--text); font-size: 14.5px; white-space: pre-wrap; }
.meta { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ===== Flashcards ===== */
.flashcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-height: 190px; padding: 28px 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-align: center;
  transition: transform .15s ease, box-shadow .15s ease; user-select: none;
  font-size: 17px; font-weight: 600; position: relative;
}
.flashcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.flashcard .face-q { color: var(--text); }
.flashcard .face-a { color: var(--primary-dark); display: none; }
.flashcard.flipped .face-q { display: none; }
.flashcard.flipped .face-a { display: block; }
.card-badge {
  position: absolute; top: 14px; left: 16px; font-size: 11px; font-weight: 800;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}

/* ===== Quiz ===== */
.quiz-progress { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.quiz-question { font-size: 18px; font-weight: 700; margin-bottom: 18px; line-height: 1.4; }
.quiz-option {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: #FAFAFE; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 13px 16px; font-size: 15px; font-family: inherit; margin-bottom: 10px;
  transition: all .12s ease;
}
.quiz-option:hover { border-color: var(--primary); background: #F0F1FE; }
.quiz-option.correct { border-color: var(--success); background: #ECFDF5; color: #047857; font-weight: 700; }
.quiz-option.wrong { border-color: var(--error); background: #FEF2F2; color: #B91C1C; }
.quiz-option:disabled { cursor: default; opacity: .9; }
.quiz-explain {
  background: #F8FAFC; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 4px 0 14px; display: none;
}
.quiz-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.quiz-actions { margin-top: 20px; text-align: right; }

/* ===== Actu ===== */
.article { display: flex; flex-direction: column; gap: 8px; }
.article .src { font-size: 12px; font-weight: 800; color: var(--violet); text-transform: uppercase; letter-spacing: .05em; }
.article .date { font-size: 12px; color: var(--muted); }
.article .sum { background: #FAFAFE; border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--text); border: 1px solid var(--border); }

/* ===== Historique ===== */
.msg-row { padding: 14px 0; border-bottom: 1px solid var(--border); }
.msg-row:last-child { border-bottom: 0; }
.msg-row .who { font-size: 12.5px; font-weight: 800; margin-bottom: 3px; }
.msg-row .who.user { color: var(--primary); }
.msg-row .who.assistant { color: var(--violet); }
.msg-row .txt { font-size: 14px; color: var(--text); white-space: pre-wrap; }
.msg-row .when { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ===== Chat (messagerie) ===== */
.chat-wrap { display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; height: calc(100vh - 150px); min-height: 420px; }
.chat-box {
  flex: 1; overflow-y: auto; padding: 18px 6px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.bubble {
  max-width: 82%; padding: 11px 15px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
  box-shadow: var(--shadow);
}
.bubble.user {
  align-self: flex-end; background: linear-gradient(135deg, var(--primary), var(--violet));
  color: #fff; border-bottom-right-radius: 5px;
}
.bubble.assistant {
  align-self: flex-start; background: #fff; border: 1px solid var(--border);
  border-bottom-left-radius: 5px; color: var(--text);
}
.bubble .when { display: block; font-size: 10.5px; opacity: .65; margin-top: 4px; font-weight: 600; }
.bubble.typing { color: var(--muted); font-style: italic; }
.chat-input {
  display: flex; gap: 10px; padding: 12px 0 4px; align-items: flex-end;
}
.chat-input input {
  flex: 1; border-radius: 14px; padding: 13px 16px;
}
.chat-input .btn { padding: 13px 20px; border-radius: 14px; flex-shrink: 0; }
.chat-hint { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ===== Divers ===== */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  background: var(--card); border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.empty .big { font-size: 40px; margin-bottom: 10px; }
.chip {
  display: inline-block; background: #EEF0FB; color: var(--primary-dark);
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; margin: 2px 2px 2px 0;
}
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { font-weight: 600; }
footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 28px 16px 40px; }

@media (max-width: 640px) {
  .page-title { font-size: 21px; }
  .brand span.tag { display: none; }
  .login-card { padding: 28px 22px; }
  .flashcard { min-height: 160px; font-size: 15.5px; }
}
