/* EDT Studio — design system
   Palette reprise du Ministère : bleu nuit (#1D2B4F) / orange (#C0622A) */

:root {
  --navy: #1D2B4F;
  --navy-light: #2C3E6B;
  --orange: #C0622A;
  --orange-light: #E08A55;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E1E4EA;
  --text: #1B1F27;
  --text-muted: #6B7280;
  --success: #1E8A5F;
  --danger: #C0392B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 40, 0.08), 0 1px 2px rgba(20, 24, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar-main {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; }
.brand-text span { font-size: 11px; color: #C7CEE3; }

.etab-switcher {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s;
}
.etab-switcher:hover { background: rgba(255,255,255,0.18); }
.etab-switcher .placeholder { color: #C7CEE3; }
.etab-switcher .name { font-weight: 600; }
.etab-switcher .sub { display: block; font-size: 10px; color: #C7CEE3; }
.etab-switcher.offline-badge::before {
  content: "● hors ligne";
  color: #F2C572;
  font-size: 10px;
  display: block;
}
.etab-switcher.online-badge::before {
  content: "● synchronisé";
  color: #7BE1A6;
  font-size: 10px;
  display: block;
}

/* ---------- Stepper ---------- */
.stepper-bar {
  display: flex;
  gap: 2px;
  background: var(--navy-light);
  overflow-x: auto;
  padding: 0 8px;
}
.step-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #C7CEE3;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.step-pill .num {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  font-size: 10px; display: flex; align-items: center; justify-content: center;
}
.step-pill.active { color: #fff; border-color: var(--orange); font-weight: 600; }
.step-pill.active .num { background: var(--orange); }
.step-pill.done .num { background: var(--success); }
.step-pill.disabled { opacity: 0.4; cursor: not-allowed; }

.step-heading {
  padding: 16px 20px 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.step-heading .sub {
  display: block;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Content ---------- */
.content { flex: 1; padding: 8px 20px 40px; max-width: 1080px; width: 100%; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--navy); }
.card .hint { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(44,62,107,0.12); }
.field { margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--navy); color: #fff; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px; position: sticky; top: 0; z-index: 5; }
tr:nth-child(even) td { background: #FAFBFC; }
td input, td select { padding: 6px 8px; font-size: 13px; }
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
/* Variante "en-tête toujours visible" (demande de Diba, tableau des masses
   horaires §3.2, 22/08/2026) : contrairement à .table-wrap seule, cette
   variante défile elle-même verticalement (au lieu de laisser toute la page
   défiler) — c'est ce qui permet à `th { position: sticky; top: 0 }`
   ci-dessus de coller au HAUT DE CE CADRE plutôt que de se retrouver caché
   sous le bandeau bleu fixe en haut de l'application. Volontairement pas
   appliqué à .table-wrap globalement : la grille de montage d'emploi du
   temps (très interactive, beaucoup de tests existants) utilise aussi
   .table-wrap et ne doit pas changer de comportement de défilement. */
.table-wrap-sticky { max-height: 65vh; overflow-y: auto; }
.table-wrap td.col-total, .table-wrap th.col-total { background: #EEF1F8; font-weight: 700; }
th.col-total { background: var(--navy-light); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-accent { background: var(--orange); color: #fff; }
.btn-accent:hover { background: var(--orange-light); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { background: #EEF0F4; }
.btn-danger { background: transparent; color: var(--danger); border-color: #F1C6C0; }
.btn-danger:hover { background: #FCEEEC; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pc { background: #E7EEFB; color: #2A56B8; }
.badge-pl { background: #EAF6EE; color: var(--success); }
.badge-warn { background: #FDF1E4; color: var(--orange); }

/* ---------- Accueil des modules (GestEtabPro) — Diba, 02/09/2026 :
   "CEST UNE APPLICATION COMPLETE DE GESTION ETABLISSEMENT... EDT STUDIO EST
   LE 1ER MODULE". Voir App.renderHubModules() dans app.js. ---------- */
.hub-intro { text-align: center; padding: 22px 10px 8px; }
.hub-intro h2 { margin: 0 0 6px; font-size: 22px; color: var(--navy); }
.hub-intro .hint { font-size: 13.5px; margin-bottom: 0; }
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.module-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(20,24,40,0.12); }
.module-card.bientot { cursor: default; opacity: 0.72; }
.module-card.bientot:hover { transform: none; box-shadow: var(--shadow); }
.module-icon { font-size: 34px; margin-bottom: 8px; }
.module-card h3 { margin: 0 0 2px; font-size: 15px; color: var(--navy); }
.module-soustitre { font-size: 11.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.module-card .hint { margin: 6px 0 12px; }
.module-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.module-status.status-ok { background: #EAF6EE; color: var(--success); }
.module-status.status-soon { background: #FDF1E4; color: var(--orange); }

.alert { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; }
.alert-info { background: #EBF1FB; color: #244A8C; border: 1px solid #CFE0F7; }
.alert-warn { background: #FDF1E4; color: #8A4B12; border: 1px solid #F4D6AF; }
.alert-danger { background: #FCEEEC; color: #8A2A1E; border: 1px solid #F1C6C0; }
.alert-success { background: #EAF6EE; color: #1E6B3A; border: 1px solid #C7E8D1; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,20,35,0.55);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 { margin: 0 0 4px; font-size: 17px; color: var(--navy); }
.modal .hint { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.etab-list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; cursor: pointer;
}
.etab-list-item:hover { border-color: var(--navy-light); background: #F7F9FC; }
.etab-list-item .name { font-weight: 600; font-size: 13.5px; }
.etab-list-item .meta { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.empty-state { text-align: center; padding: 30px 10px; color: var(--text-muted); font-size: 13px; }
.small-btn { font-size: 11.5px; padding: 4px 8px; border-radius: 6px; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-4 { margin-top: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Barre de progression (génération de l'emploi du temps) ---------- */
.progress-wrap { margin-top: 8px; }
.progress-track {
  height: 10px; border-radius: 999px; background: var(--bg-subtle);
  border: 1px solid var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--navy-light), var(--navy));
  transition: width 0.15s ease-out;
}
.progress-label {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-muted); margin-top: 5px;
}
.progress-label .pct { font-weight: 600; color: var(--navy); white-space: nowrap; }

/* ---------- Assistant IA (Diba, 22/08/2026) ---------- */
.assistant-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  background: var(--orange); color: #fff; border: none; border-radius: 999px;
  padding: 12px 20px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 20px rgba(192, 98, 42, 0.35);
}
.assistant-fab:hover { background: var(--orange-light); }
.assistant-modal { max-width: 520px; display: flex; flex-direction: column; }
.assistant-fil {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 45vh; min-height: 120px; overflow-y: auto;
  padding: 4px 2px; margin-bottom: 10px;
}
.assistant-msg {
  padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4;
  max-width: 85%; white-space: pre-wrap;
}
.assistant-msg-user {
  align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 3px;
}
.assistant-msg-assistant {
  align-self: flex-start; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 3px;
}
.assistant-saisie { display: flex; gap: 8px; }
.assistant-saisie input {
  flex: 1; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13.5px;
}