/* =============================================================
   Mieux Apprendre — Feuille de style
   ============================================================= */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #1e293b;
  --mut: #64748b;
  --line: #e2e8f0;
  --pri: #1d3f77;
  --pri2: #3560ab;
  --gold: #c9a227;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --err: #dc2626;
  --err-bg: #fee2e2;
  --info-bg: #e0e7ff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html {
  background: linear-gradient(160deg, #edf1f9 0%, #f8f4e8 55%, #edf1f9 100%);
  background-attachment: fixed;
}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: transparent;
  color: var(--ink);
  min-height: 100vh;
}
/* Logo « Mieux Apprendre » en filigrane d'arrière-plan (assombri) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(15, 23, 42, .45), rgba(15, 23, 42, .45)),
    url('../logo.png') no-repeat center 12% / min(72vmin, 620px);
  opacity: .18;
  pointer-events: none;
  z-index: -1;
}
a { color: var(--pri); text-decoration: none; }
img { max-width: 100%; }

/* ── Barre supérieure ─────────────────────────────────────── */
.topbar {
  background: linear-gradient(120deg, var(--pri), var(--pri2));
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 8px; background: #fff; object-fit: contain; }
.topbar .who { margin-left: auto; font-size: .88rem; opacity: .95; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .badge-role { background: rgba(255,255,255,.2); padding: 3px 10px; border-radius: 999px; font-size: .75rem; }

/* ── Conteneur ────────────────────────────────────────────── */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.wrap-narrow { max-width: 480px; margin: 0 auto; padding: 30px 16px 60px; }

/* ── Cartes ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h2 .fa, .card h2 .fas { color: var(--pri); }
.muted { color: var(--mut); font-size: .88rem; }

/* ── Grille de statistiques ───────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 1.8rem; font-weight: 800; color: var(--pri); }
.stat .lbl { font-size: .8rem; color: var(--mut); margin-top: 4px; }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 10px; padding: 10px 18px;
  font-size: .92rem; font-weight: 600; cursor: pointer;
  background: var(--pri); color: #fff; transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn-ghost { background: #eef2ff; color: var(--pri); }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-err { background: var(--err); }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Formulaires ──────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(29, 63, 119, .35); border-color: var(--pri);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Tableaux ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.tbl th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--mut); }
table.tbl tr:hover td { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-info { background: var(--info-bg); color: var(--pri); }

/* ── Onglets (admin) ──────────────────────────────────────── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.tabs button.active { background: var(--pri); color: #fff; border-color: var(--pri); }
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ── QR ───────────────────────────────────────────────────── */
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 18px; background: #fff; border: 2px dashed var(--pri); border-radius: var(--radius);
}
.qr-box canvas, .qr-box img { border-radius: 8px; }
#qr-reader { width: 100%; max-width: 420px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; }
#qr-reader video { border-radius: var(--radius); }

/* ── Mini barres (statistiques) ───────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bars .bar .col {
  width: 100%; max-width: 46px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--pri2), var(--pri));
  min-height: 3px; transition: height .3s;
}
.bars .bar .cap { font-size: .68rem; color: var(--mut); text-align: center; white-space: nowrap; }
.bars .bar .val { font-size: .72rem; font-weight: 700; color: var(--pri); }

/* ── Page d'accueil ───────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--pri), var(--pri2));
  color: #fff; border-radius: 20px; padding: 44px 30px; text-align: center;
  box-shadow: var(--shadow); margin-bottom: 26px;
}
.hero img { width: 96px; height: 96px; border-radius: 50%; background: #fff; padding: 4px; object-fit: contain; margin-bottom: 14px; box-shadow: 0 0 0 3px var(--gold); }
.hero h1 { font-size: 1.9rem; margin-bottom: 8px; }
.hero p { opacity: .92; max-width: 560px; margin: 0 auto 20px; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.panel-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 20px; box-shadow: var(--shadow); text-align: center; transition: transform .15s;
}
.panel-card:hover { transform: translateY(-3px); }
.panel-card .ic {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #fff;
}
.ic-tutor { background: linear-gradient(135deg, #1d3f77, #3560ab); }
.ic-parent { background: linear-gradient(135deg, #16a34a, #22c55e); }
.ic-admin { background: linear-gradient(135deg, #d97706, #f59e0b); }
.panel-card h3 { margin-bottom: 8px; font-size: 1.02rem; }
.panel-card p { font-size: .86rem; color: var(--mut); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: .9rem; opacity: 0; transition: all .3s; z-index: 999; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }
.toast-warn { background: var(--warn); }

/* ── Auth ─────────────────────────────────────────────────── */
.auth-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; border: 1px solid var(--line); }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo img { width: 88px; height: 88px; border-radius: 50%; object-fit: contain; background: #fff; box-shadow: 0 0 0 3px var(--gold); }
.auth-logo h1 { font-size: 1.35rem; margin-top: 8px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: .88rem; margin-bottom: 14px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-err { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }

/* ── En-tête de page (panels) ─────────────────────────────── */
.page-head { margin: 6px 0 22px; }
.page-head h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
.page-head h1 .fas { color: var(--pri); }
.page-head p { color: var(--mut); font-size: .9rem; margin-top: 4px; }

/* ── Numérotation des sections ────────────────────────────── */
.card h2 .step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--pri); color: #fff; font-size: .8rem; font-weight: 800;
}

/* ── Aperçu téléphone (accueil) ───────────────────────────── */
.hero-split { display: flex; align-items: center; gap: 36px; flex-wrap: wrap; text-align: left; }
.hero-split .hero-text { flex: 1; min-width: 280px; }
.hero-split .hero-text h1 { margin-top: 6px; }
.hero-split .hero-text p { margin: 0 0 20px; }
.phone {
  width: 240px; flex-shrink: 0; margin: 0 auto;
  border: 9px solid #0f172a; border-radius: 38px; background: #f8fafc;
  box-shadow: 0 24px 50px rgba(0, 0, 0, .35); overflow: hidden;
}
.phone-notch { width: 110px; height: 22px; background: #0f172a; border-radius: 0 0 14px 14px; margin: 0 auto; }
.phone-screen { padding: 14px 12px 18px; }
.ps-brand { display: flex; align-items: center; gap: 7px; font-size: .72rem; font-weight: 800; color: var(--pri); margin-bottom: 12px; }
.ps-brand img { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; }
.ps-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.ps-stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.ps-stat b { display: block; font-size: 1.05rem; color: var(--pri); }
.ps-stat span { font-size: .58rem; color: var(--mut); }
.ps-qr { background: #fff; border: 2px dashed var(--pri); border-radius: 12px; padding: 10px; display: flex; align-items: center; justify-content: center; }
.ps-qr .fas { font-size: 3.2rem; color: var(--pri); }
.ps-bars { display: flex; align-items: flex-end; gap: 5px; height: 52px; margin-top: 10px; }
.ps-bars i { flex: 1; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--pri2), var(--pri)); }
.ps-label { font-size: .6rem; color: var(--mut); text-align: center; margin-top: 6px; }

/* ── QR en attente d'attribution ──────────────────────────── */
.qr-wait {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 26px 18px; background: #f8fafc; border: 2px dashed var(--line);
  border-radius: var(--radius); text-align: center;
}
.qr-wait .fas { font-size: 2.4rem; color: var(--mut); }
.qr-wait strong { font-size: .98rem; }
