/* JB4WOOD Academy — layout & composants */

/* ── Structure générale ── */
#app { min-height: 100vh; display: flex; }

/* La sidebar reste toujours sur fond vert foncé (couleur de marque, pas de token thème) */
.sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--vert-fonce);
  color: var(--beton-clair);
  display: flex; flex-direction: column;
  padding: 18px 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  font-family: var(--titre); font-size: 1.25rem;
  color: #fff; padding: 6px 22px 18px; display: flex; align-items: center; gap: 10px;
}
.sidebar .brand small { display:block; font-family: var(--corps); font-weight: 400; font-size:.7rem; color: var(--or-clair); letter-spacing:.5px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.sidebar nav a {
  color: var(--beton-clair); padding: 11px 14px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 11px; font-size: .95rem; font-weight: 500;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: rgba(170,137,102,.16); color: #fff; border-left-color: var(--or); }
.sidebar nav a .badge {
  margin-left: auto; background: var(--or); color: var(--vert-fonce);
  font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
}
.sidebar .spacer { flex: 1; }
.sidebar .user-box { padding: 14px 22px 4px; font-size: .82rem; color: var(--bord); border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .user-box b { color: #fff; display: block; font-size: .9rem; }
.sidebar .user-box button { background: none; color: var(--or-clair); padding: 6px 0; font-size: .82rem; }

/* ── Bouton bascule thème ── */
.theme-toggle {
  background: none; border: none;
  color: var(--or-clair); font-size: .82rem;
  padding: 6px 0; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  width: 100%;
}
.theme-toggle:hover { color: #fff; }

.main { flex: 1; min-width: 0; padding: 30px 38px 60px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ── En-têtes ── */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 1.9rem; margin: 0 0 4px; color: var(--vert); }
.page-head .sub { color: var(--texte-soft); font-size: .98rem; }
.crumb { font-size: .85rem; color: var(--texte-soft); margin-bottom: 10px; }
.crumb a { color: var(--or); }

/* ── Cartes / tuiles ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--ombre-sm);
  padding: 20px; transition: transform .15s, box-shadow .15s; border: 1px solid rgba(0,0,0,.04);
}
[data-theme="dark"] .card { border-color: var(--bord); }
.card.clickable:hover { transform: translateY(-3px); box-shadow: var(--ombre); cursor: pointer; }
.card .icon { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.card h3 { margin: 0 0 6px; font-size: 1.12rem; color: var(--vert); }
.card p { margin: 0; color: var(--texte-soft); font-size: .9rem; }
.card .meta { margin-top: 12px; display: flex; gap: 10px; align-items: center; font-size: .82rem; color: var(--texte-soft); }
.card .due-pill { background: var(--or); color: var(--vert-fonce); font-weight: 700; padding: 2px 10px; border-radius: 999px; font-size: .78rem; }
.tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 6px; background: var(--bg-inset); color: var(--texte-soft); }
.tag.geo { background: #d9ece1; color: var(--vert); }
.tag.compta { background: #efe3cd; color: #8a6d2f; }
.tag.formation { background: #e2e0ec; color: #524a7a; }
[data-theme="dark"] .tag.geo    { background: #1a3829; color: #7ecfa2; }
[data-theme="dark"] .tag.compta { background: #352810; color: var(--or-clair); }
[data-theme="dark"] .tag.formation { background: #2a2840; color: #bbb8e8; }

/* ── Boutons ── */
.btn { background: var(--vert); color: #fff; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: .95rem; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--vert-clair); }
.btn.or { background: var(--or); color: var(--vert-fonce); }
.btn.or:hover { background: var(--or-clair); }
.btn.ghost { background: transparent; color: var(--vert); border: 1.5px solid var(--vert); }
.btn.ghost:hover { background: var(--vert); color: #fff; }
.btn.lg { padding: 14px 28px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: var(--erreur); color: #fff; }

/* ── Login ── */
.login-overlay {
  position: fixed; inset: 0; background: var(--vert-fonce);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.login-card { background: var(--bg-elevated); border-radius: var(--radius); padding: 36px; width: 100%; max-width: 380px; box-shadow: var(--ombre); }
.login-card h1 { color: var(--vert); margin: 0 0 4px; font-size: 1.6rem; }
.login-card .sub { color: var(--texte-soft); margin-bottom: 22px; font-size: .9rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--texte-soft); margin-bottom: 5px; font-weight: 600; }
.field input { width: 100%; padding: 11px 13px; border: 1.5px solid var(--bord); border-radius: var(--radius-sm); font-size: 1rem; font-family: var(--corps); background: var(--bg-inset); color: var(--texte); }
.field input:focus { outline: none; border-color: var(--or); }
.login-card .btn { width: 100%; justify-content: center; }
.login-error { color: var(--erreur); font-size: .85rem; margin: 8px 0; min-height: 18px; }
.login-toggle { text-align: center; margin-top: 16px; font-size: .85rem; }
.login-toggle a { cursor: pointer; }

/* ── Révision ── */
.review-wrap { max-width: 640px; margin: 0 auto; }
.review-progress { height: 6px; background: var(--bg-inset); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.review-progress span { display: block; height: 100%; background: var(--or); transition: width .3s; }
.qcard { background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--ombre); padding: 32px; text-align: center; }
.qcard .prompt { font-size: 1.3rem; color: var(--vert); margin-bottom: 24px; font-weight: 600; }
.choices { display: grid; gap: 12px; }
.choice { padding: 15px 18px; border: 2px solid var(--bord); border-radius: var(--radius-sm); background: var(--bg-elevated); font-size: 1.02rem; text-align: left; transition: all .12s; color: var(--texte); }
.choice:hover { border-color: var(--or); }
.choice.correct { border-color: var(--ok); background: #eafaf0; color: #14432c; }
.choice.wrong { border-color: var(--erreur); background: #fdecea; color: #6b1212; }
[data-theme="dark"] .choice.correct { background: #112b1c; color: #7ecfa2; }
[data-theme="dark"] .choice.wrong   { background: #2b1010; color: #f09090; }
.choice:disabled { cursor: default; }
.flash-back { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--bord); color: var(--texte); font-size: 1.05rem; }
.grade-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 22px; }
.grade-row button { padding: 12px 6px; border-radius: var(--radius-sm); font-weight: 600; font-size: .86rem; color: #fff; }
.g-again { background: #c0392b; } .g-hard { background: #d98c1f; } .g-good { background: var(--vert); } .g-easy { background: var(--vert-clair); }
.review-done { text-align: center; padding: 50px 20px; }
.review-done .big { font-size: 3rem; }

/* ── Géo / carte ── */
.geo-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.geo-toolbar .modes { display: flex; gap: 6px; flex-wrap: wrap; }
.geo-toolbar .modes button { padding: 7px 13px; border-radius: 999px; background: var(--bg-elevated); border: 1.5px solid var(--bord); font-size: .85rem; font-weight: 600; color: var(--texte-soft); }
.geo-toolbar .modes button.active { background: var(--vert); color: #fff; border-color: var(--vert); }
.geo-toolbar select { padding: 8px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--bord); font-family: var(--corps); font-size: .9rem; background: var(--bg-elevated); color: var(--texte); }
#map { height: 62vh; min-height: 380px; border-radius: var(--radius); box-shadow: var(--ombre-sm); z-index: 1; }
.geo-question { background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--ombre-sm); padding: 16px 20px; margin-bottom: 12px; display: flex; align-items: center; gap: 14px; }
.geo-question .q { font-size: 1.15rem; font-weight: 600; color: var(--vert); flex: 1; }
.geo-question .fb { font-weight: 700; }
.geo-question .fb.ok { color: var(--ok); } .geo-question .fb.no { color: var(--erreur); }
.geo-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.geo-choices button { padding: 9px 16px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 2px solid var(--bord); font-weight: 600; color: var(--texte); }
.geo-choices button.correct { border-color: var(--ok); background: #eafaf0; color: #14432c; }
.geo-choices button.wrong { border-color: var(--erreur); background: #fdecea; color: #6b1212; }
[data-theme="dark"] .geo-choices button.correct { background: #112b1c; color: #7ecfa2; }
[data-theme="dark"] .geo-choices button.wrong   { background: #2b1010; color: #f09090; }
.banner { background: var(--bg-elevated); border: 1px solid var(--or-clair); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }
.banner .btn { padding: 7px 14px; font-size: .85rem; }

/* ── Leçon / markdown ── */
.lesson { background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--ombre-sm); padding: 30px 38px; line-height: 1.7; color: var(--texte); }
.lesson h1, .lesson h2, .lesson h3 { color: var(--vert); }
.lesson h2 { border-bottom: 2px solid var(--bg-inset); padding-bottom: 6px; margin-top: 28px; }
.lesson code { background: var(--bg-inset); padding: 2px 6px; border-radius: 4px; font-size: .92em; color: var(--texte); }
.lesson pre { background: var(--vert-fonce); color: #eafaf0; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; }
.lesson table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.lesson th, .lesson td { border: 1px solid var(--bord); padding: 8px 12px; text-align: left; }
.lesson th { background: var(--bg-inset); color: var(--texte); }
.lesson blockquote { border-left: 4px solid var(--or); margin: 16px 0; padding: 6px 18px; background: var(--bg-inset); color: var(--texte-soft); }
.lesson img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 4px 0 22px; box-shadow: var(--ombre-sm); }
.lesson img.banner, .lesson p:first-child img { margin-top: 0; }

/* ── Tables admin ── */
table.data { width: 100%; border-collapse: collapse; background: var(--bg-elevated); border-radius: var(--radius); overflow: hidden; box-shadow: var(--ombre-sm); }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--bord); font-size: .92rem; color: var(--texte); }
table.data th { background: var(--vert); color: #fff; font-family: var(--titre); font-size: .82rem; }
table.data tr:last-child td { border-bottom: none; }
table.data .row-actions { display: flex; gap: 6px; }
table.data .row-actions button { padding: 5px 10px; font-size: .8rem; border-radius: 6px; }

/* ── Modale ── */
.modal-bg { position: fixed; inset: 0; background: rgba(18,51,32,.55); display: flex; align-items: center; justify-content: center; z-index: 900; padding: 20px; }
.modal { background: var(--bg-elevated); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 460px; box-shadow: var(--ombre); max-height: 88vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; color: var(--vert); font-size: 1.3rem; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.checks { display: grid; gap: 7px; max-height: 280px; overflow-y: auto; border: 1px solid var(--bord); border-radius: var(--radius-sm); padding: 12px; }
.checks label { display: flex; gap: 9px; align-items: center; font-size: .9rem; cursor: pointer; color: var(--texte); }
.code-reveal { background: var(--vert-fonce); color: var(--or-clair); font-family: monospace; font-size: 1.5rem; letter-spacing: 3px; text-align: center; padding: 18px; border-radius: var(--radius-sm); margin: 14px 0; }

/* ── Stats ── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--bg-elevated); border-radius: var(--radius); padding: 18px; box-shadow: var(--ombre-sm); text-align: center; }
.stat .n { font-size: 2rem; font-family: var(--titre); color: var(--vert); }
.stat .l { font-size: .8rem; color: var(--texte-soft); text-transform: uppercase; letter-spacing: .5px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 10px; background: var(--bg-elevated); border-radius: var(--radius); box-shadow: var(--ombre-sm); }
.bars .bar { flex: 1; background: var(--or-clair); border-radius: 3px 3px 0 0; min-height: 2px; }
.progress-bar { height: 8px; background: var(--bg-inset); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress-bar span { display: block; height: 100%; background: var(--ok); }

/* ── Protection contenu (dissuasion capture, sans filigrane) ── */
.screenshot-guard #main { -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-touch-callout: none; }
.screenshot-guard #main img { -webkit-user-drag: none; user-drag: none; }
/* floutage instantané quand l'app passe en arrière-plan (aperçu sélecteur d'apps) */
.screenshot-guard.app-obscured #main { filter: blur(22px); }
@media print { .screenshot-guard #main { display: none !important; } }

.empty { text-align: center; color: var(--texte-soft); padding: 50px 20px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--vert-fonce); color: #fff; padding: 12px 22px; border-radius: 999px; box-shadow: var(--ombre); z-index: 1100; font-size: .9rem; }
.offline-flag { position: fixed; top: 0; left: 0; right: 0; background: var(--or); color: var(--vert-fonce); text-align: center; padding: 5px; font-size: .82rem; font-weight: 600; z-index: 800; }

/* ── Mobile ── */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s; z-index: 950; width: 80%; max-width: 280px; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 64px 18px 50px; }
  .menu-toggle { display: flex; position: fixed; top: 12px; left: 12px; z-index: 940; background: var(--vert); color: #fff; width: 42px; height: 42px; border-radius: 10px; align-items: center; justify-content: center; font-size: 1.3rem; box-shadow: var(--ombre-sm); }
  .grade-row { grid-template-columns: repeat(2,1fr); }
}
