/* ==========================================================================
   STYLE NOTION — Wiki IUT Informatique
   Inspiré de l'ergonomie Notion, Linear et Craft :
   - Mise en page à colonne unique aérée, canvas épuré.
   - Codes couleurs identifiants par promo (BUT1 vert, BUT2 indigo, BUT3 ambre).
   - Header flottant avec flou d'arrière-plan.
   - Spoilers de correction pédagogiques et indices progressifs.
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;

  /* Mode Clair */
  --bg-page: #fbfbfa;
  --bg-surface: #ffffff;
  --bg-hover: #f1f1ef;
  --bg-code: #1e1e24;
  --text-main: #37352f;
  --text-muted: #787774;
  --text-heading: #191919;
  --border: #e9e9e7;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;

  /* Promos */
  --c-but1: #10b981;
  --c-but1-bg: #ecfdf5;
  --c-but2: #6366f1;
  --c-but2-bg: #eef2ff;
  --c-but3: #f59e0b;
  --c-but3-bg: #fffbeb;

  --accent-ok: #10b981;
  --accent-warn: #f59e0b;
  --accent-danger: #ef4444;

  --header-h: 64px;
}

[data-theme="dark"] {
  --bg-page: #121214;
  --bg-surface: #18181b;
  --bg-hover: #27272a;
  --bg-code: #09090b;
  --text-main: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-heading: #fafafa;
  --border: #27272a;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: #1e293b;

  --c-but1: #34d399;
  --c-but1-bg: #064e3b;
  --c-but2: #818cf8;
  --c-but2-bg: #312e81;
  --c-but3: #fbbf24;
  --c-but3-bg: #78350f;

  --accent-ok: #34d399;
  --accent-warn: #fbbf24;
  --accent-danger: #f87171;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* Header Notion */
.header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: rgba(251, 251, 250, 0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem;
}
[data-theme="dark"] .header {
  background: rgba(18, 18, 20, 0.88);
}

.header-left, .header-right {
  display: flex; align-items: center; gap: 1rem;
}

.logo {
  font-weight: 800; font-size: 1.2rem; color: var(--text-heading);
  display: flex; align-items: center; gap: 0.5rem; letter-spacing: -0.02em;
}
.logo-badge {
  font-size: 0.7rem; font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; padding: 0.15rem 0.55rem; border-radius: 999px;
}

.nav-links { display: flex; list-style: none; gap: 0.4rem; }
.nav-links a {
  padding: 0.4rem 0.75rem; border-radius: 8px; color: var(--text-muted);
  font-weight: 600; font-size: 0.9rem; transition: all 0.15s ease;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text-heading); background: var(--bg-hover);
}

/* Recherche */
.search-wrapper { position: relative; width: 260px; }
.search-input {
  width: 100%; padding: 0.45rem 2.2rem 0.45rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-main); font-size: 0.875rem;
}
.search-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; padding: 0.1rem 0.35rem; border: 1px solid var(--border);
  border-radius: 4px; background: var(--bg-hover); color: var(--text-muted);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 28px rgba(0,0,0,0.12);
  list-style: none; max-height: 360px; overflow-y: auto; z-index: 200; padding: 0.4rem;
}
.search-results li a {
  display: flex; flex-direction: column; padding: 0.5rem 0.75rem;
  border-radius: 8px; color: var(--text-main);
}
.search-results li:hover a { background: var(--bg-hover); }
.sr-type { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--primary); }
.sr-title { font-weight: 600; font-size: 0.9rem; }
.sr-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Thème toggle & boutons */
.theme-btn {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 10px; width: 36px; height: 36px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; color: var(--text-main);
}
.theme-btn:hover { background: var(--bg-hover); }
.theme-btn svg { width: 18px; height: 18px; }
[data-theme="light"] .theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* Canvas Principal Notion */
.canvas {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 2.5rem 1.5rem; flex: 1;
}

/* Breadcrumbs */
.breadcrumb { margin-bottom: 1.5rem; }
.breadcrumb ol {
  display: flex; flex-wrap: wrap; list-style: none; gap: 0.4rem;
  font-size: 0.875rem; color: var(--text-muted);
}
.breadcrumb li:not(:last-child)::after {
  content: "›"; margin-left: 0.4rem; color: var(--text-muted);
}
.breadcrumb a:hover { color: var(--text-heading); }

