/* ============================================================
   DESIGN SYSTEM — styles.css
   Brand: #1976d2 (blue) + #19395b (navy)
   ============================================================ */

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

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }

/* ── TOKENS ── */
:root {
  --navy-900: #19395b;
  --navy-700: #334e68;
  --navy-400: #7a95b0;
  --navy-200: #d0dce8;
  --navy-100: #eef3f8;
  --navy-50:  #f5f8fb;
  --white:    #ffffff;
  --blue-700: #1565c0;
  --blue-600: #1976d2;
  --blue-400: #42a5f5;
  --blue-50:  #e3f0fb;
  --green-700: #1b7a3e;
  --green-50:  #e6f4ec;
  --amber-700: #b45309;
  --amber-50:  #fef7e6;
  --red-700:   #b91c1c;
  --red-50:    #fef2f2;
  --font: 'Inter', system-ui, sans-serif;
  --shadow-card: 0 1px 2px rgba(25,57,91,0.04);
  --shadow-md:   0 1px 3px rgba(25,57,91,0.08);
  --radius-card: 10px;
  --radius-btn:  6px;
  --radius-badge: 6px;
  --sidebar-active-bg: rgba(25, 118, 210, 0.25); /* --blue-600 at 25% opacity */
}

/* ── BASE ── */
html, body { height: 100%; background: var(--navy-50); font-family: var(--font); font-size: 14px; color: var(--navy-700); line-height: 1.5; }

/* ── SHELL ── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--navy-900);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-logo svg { width: 16px; height: 16px; fill: white; }
.sidebar-brand-name { font-size: 13px; font-weight: 700; color: var(--white); line-height: 1.2; }
.sidebar-brand-sub  { font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 1px; }
.sidebar-section-label {
  padding: 20px 18px 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: rgba(255,255,255,0.3);
}
.sidebar-nav { padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.6);
  text-decoration: none; margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--white); }
.nav-icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--blue-400); opacity: 1; }
.sidebar-footer {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 8px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--white); flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.75); }

/* ── MAIN AREA ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── TOPBAR ── */
.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--white); border-bottom: 1px solid var(--navy-200);
  display: flex; align-items: center; padding: 0 24px; gap: 12px;
}
.topbar-breadcrumb { font-size: 12px; color: var(--navy-400); display: flex; align-items: center; gap: 6px; }
.topbar-breadcrumb a { color: var(--navy-400); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--blue-600); }
.topbar-breadcrumb span { color: var(--navy-700); font-weight: 500; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--navy-900); margin-left: 4px; }
.topbar-spacer { flex: 1; }
.topbar-meta { font-size: 12px; color: var(--navy-400); }
.topbar-meta strong { color: var(--navy-700); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-btn);
  font-size: 13px; font-weight: 600; border: none;
  transition: background 0.15s;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-primary { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: var(--blue-700); }
.btn-ghost { background: transparent; color: var(--navy-700); border: 1px solid var(--navy-200); }
.btn-ghost:hover { background: var(--navy-100); }
.btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

/* ── CONTENT AREA ── */
.content { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }

/* ── STAT CARDS ── */
.stats-grid   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stats-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat-card {
  background: var(--white); border: 1px solid var(--navy-200);
  border-radius: var(--radius-card); padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card-header { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-icon {
  width: 32px; height: 32px; background: var(--blue-50);
  border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 16px; height: 16px; stroke: var(--blue-600); fill: none; stroke-width: 2; stroke-linecap: round; }
.stat-icon.red   { background: var(--red-50); }
.stat-icon.red svg { stroke: var(--red-700); }
.stat-icon.green { background: var(--green-50); }
.stat-icon.green svg { stroke: var(--green-700); }
.stat-icon.amber { background: var(--amber-50); }
.stat-icon.amber svg { stroke: var(--amber-700); }
.stat-num { font-size: 30px; font-weight: 700; color: var(--navy-900); letter-spacing: -1px; line-height: 1; margin-top: 10px; }
.stat-num.red    { color: var(--red-700); }
.stat-num.green  { color: var(--green-700); }
.stat-num.amber  { color: var(--amber-700); }
.stat-label { font-size: 12px; color: var(--navy-400); margin-top: 3px; }
.stat-delta { font-size: 11px; font-weight: 600; color: var(--green-700); margin-top: 6px; }

/* ── SECTION CARDS ── */
.section-card {
  background: var(--white); border: 1px solid var(--navy-200);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.section-header {
  padding: 14px 18px; border-bottom: 1px solid var(--navy-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.section-title { font-size: 13px; font-weight: 700; color: var(--navy-900); }
.section-subtitle { font-size: 11px; color: var(--navy-400); margin-top: 1px; }
.section-body { padding: 14px 18px; }

/* ── TWO-COL MIDDLE ROW ── */
.middle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── TEACHERS ── */
.teacher-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--navy-100);
}
.teacher-row:last-child { border-bottom: none; }
.teacher-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-50); border: 2px solid var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--blue-700); flex-shrink: 0;
}
.teacher-avatar.sm {
  width: 20px; height: 20px; font-size: 9px; border-width: 1px;
}
.teacher-name  { font-size: 13px; font-weight: 600; color: var(--navy-900); }
.teacher-count { font-size: 11px; color: var(--navy-400); }
.teacher-spacer { flex: 1; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-badge);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.badge-valid   { background: var(--green-50);  color: var(--green-700); }
.badge-pending { background: var(--amber-50);  color: var(--amber-700); }
.badge-null    { background: var(--red-50);    color: var(--red-700); }
.badge-receive { background: var(--navy-100);  color: var(--navy-700); }
.badge-id      { background: var(--blue-50);   color: var(--blue-700); }
.badge-role    { background: var(--blue-50);   color: var(--blue-700); }
.badge-neutral { background: var(--navy-100);  color: var(--navy-700); }

