/* ═══════════════════════════════════════════════════════════
   ÉCOLAPP — Design System partagé
   Police : Syne (display) + Outfit (corps)
   Thème : Ardoise & Craie — chaleureux, scolaire, moderne
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  /* Couleurs de base */
  --ink:        #1A1D2E;
  --ink-soft:   #2E3248;
  --ink-muted:  #6B7280;
  --chalk:      #F7F5F0;
  --chalk-dark: #EDE9E0;
  --white:      #FFFFFF;
  --border:     rgba(26,29,46,0.10);
  --border-md:  rgba(26,29,46,0.16);

  /* Accent principal */
  --primary:    #4F6EF7;
  --primary-dk: #3B58E8;
  --primary-bg: rgba(79,110,247,0.08);
  --primary-lt: #EEF1FE;

  /* Couleurs modules */
  --rituel:     #F4845F;   /* corail */
  --rituel-bg:  #FEF2EE;
  --synthese:   #6366F1;   /* indigo */
  --synthese-bg:#EEEEFF;
  --aida:       #C9893A;   /* ocre */
  --aida-bg:    #FDF4E7;
  --calcul:     #22A699;   /* teal */
  --calcul-bg:  #E6F7F6;
  --carnet:     #9B5FC0;   /* violet */
  --carnet-bg:  #F4EEFA;

  /* Sémantique */
  --success:    #16A34A;
  --success-bg: #DCFCE7;
  --warning:    #D97706;
  --warning-bg: #FEF3C7;
  --error:      #DC2626;
  --error-bg:   #FEE2E2;

  /* Typo */
  --font-display: 'Syne', sans-serif;
  --font-body:    'Outfit', sans-serif;

  /* Géométrie */
  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow:    0 2px 16px rgba(26,29,46,0.08);
  --shadow-md: 0 6px 32px rgba(26,29,46,0.12);
  --shadow-lg: 0 16px 56px rgba(26,29,46,0.16);

  /* Transitions */
  --ease: cubic-bezier(0.34, 1.06, 0.64, 1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--chalk);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border);
}

.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.topbar-logo .logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  background: var(--chalk);
  border: 1px solid var(--border-md);
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-back {
  font-size: 13px;
  color: var(--ink-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.18s;
}
.topbar-back:hover { color: var(--ink); }

.btn-logout {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-md);
  background: transparent;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.18s;
}
.btn-logout:hover { background: var(--error-bg); color: var(--error); border-color: rgba(220,38,38,0.2); }

/* ── Page layout ────────────────────────────────────────── */
.page-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.page-header {
  margin-bottom: 28px;
}

.page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-title .accent { color: var(--primary); }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--chalk-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}

.tab-btn {
  padding: 8px 20px;
  border-radius: calc(var(--radius) - 4px);
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active {
  background: var(--white);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(26,29,46,0.10);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.28s var(--ease) both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* ── Formulaires ────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: 7px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--chalk);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.field textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.55;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

/* ── Boutons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 12px rgba(79,110,247,0.28);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(79,110,247,0.38);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover { background: var(--chalk); color: var(--ink); }

.btn-full { width: 100%; }

.btn-sm { padding: 7px 14px; font-size: 12px; }

/* Couleurs modules pour boutons */
.btn-rituel   { background: var(--rituel);   color: white; box-shadow: 0 2px 12px rgba(244,132,95,0.28); }
.btn-synthese { background: var(--synthese); color: white; box-shadow: 0 2px 12px rgba(99,102,241,0.28); }
.btn-aida     { background: var(--aida);     color: white; box-shadow: 0 2px 12px rgba(201,137,58,0.28); }
.btn-calcul   { background: var(--calcul);   color: white; box-shadow: 0 2px 12px rgba(34,166,153,0.28); }
.btn-carnet   { background: var(--carnet);   color: white; box-shadow: 0 2px 12px rgba(155,95,192,0.28); }

/* ── Statut / Alerts ────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error   { background: var(--error-bg);   color: var(--error); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert { display: none; }
.alert.visible { display: flex; }

/* ── Historique / Feed ──────────────────────────────────── */
.feed { display: flex; flex-direction: column; gap: 12px; }

.feed-item {
  background: var(--chalk);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
}

.feed-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}

.feed-meta {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
}

.feed-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 99px;
}

.feed-content {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ── Loader ─────────────────────────────────────────────── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--ink-muted);
  font-size: 13px;
  gap: 14px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Vide ───────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-muted);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-text { font-size: 14px; font-weight: 500; }
.empty-sub  { font-size: 12px; margin-top: 4px; }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--ink);
  color: white;
  padding: 12px 22px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.25s;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#toast.success { background: var(--success); }
#toast.error   { background: var(--error); }

/* ── Module cards (dashboard) ───────────────────────────── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.module-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: transform 0.22s var(--ease), box-shadow 0.22s;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.module-card.rituel::before   { background: var(--rituel); }
.module-card.synthese::before { background: var(--synthese); }
.module-card.aida::before     { background: var(--aida); }
.module-card.calcul::before   { background: var(--calcul); }
.module-card.carnet::before   { background: var(--carnet); }

.module-emoji { font-size: 28px; margin-bottom: 12px; display: block; }
.module-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.module-desc { font-size: 12px; color: var(--ink-muted); line-height: 1.45; }

.module-badge {
  position: absolute;
  top: 14px; right: 14px;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* ── Checklist ──────────────────────────────────────────── */
.checklist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--chalk);
  transition: all 0.18s;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.check-row:hover { border-color: var(--primary); }

.check-row.checked {
  background: var(--success-bg);
  border-color: rgba(22,163,74,0.3);
  color: var(--success);
}

.check-box {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border-md);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all 0.18s;
}

.check-row.checked .check-box {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* ── Prof table ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--chalk-dark);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--ink-soft);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--chalk); }
.data-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

/* ── Stat chips ─────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-chip {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: center;
  flex: 1;
  min-width: 80px;
}

.stat-chip-val {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}

.stat-chip-label {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ── PIN modal ──────────────────────────────────────────── */
.pin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(26,29,46,0.55);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pin-overlay.open { display: flex; }

.pin-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s var(--ease) both;
}

.pin-icon  { font-size: 40px; margin-bottom: 10px; }
.pin-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.pin-sub   { font-size: 13px; color: var(--ink-muted); margin-bottom: 24px; }

.pin-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.pin-dot {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-md);
  background: var(--chalk);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.15s;
}

.pin-dot.filled {
  background: var(--primary-lt);
  border-color: var(--primary);
  color: var(--primary);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.num-key {
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-md);
  background: var(--chalk);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--ink);
}

.num-key:hover  { background: var(--chalk-dark); }
.num-key:active { transform: scale(0.9); }
.num-key.del  { font-size: 14px; color: var(--ink-muted); }
.num-key.ok   { background: var(--primary); color: white; border-color: var(--primary); }
.num-key.ok:hover { background: var(--primary-dk); }

.pin-error {
  font-size: 12px;
  color: var(--error);
  min-height: 18px;
  margin-top: 8px;
}

@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)}
  40%{transform:translateX(6px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)}
}
.pin-box.shake { animation: shake 0.35s ease; }

/* ── Progress bar ───────────────────────────────────────── */
.progress-wrap { background: var(--chalk-dark); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.6s var(--ease); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .page-wrap { padding: 20px 14px 80px; }
  .card { padding: 20px 18px; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1; text-align: center; padding: 8px 12px; }
  .module-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  .module-grid { grid-template-columns: 1fr; }
}