/* Titres & Typographie */
.page-header { margin-bottom: 2.5rem; }
.kicker {
  font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--primary); margin-bottom: 0.35rem;
}
h1 {
  font-size: 2.4rem; color: var(--text-heading); font-weight: 800;
  line-height: 1.2; letter-spacing: -0.03em;
}
.lead {
  font-size: 1.15rem; color: var(--text-muted); margin-top: 0.75rem;
}
h2 {
  font-size: 1.5rem; color: var(--text-heading); margin: 2rem 0 1rem 0;
  font-weight: 700; letter-spacing: -0.02em;
}
p { margin-bottom: 1rem; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; font-size: 0.75rem;
  font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 999px;
}
.badge-ok { background: rgba(16,185,129,0.12); color: var(--accent-ok); }
.badge-warn { background: rgba(245,158,11,0.12); color: var(--accent-warn); }
.badge-res { background: rgba(37,99,235,0.1); color: var(--primary); }
.badge-sae { background: rgba(168,85,247,0.12); color: #9333ea; }
.badge-promo { background: var(--bg-hover); color: var(--text-heading); font-weight: 700; }

.diff { color: #f59e0b; font-size: 0.85rem; letter-spacing: 2px; }
.diff-off { opacity: 0.25; }

/* Callouts Notion */
.callout {
  padding: 1.25rem 1.5rem; border-radius: 12px; margin: 1.5rem 0;
  background: var(--bg-surface); border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.callout-title {
  font-weight: 700; font-size: 0.95rem; margin-bottom: 0.35rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.callout-info { background: rgba(59,130,246,0.05); border-color: rgba(59,130,246,0.2); }
.callout-tip { background: rgba(16,185,129,0.05); border-color: rgba(16,185,129,0.2); }
.callout-warn { background: rgba(245,158,11,0.05); border-color: rgba(245,158,11,0.2); }

/* Blocs de Code */
.code-block {
  margin: 1.25rem 0; border-radius: 12px; overflow: hidden;
  background: var(--bg-code); border: 1px solid var(--border);
}
.code-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 1rem; background: rgba(255,255,255,0.04);
  font-size: 0.75rem; color: #a1a1aa; font-family: var(--font-mono);
}
.code-block pre {
  padding: 1.15rem; overflow-x: auto; font-family: var(--font-mono);
  font-size: 0.9rem; color: #fafafa; line-height: 1.5;
}
.btn-copy {
  background: rgba(255,255,255,0.1); border: none; color: #e4e4e7;
  border-radius: 6px; font-size: 0.75rem; padding: 0.2rem 0.55rem; cursor: pointer;
}
.btn-copy:hover { background: rgba(255,255,255,0.2); }

/* Cartes Notion */
.grid {
  display: grid; gap: 1.25rem; list-style: none; margin: 1.5rem 0 2.5rem 0;
}
.grid-promos { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-ressources { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden; display: flex; flex-direction: column;
}
.card:hover {
  transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  border-color: rgba(37,99,235,0.3);
}
.card-promo-but1 { border-top: 5px solid var(--c-but1); }
.card-promo-but2 { border-top: 5px solid var(--c-but2); }
.card-promo-but3 { border-top: 5px solid var(--c-but3); }

.card-body {
  padding: 1.6rem; display: flex; flex-direction: column; height: 100%;
}
.card-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.card-kicker { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.card-title { font-weight: 800; font-size: 1.3rem; color: var(--text-heading); margin: 0.2rem 0 0.5rem 0; }
.card-desc { font-size: 0.925rem; color: var(--text-muted); margin-bottom: 1rem; }
.card-meta { margin-top: auto; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

/* Indices & Corrections (Wiki) */
.indices-box {
  margin: 1.5rem 0; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem;
}
.indices-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.75rem; }
details.hint {
  margin: 0.5rem 0; background: var(--bg-page); border-radius: 8px;
  border: 1px solid var(--border);
}
details.hint summary {
  padding: 0.65rem 0.9rem; cursor: pointer; font-weight: 600; font-size: 0.9rem;
}
.hint-content { padding: 0.85rem 1rem; border-top: 1px solid var(--border); font-size: 0.925rem; }

details.correction {
  margin: 2rem 0; border-radius: 14px; background: var(--bg-surface);
  border: 2px solid var(--accent-ok); overflow: hidden;
  box-shadow: 0 4px 16px rgba(16,185,129,0.1);
}
details.correction summary {
  padding: 1rem 1.25rem; background: rgba(16,185,129,0.08); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: var(--accent-ok); font-size: 1rem;
}
.correction-content {
  padding: 1.5rem; border-top: 1px solid rgba(16,185,129,0.2);
}

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem; font-size: 0.9rem; font-weight: 600; border-radius: 10px;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg-surface);
  color: var(--text-heading); transition: all 0.15s ease;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn-primary {
  background: var(--text-heading); color: var(--bg-surface); border-color: var(--text-heading);
}
.btn-primary:hover {
  background: var(--text-heading); color: var(--bg-surface); opacity: 0.9;
}
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.825rem; border-radius: 8px; }

/* Forum */
.topic-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.35rem; margin-bottom: 1rem;
  display: flex; gap: 1.25rem; box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}
.topic-stats {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 80px; padding: 0.5rem; border-radius: 10px; background: var(--bg-page);
  font-size: 0.75rem; color: var(--text-muted); gap: 0.35rem;
}
.topic-content { flex: 1; min-width: 0; }
.topic-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.4rem; }
.topic-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* Posts */
.post-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.5rem; margin-bottom: 1.25rem;
  display: flex; gap: 1.25rem;
}
.post-card.is-solution {
  border: 2px solid var(--accent-ok); box-shadow: 0 0 0 1px var(--accent-ok);
}
.post-votes { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.btn-vote {
  background: var(--bg-page); border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 32px; cursor: pointer;
}
.btn-vote.has-voted { background: var(--primary); color: #fff; }
.post-content { flex: 1; min-width: 0; }
.post-author { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; font-size: 0.85rem; color: var(--text-muted); }
.solution-banner {
  font-size: 0.85rem; font-weight: 700; color: var(--accent-ok); margin-bottom: 0.75rem;
}

/* Modale d'authentification */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 440px; padding: 2rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.modal-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; }
.modal-tab {
  background: none; border: none; font-size: 1rem; font-weight: 700;
  color: var(--text-muted); cursor: pointer; padding: 0.25rem 0.5rem;
}
.modal-tab.active { color: var(--text-heading); border-bottom: 2px solid var(--primary); }

.form-group { margin-bottom: 1.15rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 700; margin-bottom: 0.35rem; }
.form-control {
  width: 100%; padding: 0.65rem 0.85rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-page); color: var(--text-main); font-family: inherit; font-size: 0.95rem;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-help { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; display: block; }

/* Alertes & Toasts */
.alert {
  padding: 0.85rem 1.25rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: 0.9rem;
}
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid var(--accent-ok); color: var(--accent-ok); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid var(--accent-warn); color: var(--accent-warn); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid var(--accent-danger); color: var(--accent-danger); }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: #18181b; color: #fff;
  padding: 0.85rem 1.4rem; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-size: 0.9rem; opacity: 0; transform: translateY(10px); transition: all 0.2s ease;
  pointer-events: none; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 0 1rem; }
  .search-wrapper { display: none; }
  .canvas { padding: 1.5rem 1rem; }
}

/* Extensions Notion Style pour l'Éditeur & Tables */
.editor-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.editor-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 650px) {
  .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; }
}

.hint-editor-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-page);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 0.65rem;
}

.hint-num-pill {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.btn-remove-hint {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent-danger);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-weight: bold;
}
.btn-remove-hint:hover { background: rgba(239,68,68,0.1); }

.btn-add-hint {
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  color: var(--primary);
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}
.btn-add-hint:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.table-notion {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-notion th {
  background: var(--bg-hover);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.table-notion td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.table-notion tr:last-child td {
  border-bottom: none;
}

.table-notion tr:hover td {
  background: var(--bg-hover);
}

.badge-but1 { background: rgba(16,185,129,0.12); color: var(--c-but1); border: 1px solid rgba(16,185,129,0.3); }
.badge-but2 { background: rgba(99,102,241,0.12); color: var(--c-but2); border: 1px solid rgba(99,102,241,0.3); }
.badge-but3 { background: rgba(245,158,11,0.12); color: var(--c-but3); border: 1px solid rgba(245,158,11,0.3); }