.type-pill { font-size: 11px; font-weight: 500; color: var(--navy-700); background: var(--navy-100); padding: 2px 8px; border-radius: 4px; }

/* ── MINI STATS GRID ── */
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-stat {
  background: var(--navy-50); border: 1px solid var(--navy-100);
  border-radius: 8px; padding: 12px 14px;
}
.mini-stat-num   { font-size: 22px; font-weight: 700; color: var(--navy-900); letter-spacing: -0.5px; }
.mini-stat-label { font-size: 11px; color: var(--navy-400); margin-top: 2px; }

/* ── TABLE CARD ── */
.table-card {
  background: var(--white); border: 1px solid var(--navy-200);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
}
.table-header-bar {
  padding: 14px 18px; border-bottom: 1px solid var(--navy-100);
  display: flex; align-items: center; gap: 12px;
}
.table-count  { font-size: 12px; color: var(--navy-400); margin-left: 8px; }
.table-spacer { flex: 1; }
.search-box {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--navy-200); border-radius: 6px;
  padding: 5px 10px; font-size: 12px; color: var(--navy-400); background: var(--navy-50);
}
.search-box svg { width: 12px; height: 12px; stroke: var(--navy-400); fill: none; stroke-width: 2; flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--navy-400); background: var(--navy-50);
  border-bottom: 1px solid var(--navy-200); white-space: nowrap;
}
thead th:first-child { padding-left: 18px; }
thead th:last-child  { padding-right: 18px; text-align: right; }
thead th.right  { text-align: right; }
thead th.center { text-align: center; }
tbody tr { border-bottom: 1px solid var(--navy-100); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--navy-50); }
tbody td { padding: 12px 16px; font-size: 13px; color: var(--navy-700); vertical-align: middle; }
tbody td:first-child { padding-left: 18px; }
tbody td:last-child  { padding-right: 18px; text-align: right; }
tbody td.right  { text-align: right; }
tbody td.center { text-align: center; }
tbody td.bold   { font-weight: 600; color: var(--navy-900); font-variant-numeric: tabular-nums; }
tbody td.muted  { color: var(--navy-400); font-size: 12px; font-variant-numeric: tabular-nums; }

.attendance-max { color: var(--navy-400); font-weight: 400; }

.action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--navy-200); background: transparent;
  color: var(--navy-400); transition: background 0.12s, color 0.12s;
}
.action-btn:hover { background: var(--navy-100); color: var(--navy-700); }
.action-btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }
.action-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.action-group { display: flex; gap: 4px; justify-content: flex-end; }

