/* ==========================================================================
   Gestion Formation — Design System
   Design premium, moderne, 100% responsive (mobile-first).
   Variables CSS + composants réutilisables. Remplace tout le CSS inline
   dupliqué historiquement sur chaque page.
   ========================================================================== */

:root {
  /* Couleurs marque */
  --gf-primary: #2f6fed;
  --gf-primary-dark: #1d4ed8;
  --gf-primary-light: #eaf1ff;
  --gf-accent: #0ea5b7;
  --gf-ink: #0f172a;
  --gf-slate-900: #0f172a;
  --gf-slate-800: #1e293b;
  --gf-slate-700: #334155;
  --gf-slate-500: #64748b;
  --gf-slate-300: #cbd5e1;
  --gf-slate-200: #e2e8f0;
  --gf-slate-100: #f1f5f9;
  --gf-bg: #f4f7fb;
  --gf-surface: #ffffff;

  /* États */
  --gf-success: #16a34a;
  --gf-success-bg: #ecfdf3;
  --gf-danger: #dc2626;
  --gf-danger-bg: #fef2f2;
  --gf-warning: #d97706;
  --gf-warning-bg: #fffbeb;
  --gf-info: #2563eb;
  --gf-info-bg: #eff6ff;

  /* Effets */
  --gf-radius-sm: 8px;
  --gf-radius: 14px;
  --gf-radius-lg: 20px;
  --gf-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --gf-shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --gf-shadow-lg: 0 20px 45px rgba(15, 23, 42, .12);
  --gf-sidebar-w: 264px;
  --gf-topbar-h: 64px;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', 'Roboto', system-ui, -apple-system, sans-serif;
  background: var(--gf-bg);
  color: var(--gf-slate-800);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; color: var(--gf-slate-900); font-weight: 700; }
