/* ═══════════════════════════════════════════════════════════════
   PORTAIL DE FORMATION — feuille de style
   Couleurs injectées en variables CSS depuis parametres_portail
   (voir includes/head.php). Polices : Syne (titres) + Plus Jakarta
   Sans (interface/FR) + Cairo (contenu arabe, RTL).
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #3D52C4;
  --accent: #ED2024;
  --bg: #F7F7FA;
  --surface: #FFFFFF;
  --text: #171923;
  --text-muted: #6B7280;
  --border: #E6E7EE;
  --success: #1F9D6B;
  --primary-dark: color-mix(in srgb, var(--primary) 82%, black);
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 26px;
  --shadow: 0 10px 30px -12px rgba(23, 22, 54, 0.18);
  --shadow-sm: 0 4px 14px -6px rgba(23, 22, 54, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display {
  font-family: 'Syne', 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

p { line-height: 1.65; color: var(--text); }
a { color: inherit; }

/* ── RTL : contenu arabe passe sur Cairo, sens inversé ──────── */
[dir="rtl"] {
  font-family: 'Cairo', 'Plus Jakarta Sans', sans-serif;
}
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 {
  font-family: 'Cairo', sans-serif;
  font-weight: 800;
  letter-spacing: 0;
}

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ═══════════════════════════════════════════════════════════
   ÉCRAN DE CONNEXION — mot de passe unique, pas de contenu visible
   ═══════════════════════════════════════════════════════════ */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--primary) 55%, transparent), transparent 42%),
    radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 40%),
    linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-dark) 100%);
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 28px 28px 20px 20px;
  padding: 40px 32px 32px;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.45);
  text-align: center;
}

.gate-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  overflow: hidden;
}
.gate-logo img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }

.gate-name {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.gate-title {
  font-size: 1.6rem;
  margin-bottom: 22px;
}

.gate-lock {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.field {
  width: 100%;
  padding: 15px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  text-align: center;
  letter-spacing: 0.04em;
}
.field:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); }
.btn-danger { background: var(--accent); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 0.85rem; }

.gate-form { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }

.gate-error {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 16px;
}

/* ═══════════════════════════════════════════════════════════
   EN-TÊTE GLOBAL (pages authentifiées)
   ═══════════════════════════════════════════════════════════ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 1120px;
  margin: 0 auto;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo { width: 38px; height: 38px; border-radius: 10px; overflow: hidden; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; }
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.topbar-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.lang-switch {
  display: flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-switch a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-muted);
}
.lang-switch a.active { background: var(--primary); color: #fff; }

/* ═══════════════════════════════════════════════════════════
   TABLEAU DE BORD — sélection de module
   ═══════════════════════════════════════════════════════════ */
.dash-hero { padding: 48px 0 8px; text-align: center; }
.dash-hero h1 { font-size: 2rem; margin-bottom: 10px; }
.dash-hero p { color: var(--text-muted); max-width: 480px; margin: 0 auto; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 36px 0 60px;
}
@media (max-width: 540px) {
  .module-grid { grid-template-columns: 1fr; }
}

.module-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 30px 26px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.module-card.unlocked:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.module-card.locked { opacity: 0.55; filter: grayscale(0.6); cursor: not-allowed; }

.module-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: #fff;
}
.module-card h3 { font-size: 1.2rem; margin-bottom: 8px; }
.module-card p { color: var(--text-muted); font-size: 0.9rem; }

.module-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
}
[dir="rtl"] .module-badge { right: auto; left: 20px; }
.module-badge.active { background: var(--success); color: #fff; }

/* ═══════════════════════════════════════════════════════════
   VISIONNEUSE DE FORMATION — sidebar + contenu
   ═══════════════════════════════════════════════════════════ */
.course {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  min-height: calc(100vh - 66px);
}
@media (max-width: 920px) {
  .course { grid-template-columns: 1fr; }
}

.course-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  overflow-y: auto;
}
[dir="rtl"] .course-sidebar { border-right: none; border-left: 1px solid var(--border); }

.sidebar-module { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.sidebar-module .module-icon { width: 36px; height: 36px; border-radius: 10px; margin: 0; }
.sidebar-module strong { font-size: 0.95rem; }

.chap-block { margin-bottom: 6px; }
.chap-title {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 14px 10px 8px;
}
.step-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}
.step-link:hover { background: var(--bg); }
.step-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.step-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}
.step-link.active .step-dot { background: var(--primary); }

.course-content { padding: 36px 44px 60px; max-width: 760px; }
@media (max-width: 600px) { .course-content { padding: 24px 20px 48px; } }

.course-content .eyebrow {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.course-content h1 { font-size: 1.7rem; margin-bottom: 22px; }

.video-frame {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0d0f1a;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}
.video-frame video { width: 100%; height: 100%; object-fit: cover; }

.rich-text { font-size: 1.02rem; color: var(--text); }
.rich-text img { border-radius: var(--radius-sm); margin: 18px 0; }
.rich-text h2, .rich-text h3 { margin: 28px 0 12px; }
.rich-text ul, .rich-text ol { padding-inline-start: 22px; line-height: 1.8; }
.rich-text p { margin: 0 0 16px; }

.course-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.course-nav .btn { flex: 1; max-width: 220px; }

/* ═══════════════════════════════════════════════════════════
   BACKOFFICE
   ═══════════════════════════════════════════════════════════ */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 66px); }
@media (max-width: 860px) { .admin-shell { grid-template-columns: 1fr; } }

.admin-nav { background: var(--surface); border-right: 1px solid var(--border); padding: 24px 14px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.92rem;
  margin-bottom: 4px;
}
.admin-nav a:hover, .admin-nav a.active { background: var(--primary-soft); color: var(--primary); }

.admin-content { padding: 32px 40px; max-width: 980px; }
@media (max-width: 600px) { .admin-content { padding: 20px; } }

.admin-content h1 { font-size: 1.5rem; margin-bottom: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 18px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--surface);
}
.list-row-main { display: flex; align-items: center; gap: 12px; }
.list-row-title { font-weight: 700; font-size: 0.95rem; }
.list-row-sub { font-size: 0.8rem; color: var(--text-muted); }
.list-row-actions { display: flex; gap: 8px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; font-size: 0.86rem; margin-bottom: 7px; }
.form-group .hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

input[type=text], input[type=password], input[type=email], input[type=url], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--surface);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }

.color-row { display: flex; align-items: center; gap: 10px; }
.color-swatch {
  width: 42px; height: 42px; border-radius: 10px;
  border: 1.5px solid var(--border); flex-shrink: 0;
}

.badge-admin {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}

.alert {
  padding: 13px 16px; border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 600; margin-bottom: 20px;
}
.alert-success { background: color-mix(in srgb, var(--success) 14%, white); color: var(--success); }
.alert-error { background: var(--accent-soft); color: var(--accent); }

.empty-state {
  text-align: center; padding: 50px 20px; color: var(--text-muted);
}

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  vertical-align: middle;
}