/* ── FORMATION CARDS (dashboard) ── */
.formation-card {
  background: var(--white); border: 1px solid var(--navy-200);
  border-radius: var(--radius-card); padding: 18px 20px;
  box-shadow: var(--shadow-card); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.formation-card:hover { border-color: var(--blue-600); box-shadow: var(--shadow-md); }
.formation-card-title { font-size: 14px; font-weight: 700; color: var(--navy-900); }
.formation-card-meta  { font-size: 12px; color: var(--navy-400); }
.formation-card-stats { display: flex; gap: 16px; margin-top: 4px; }
.fcs { display: flex; flex-direction: column; }
.fcs-num   { font-size: 20px; font-weight: 700; color: var(--navy-900); letter-spacing: -0.5px; line-height: 1; }
.fcs-label { font-size: 11px; color: var(--navy-400); margin-top: 2px; }

/* ── CSS BAR CHART (statistiques) ── */
.chart-card {
  background: var(--white); border: 1px solid var(--navy-200);
  border-radius: var(--radius-card); padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.chart-title { font-size: 13px; font-weight: 700; color: var(--navy-900); margin-bottom: 16px; }
.bar-chart { display: flex; align-items: stretch; gap: 8px; height: 150px; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.bar-fill { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.bar {
  width: 100%; border-radius: 4px 4px 0 0;
  background: var(--blue-600); min-height: 4px;
  transition: opacity 0.15s;
}
.bar:hover { opacity: 0.8; }
.bar.green  { background: var(--green-700); }
.bar.amber  { background: var(--amber-700); }
.bar.red    { background: var(--red-700); }
.bar-label  { font-size: 10px; color: var(--navy-400); text-align: center; white-space: nowrap; }
.bar-value  { font-size: 11px; font-weight: 600; color: var(--navy-700); }
.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ── EMPTY STATE ── */
.empty-state {
  padding: 48px 24px; text-align: center;
  color: var(--navy-400); font-size: 13px;
}
.empty-state svg { width: 32px; height: 32px; stroke: var(--navy-200); fill: none; stroke-width: 1.5; margin-bottom: 12px; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */

/* ── Burger / overlay (cachés par défaut sur desktop) ── */
.nav-toggle-input { display: none; }

.nav-burger {
  display: none;
  flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; padding: 6px;
  cursor: pointer; flex-shrink: 0; border-radius: 6px;
  transition: background 0.15s;
}
.nav-burger:hover { background: var(--navy-100); }
.nav-burger span {
  display: block; width: 20px; height: 2px;
  background: var(--navy-700); border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform-origin: center;
}

.nav-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 100; cursor: pointer;
}

/* ── Tablet : 641px – 1100px — sidebar icônes seules ── */
@media (max-width: 1100px) {
  .sidebar { width: 60px; }
  .sidebar-brand { padding: 16px 0; justify-content: center; }
  .sidebar-brand-name,
  .sidebar-brand-sub   { display: none; }
  .sidebar-section-label { display: none; }
  .sidebar-nav { padding: 0 6px; }
  .nav-item  { justify-content: center; padding: 10px 8px; font-size: 0; }
  .nav-icon  { width: 20px; height: 20px; }
  .sidebar-footer { justify-content: center; padding: 12px 0; }
  .user-name { display: none; }

  .stats-grid   { grid-template-columns: repeat(2, 1fr); }
  .middle-row   { grid-template-columns: 1fr; }
  .chart-grid-2 { grid-template-columns: 1fr; }
}

/* ── Mobile : ≤ 640px — burger drawer ── */
@media (max-width: 640px) {
  /* Afficher le bouton burger */
  .nav-burger { display: flex; }

  /* Sidebar : tiroir fixe hors-écran par défaut */
  .sidebar {
    position: fixed;
    top: 0; left: -270px; bottom: 0;
    width: 260px; height: 100vh;
    z-index: 200; flex-direction: column;
    transition: left 0.28s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }

  /* Remettre le rendu complet de la sidebar dans le tiroir */
  .sidebar-brand { padding: 20px 18px 16px; justify-content: flex-start; }
  .sidebar-brand-name { display: block; }
  .sidebar-brand-sub  { display: block; }
  .sidebar-section-label { display: block; }
  .sidebar-nav { padding: 0 8px; }
  .nav-item  { justify-content: flex-start; padding: 8px 10px; font-size: 13px; font-weight: 500; }
  .nav-icon  { width: 16px; height: 16px; }
  .sidebar-footer { justify-content: flex-start; padding: 12px 16px; }
  .user-name { display: block; }

  /* Ouvrir le tiroir */
  .nav-toggle-input:checked ~ .shell .sidebar { left: 0; }

  /* Overlay visible quand ouvert */
  .nav-toggle-input:checked ~ .nav-overlay { display: block; }

  /* Animation burger → croix */
  .nav-toggle-input:checked ~ .shell .nav-burger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .nav-toggle-input:checked ~ .shell .nav-burger span:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle-input:checked ~ .shell .nav-burger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Main : pleine largeur (sidebar hors du flux) */
  .shell   { height: 100vh; overflow: hidden; }
  .main    { width: 100%; }
  .content { padding: 12px; gap: 12px; }
  .topbar  { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }

  /* Grilles */
  .stats-grid,
  .stats-grid-3 { grid-template-columns: 1fr 1fr; }
  .middle-row,
  .chart-grid-2,
  .chart-grid-3 { grid-template-columns: 1fr; }

  .table-card     { overflow-x: auto; }
  .stat-num       { font-size: 22px; }
  .formation-card { padding: 14px; }
  .chart-card     { padding: 14px 16px; }
}

/* ── Petit mobile : ≤ 400px — colonne unique ── */
@media (max-width: 400px) {
  .stats-grid,
  .stats-grid-3,
  .stats-grid-2 { grid-template-columns: 1fr; }
  .stat-num { font-size: 20px; }
}