p { margin: 0 0 .75rem; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

/* ---------- Layout général : sidebar + topbar ---------- */
.gf-app { display: flex; min-height: 100vh; }

.gf-sidebar {
  width: var(--gf-sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  padding: 20px 16px 24px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(0);
  transition: transform .25s ease;
  overflow-y: auto;
}
.gf-sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 20px; }
.gf-sidebar-brand img { height: 38px; width: 38px; border-radius: 10px; background: #fff; padding: 3px; }
.gf-sidebar-brand strong { display: block; font-size: 1.05em; color: #fff; }
.gf-sidebar-brand span { display: block; font-size: .78em; color: #94a3b8; }

.gf-nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: #cbd5e1; font-weight: 500; font-size: .95em;
  transition: background .2s ease, color .2s ease;
}
.gf-nav-link i { width: 20px; text-align: center; font-size: 1.05em; color: #93a5c4; }
.gf-nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.gf-nav-link.active { background: var(--gf-primary); color: #fff; box-shadow: var(--gf-shadow-sm); }
.gf-nav-link.active i { color: #fff; }
.gf-sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.gf-sidebar-user { display:flex; align-items:center; gap:10px; padding: 8px 10px; }
.gf-sidebar-user .avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--gf-primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink:0;
}
.gf-sidebar-user .who { min-width: 0; }
.gf-sidebar-user .who strong { display:block; color:#fff; font-size:.92em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gf-sidebar-user .who span { display:block; font-size:.78em; color:#94a3b8; }
.gf-logout-link { display:flex; align-items:center; gap:10px; padding: 10px 14px; margin-top:6px; border-radius:10px; color:#fca5a5; font-weight:600; font-size:.92em; }
.gf-logout-link:hover { background: rgba(220,38,38,.15); }

.gf-main { flex: 1; min-width: 0; margin-left: var(--gf-sidebar-w); display: flex; flex-direction: column; }

.gf-topbar {
  height: var(--gf-topbar-h);
  background: var(--gf-surface);
  border-bottom: 1px solid var(--gf-slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
.gf-topbar h1 { font-size: 1.15em; margin: 0; }
.gf-topbar-actions { display: flex; align-items: center; gap: 10px; }
.gf-burger {
  display: none; background: none; border: none; cursor: pointer;
  width: 40px; height: 40px; border-radius: 10px; align-items: center; justify-content: center;
  color: var(--gf-slate-700); font-size: 1.25em;
}
.gf-burger:hover { background: var(--gf-slate-100); }

.gf-content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

.gf-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55;
}
.gf-overlay.open { display: block; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h1 { font-size: 1.5em; }
.page-header p { color: var(--gf-slate-500); margin: 4px 0 0; font-size: .95em; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cartes ---------- */
.card {
  background: var(--gf-surface); border-radius: var(--gf-radius); padding: 22px;
  box-shadow: var(--gf-shadow-sm); border: 1px solid var(--gf-slate-200);
}
.card + .card { margin-top: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--gf-primary-light); color: var(--gf-primary); font-size: 1.3em; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.5em; font-weight: 700; color: var(--gf-slate-900); }
.stat-card .stat-label { color: var(--gf-slate-500); font-size: .88em; }

.option-card {
  background: var(--gf-surface); border-radius: var(--gf-radius-lg); padding: 26px;
  border: 1px solid var(--gf-slate-200); box-shadow: var(--gf-shadow-sm);
  display: flex; flex-direction: column; gap: 10px; transition: transform .2s ease, box-shadow .2s ease;
}
.option-card:hover { transform: translateY(-4px); box-shadow: var(--gf-shadow); }
.option-card .stat-icon { margin-bottom: 6px; }
.option-card h3 { font-size: 1.15em; }
.option-card p { color: var(--gf-slate-500); font-size: .92em; flex: 1; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .92em; cursor: pointer; transition: all .18s ease;
  background: var(--gf-primary); color: #fff; line-height: 1.3;
}
.btn:hover { background: var(--gf-primary-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.btn-secondary { background: var(--gf-slate-100); color: var(--gf-slate-700); border-color: var(--gf-slate-200); }
.btn.btn-secondary:hover { background: var(--gf-slate-200); }
.btn.btn-outline { background: transparent; color: var(--gf-primary); border-color: var(--gf-primary); }
.btn.btn-outline:hover { background: var(--gf-primary-light); }
.btn.btn-success { background: var(--gf-success); }
.btn.btn-success:hover { background: #15803d; }
.btn.btn-danger { background: var(--gf-danger); }
.btn.btn-danger:hover { background: #b91c1c; }
.btn.btn-warning { background: var(--gf-warning); }
.btn.btn-sm { padding: 7px 12px; font-size: .85em; border-radius: 8px; }
.btn.btn-icon { padding: 9px; width: 38px; height: 38px; }
.btn.btn-block { width: 100%; }

/* ---------- Formulaires ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
label { font-weight: 600; font-size: .88em; color: var(--gf-slate-700); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--gf-slate-300); border-radius: var(--gf-radius-sm);
  font-size: .95em; font-family: inherit; background: #fff; color: var(--gf-slate-900);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gf-primary); box-shadow: 0 0 0 3px rgba(47, 111, 237, .15);
}
textarea { resize: vertical; min-height: 90px; }
.field-check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--gf-slate-700); }
.field-check input { width: 17px; height: 17px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px; margin: 8px 0 16px; }

/* ---------- Alertes / messages ---------- */
.alert { padding: 13px 16px; border-radius: var(--gf-radius-sm); margin-bottom: 18px; font-size: .92em; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--gf-success-bg); color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: var(--gf-danger-bg); color: #b91c1c; border: 1px solid #fecaca; }
.alert-info { background: var(--gf-info-bg); color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--gf-warning-bg); color: #b45309; border: 1px solid #fde68a; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .78em; font-weight: 700; }
.badge-success { background: var(--gf-success-bg); color: #15803d; }
.badge-danger { background: var(--gf-danger-bg); color: #b91c1c; }
.badge-warning { background: var(--gf-warning-bg); color: #b45309; }
.badge-info { background: var(--gf-info-bg); color: #1d4ed8; }
.badge-neutral { background: var(--gf-slate-100); color: var(--gf-slate-500); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--gf-radius); border: 1px solid var(--gf-slate-200); }
table.table-pro { width: 100%; border-collapse: collapse; min-width: 560px; background: #fff; }
table.table-pro th {
  text-align: left; font-size: .78em; text-transform: uppercase; letter-spacing: .04em;
  color: var(--gf-slate-500); padding: 12px 16px; background: var(--gf-slate-100); white-space: nowrap;
}
table.table-pro td { padding: 13px 16px; border-top: 1px solid var(--gf-slate-200); font-size: .92em; vertical-align: middle; }
table.table-pro tbody tr:hover { background: var(--gf-slate-100); }
.action-btns { display: flex; gap: 8px; align-items: center; }
.action-btns a, .action-btns button {
  width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--gf-slate-100); color: var(--gf-slate-700); border: none; cursor: pointer; font-size: .95em; transition: all .15s ease;
}
.action-btns a:hover, .action-btns button:hover { background: var(--gf-primary-light); color: var(--gf-primary); }
.action-btns .danger:hover, .action-btns button.danger:hover { background: var(--gf-danger-bg); color: var(--gf-danger); }

/* ---------- Liste en cartes (mobile-friendly, remplace les tableaux) ---------- */
.list-card { background: #fff; border: 1px solid var(--gf-slate-200); border-radius: var(--gf-radius); padding: 16px 18px; box-shadow: var(--gf-shadow-sm); }
.list-card + .list-card { margin-top: 12px; }
.list-card.border-success { border-left: 4px solid var(--gf-success); }
.list-card.border-danger { border-left: 4px solid var(--gf-danger); }
.list-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gf-slate-500); }
.empty-state i { font-size: 2.2em; margin-bottom: 12px; display: block; color: var(--gf-slate-300); }

/* ---------- Modales ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-content { background: #fff; border-radius: var(--gf-radius-lg); padding: 26px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--gf-shadow-lg); position: relative; }
.modal-close { position: absolute; top: 16px; right: 18px; cursor: pointer; font-size: 1.4em; color: var(--gf-slate-500); border: none; background: none; }
.modal-close:hover { color: var(--gf-slate-900); }
.modal-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.modal-header h2 { font-size: 1.2em; margin-bottom: 4px; }

/* ---------- Auth (login) ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1d4ed8, #0ea5b7); padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: rgba(255,255,255,.98); border-radius: var(--gf-radius-lg); padding: 34px 30px; box-shadow: var(--gf-shadow-lg); }
.auth-card.auth-card-lg { max-width: 560px; }
.auth-card .logo { text-align: center; margin-bottom: 18px; }
.auth-card .logo img { height: 56px; }
.auth-card h2 { text-align: center; margin-bottom: 22px; }

/* ---------- Utilitaires ---------- */
.text-center { text-align: center; }
.text-muted { color: var(--gf-slate-500); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ==========================================================================
   Responsive — mobile first, points de rupture explicites
   ========================================================================== */

/* Petits mobiles (320–479px) : sidebar cachée, nav en tiroir plein écran */
.gf-sidebar { transform: translateX(-100%); }
.gf-sidebar.open { transform: translateX(0); }
.gf-main { margin-left: 0; }
.gf-burger { display: inline-flex; }
.gf-content { padding: 16px; }
.form-row { grid-template-columns: 1fr; }
.card-grid { grid-template-columns: 1fr; }

@media (min-width: 480px) {
  .gf-content { padding: 20px; }
}

/* Tablette portrait (768px+) : sidebar toujours en tiroir mais contenu plus large */
@media (min-width: 768px) {
  .gf-content { padding: 26px; }
  .form-row { grid-template-columns: repeat(2, 1fr); }
}

/* Tablette paysage / petit laptop (1024px+) : sidebar fixe visible en permanence */
@media (min-width: 1024px) {
  .gf-sidebar { transform: translateX(0); position: fixed; }
  .gf-main { margin-left: var(--gf-sidebar-w); }
  .gf-burger { display: none; }
  .gf-overlay { display: none !important; }
  .gf-content { padding: 30px 32px; }
}

/* Desktop (1280px+) */
@media (min-width: 1280px) {
  .gf-content { padding: 34px 40px; }
}

@media (max-width: 480px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; }
  table.table-pro { display: none; }
}
@media (min-width: 481px) {
  .mobile-only-cards { display: none; }
}
