/* ============================================================
   CERTIGO TST – main.css
   ============================================================ */

/* ===== VARIABLES ===== */
:root {
  --primary:        #1B2A4A;
  --primary-light:  #243563;
  --primary-dark:   #131e35;
  --accent:         #F5A623;
  --accent-dark:    #E8950E;
  --success:        #22c55e;
  --success-bg:     #e6f9ee;
  --warning:        #f59e0b;
  --warning-bg:     #fff8e1;
  --danger:         #ef4444;
  --danger-bg:      #fce4ec;
  --info:           #3b82f6;
  --info-bg:        #e3f2fd;
  --text:           #1e293b;
  --text-light:     #64748b;
  --text-muted:     #94a3b8;
  --border:         #e2e8f0;
  --bg:             #f1f5f9;
  --white:          #ffffff;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 6px rgba(0,0,0,.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 32px rgba(27,42,74,.14);
  --sidebar-w:      260px;
  --topbar-h:       60px;
  --transition:     .18s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; }
ul { list-style: none; }
button { font-family: inherit; }
code { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
body.app-layout { display: flex; overflow-x: hidden; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-header .sidebar-logo {
  display: flex;
  align-items: center;
}
.sidebar-header .logo-img {
  height: 32px;
  filter: brightness(0) invert(1);
}
.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: rgba(255,255,255,.7);
  border-radius: 2px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { margin-bottom: 4px; }
.nav-label {
  display: block;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.72);
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,.09);
  color: var(--white);
  border-left-color: var(--accent);
}
.nav-item svg { flex-shrink: 0; opacity: .8; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  font-size: .85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { font-size: .72rem; color: rgba(255,255,255,.45); }
.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  color: rgba(255,255,255,.5);
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: var(--white); }

/* ─── Overlay mobile ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* ─── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.topbar-menu-btn span {
  display: block;
  width: 22px; height: 2px;
  background: var(--primary);
  border-radius: 2px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Page content ────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ============================================================
   AUTH LAYOUT
   ============================================================ */
body.auth-layout {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  padding: 40px 36px 32px;
}
.auth-logo { text-align: center; margin-bottom: 8px; }
.auth-logo-img { height: 52px; object-fit: contain; }
.auth-subtitle {
  text-align: center;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-light);
  margin-bottom: 28px;
}
.auth-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  text-align: center;
}
.auth-footer { font-size: .75rem; color: rgba(255,255,255,.45); text-align: center; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin: 0 24px 0;
  border: 1px solid transparent;
}
.page-content > .alert,
.main-content > .alert { margin: 12px 24px 0; }
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: .6;
  padding: 0 0 0 8px;
  flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-error    { background: var(--danger-bg);  color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info     { background: var(--info-bg);    color: #1e40af; border-color: #bfdbfe; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-lg { padding: 5px 14px; font-size: .8rem; }
.badge-upcoming    { background: #dbeafe; color: #1d4ed8; }
.badge-ongoing     { background: #fef3c7; color: #b45309; }
.badge-past        { background: #f1f5f9; color: #64748b; }
.badge-complete    { background: var(--success-bg); color: #166534; }
.badge-secondary   { background: #f1f5f9; color: #64748b; }
.badge-admin       { background: #fce7f3; color: #9d174d; }
.badge-gestionnaire{ background: #dcfce7; color: #166534; }
.badge-formateur   { background: #dbeafe; color: #1d4ed8; }
.badge-module      { background: #ede9fe; color: #6d28d9; }
.badge-you         { background: var(--accent); color: var(--white); }
.badge-role-admin       { background: #fce7f3; color: #9d174d; }
.badge-role-gestionnaire{ background: #dcfce7; color: #166534; }
.badge-role-formateur   { background: #dbeafe; color: #1d4ed8; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn svg { flex-shrink: 0; }

.btn-primary   { background: var(--accent); color: var(--white); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--white); }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }

.btn-outline-primary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: var(--white); }

.btn-success   { background: var(--success); color: var(--white); border-color: var(--success); }
.btn-success:hover { background: #16a34a; border-color: #16a34a; color: var(--white); }

.btn-danger    { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: var(--white); }

.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-outline:hover { background: var(--danger); color: var(--white); border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg); color: var(--primary); }
.btn-danger-icon { color: var(--danger); }
.btn-danger-icon:hover { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 5px;
}
.form-required::after { content: ' *'; color: var(--danger); }
.form-hint  { font-size: .78rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 4px; display: block; }

.form-input {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,166,35,.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input.is-invalid { border-color: var(--danger); }
.form-input-sm { padding: 5px 10px; font-size: .82rem; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
}
.form-col-2 { grid-column: span 2; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Password toggle */
.input-password-wrapper { position: relative; }
.input-password-wrapper .form-input { padding-right: 44px; }
.btn-toggle-password {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer;
  color: var(--text-light);
  display: flex; align-items: center;
  padding: 4px; line-height: 1;
}
.btn-toggle-password:hover { color: var(--primary); }

/* Filter bar */
.filter-card { padding: 0; }
.filter-form { padding: 16px 20px; }
.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; min-width: 160px; flex: 1; }
.filter-group .form-label { margin-bottom: 4px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 0; flex-shrink: 0; }

/* Inline form */
.inline { display: inline; }
.inline-edit-form { display: flex; align-items: center; gap: 6px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-subtitle { font-size: .8rem; color: var(--text-light); margin-top: 2px; }
.card-body { padding: 20px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrapper.card { padding: 0; }
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  background: var(--primary);
  color: var(--white);
  padding: 11px 14px;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.data-table thead th:first-child { border-radius: 0; }
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td { padding: 11px 14px; font-size: .875rem; vertical-align: middle; }
.data-table tbody tr:last-child { border-bottom: none; }
.table-actions { white-space: nowrap; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }

/* Results header */
.results-header { display: flex; align-items: center; margin-bottom: 12px; }
.results-count { font-size: .82rem; color: var(--text-light); font-weight: 500; }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar-wrapper {
  background: #e2e8f0;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 3px;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  transition: width .4s ease;
}
.mini-progress-bar {
  background: #e2e8f0;
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
  margin-bottom: 3px;
  min-width: 60px;
}
.mini-progress-fill {
  height: 100%;
  border-radius: 20px;
  transition: width .4s ease;
}
.mini-progress-text { font-size: .72rem; color: var(--text-light); }
.progress-success, .mini-progress-fill.progress-success { background: var(--success); }
.progress-warning, .mini-progress-fill.progress-warning { background: var(--warning); }
.progress-danger,  .mini-progress-fill.progress-danger  { background: var(--danger); }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon-orange { background: #fef3c7; color: #b45309; }
.stat-icon-green  { background: #dcfce7; color: #166534; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--text-light); margin-top: 2px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
}
.modal-content {
  position: relative;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h4 { font-size: .95rem; font-weight: 600; color: var(--primary); }
.modal-close {
  background: none; border: none; font-size: 1.3rem;
  cursor: pointer; color: var(--text-light); line-height: 1;
}
.modal-close:hover { color: var(--primary); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-json {
  background: #f8fafc;
  padding: 16px;
  border-radius: 6px;
  font-size: .8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  max-height: 60vh;
  overflow-y: auto;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-light);
}
.empty-state svg { opacity: .35; margin-bottom: 12px; }
.empty-state h3 { font-size: .95rem; color: var(--primary); margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; margin-bottom: 16px; }
.empty-state-sm { padding: 24px 20px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 5px;
  font-size: .875rem;
  border: 1.5px solid var(--border);
  color: var(--primary);
}
.pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .active { background: var(--accent); color: white; border-color: var(--accent); font-weight: 700; }

/* ============================================================
   SESSIONS — LIST
   ============================================================ */
.session-id { font-family: monospace; font-size: .82rem; color: var(--text-light); }
.module-name-small { font-size: .78rem; color: var(--text-light); margin-left: 4px; }
.date-range { display: flex; align-items: center; gap: 4px; font-size: .875rem; }
.date-separator { color: var(--text-muted); }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px;
  background: #f1f5f9; color: var(--primary);
  border-radius: 13px;
  font-size: .8rem; font-weight: 600;
}
.progress-cell { min-width: 120px; }

/* ============================================================
   SESSIONS — DETAIL
   ============================================================ */
.session-header-card { margin-bottom: 20px; }
.session-header-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
.session-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.session-title { font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.session-meta { display: flex; flex-wrap: wrap; gap: 14px; }
.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .82rem;
  color: var(--text-light);
}
.meta-item svg { opacity: .7; }
.session-notes {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-light);
  background: #f8fafc;
}

/* Progress circle */
.global-progress { display: flex; align-items: center; gap: 14px; }
.progress-circle { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.progress-circle svg { transform: rotate(-90deg); }
.progress-circle-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; font-weight: 700; color: var(--primary);
}
.progress-label-block { display: flex; flex-direction: column; }
.progress-label-main { font-size: .82rem; font-weight: 600; color: var(--primary); }
.progress-label-sub  { font-size: .75rem; color: var(--text-light); }

/* Prereq snapshot */
.prereq-snapshot-card { }
.prereq-list { padding: 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.prereq-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.prereq-item:last-child { border-bottom: none; }
.prereq-num {
  width: 22px; height: 22px;
  background: var(--primary); color: var(--white);
  border-radius: 50%;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.prereq-label { font-size: .875rem; color: var(--text); }

/* Company card */
.company-card { }
.company-card-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.company-header-info { display: flex; flex-direction: column; gap: 2px; }
.company-name {
  display: flex; align-items: center; gap: 8px;
  font-size: .95rem; font-weight: 600; color: var(--primary);
}
.company-location { font-size: .78rem; color: var(--text-light); }
.company-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.company-progress-inline { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.company-bulk-actions { display: flex; align-items: center; gap: 6px; }

/* Prereq grid table */
.participants-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.prereq-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.prereq-grid-table th {
  background: #f8fafc;
  color: var(--primary);
  padding: 9px 10px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.prereq-grid-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.prereq-grid-table tr:hover td { background: #f8fafc; }
.prereq-grid-table tr:last-child td { border-bottom: none; }
.th-prereq { max-width: 80px; }
.prereq-th-label {
  display: block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .7rem;
}
.td-participant { min-width: 160px; }
.participant-name { font-weight: 600; color: var(--primary); }
.participant-job  { font-size: .75rem; color: var(--text-light); }
.td-progress { min-width: 100px; }
.td-prereq { width: 60px; }

/* Checkbox cell */
.checkbox-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.checkbox-cell input[type=checkbox] { display: none; }
.checkmark {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.checkbox-cell input:checked + .checkmark {
  background: var(--success);
  border-color: var(--success);
}
.checkbox-cell input:checked + .checkmark::after {
  content: '';
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}
.prereq-status.validated   { color: var(--success); font-weight: 700; }
.prereq-status.not-validated { color: var(--text-muted); }

/* ============================================================
   SESSIONS — CREATE (étapes)
   ============================================================ */

/* ─── Sections par étape ─────────────────────────────────── */
.step-section { padding: 24px; }
.step-section + .step-section {
  border-top: 1px solid var(--border);
  background: var(--white);
}

/* ─── En-tête d'étape ─────────────────────────────────────── */
.step-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}
.step-badge {
  width: 34px; height: 34px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(27,42,74,.2);
  transition: background var(--transition), box-shadow var(--transition);
}
.step-badge.done {
  background: var(--success);
  box-shadow: 0 2px 8px rgba(34,197,94,.3);
}
.step-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
}
.step-subtitle { font-size: .82rem; color: var(--text-light); margin-top: 3px; }

/* ─── Barre filtre + recherche ID ────────────────────────── */
.planner-picker-bar {
  display: flex;
  gap: 0;
  align-items: center;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 10px 12px;
  flex-wrap: wrap;
  row-gap: 8px;
}
.planner-picker-bar > .form-input { flex: 1; min-width: 140px; background: var(--white); }
.planner-picker-id-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  padding-left: 12px;
  margin-left: 12px;
  border-left: 1px solid var(--border);
}
.planner-picker-id-search .form-input { background: var(--white); width: 190px; }

/* ─── Bandeau session sélectionnée ───────────────────────── */
.planner-selected-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.planner-selected-icon {
  width: 36px; height: 36px;
  background: var(--success);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  flex-shrink: 0;
}
.planner-selected-info { flex: 1; min-width: 0; }
.planner-selected-info strong { color: var(--text); display: block; }
.planner-selected-info span  { font-size: .8rem; color: var(--text-light); margin-top: 2px; display: block; }

/* ─── Conteneur tableau Planner ──────────────────────────── */
.planner-sessions-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.planner-sessions-container .data-table { margin: 0; }

/* États loading / vide / erreur */
.planner-state-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  color: var(--text-light);
  font-size: .875rem;
  text-align: center;
}
.planner-state-msg svg { opacity: .35; }
.planner-state-msg p { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.planner-state-msg.is-error { color: var(--danger); }
.planner-state-msg.is-error svg { opacity: .55; }

/* ─── Overlay verrou formulaire ──────────────────────────── */
.form-step-wrapper { position: relative; }
.form-step-overlay {
  position: absolute;
  inset: 0;
  background: rgba(248,250,252,.9);
  backdrop-filter: blur(1px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 5;
  color: var(--text-light);
  font-size: .875rem;
  font-weight: 500;
  text-align: center;
  padding: 40px 20px;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  pointer-events: all;
  min-height: 180px;
}
.form-step-overlay svg { opacity: .3; }

fieldset:disabled { opacity: .5; pointer-events: none; }

/* ─── Flash ligne recherche ──────────────────────────────── */
.row-highlight { animation: rowFlash .35s ease 0s 5 alternate; }
@keyframes rowFlash {
  from { background: transparent; }
  to   { background: var(--warning-bg); }
}

/* Spinner chargement */
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Tag inline (code formation) ───────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 5px;
  letter-spacing: .2px;
}
.tag         { background: var(--border); color: var(--text-muted); }
.tag-info    { background: var(--info-bg); color: var(--info); }

/* ============================================================
   ADMIN — SETTINGS
   ============================================================ */

/* Badge de statut global */
.settings-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .4px;
  flex-shrink: 0;
}
.settings-status-badge.configured { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.settings-status-badge.incomplete  { background: var(--warning-bg); color: var(--warning); border: 1px solid #fcd34d; }

/* Notice .env */
.settings-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 20px;
  background: var(--info-bg);
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-light);
  line-height: 1.5;
}
.settings-notice svg { flex-shrink: 0; margin-top: 1px; color: var(--info); opacity: .8; }
.settings-notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; font-size: .8rem; }

/* Lignes de paramètres */
.settings-rows { padding: 0 20px; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  flex-shrink: 0;
}
.settings-row-label svg { color: var(--text-light); flex-shrink: 0; }
.settings-env-var {
  font-size: .72rem;
  background: var(--bg);
  color: var(--text-light);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-weight: 400;
}
.settings-row-value { flex-shrink: 0; text-align: right; }
.settings-value-text {
  font-size: .875rem;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .82rem;
}
.settings-value-missing { font-size: .82rem; color: var(--text-muted); font-style: italic; }

/* Chips statut */
.settings-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.chip-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.chip-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fca5a5; }
.chip-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* Section test de connexion */
.settings-test-section {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.settings-test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.settings-test-title   { font-size: .875rem; font-weight: 600; color: var(--text); }
.settings-test-subtitle { font-size: .78rem; color: var(--text-light); margin-top: 2px; }

/* Résultat du test */
.settings-test-result { margin-top: 14px; }
.settings-test-ok,
.settings-test-err {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: .875rem;
}
.settings-test-ok {
  background: var(--success-bg);
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--success);
  color: var(--success);
}
.settings-test-err {
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  border-left: 4px solid var(--danger);
  color: var(--danger);
}
.settings-test-ok svg, .settings-test-err svg { flex-shrink: 0; margin-top: 1px; }
.settings-test-ok strong, .settings-test-err strong { display: block; color: var(--text); }
.settings-test-ok span, .settings-test-err span { display: block; font-size: .82rem; margin-top: 2px; color: var(--text-light); }
.settings-token-preview {
  display: block;
  margin-top: 4px;
  font-size: .78rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-light);
  word-break: break-all;
}

/* ============================================================
   MODULES — LIST
   ============================================================ */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.module-card { margin-bottom: 0; transition: box-shadow var(--transition), transform var(--transition); }
.module-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.module-inactive { opacity: .6; }
.module-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}
.module-code-badge {
  background: var(--primary);
  color: var(--white);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.module-code-badge-inline {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 700;
  margin-right: 4px;
}
.module-name { font-size: .95rem; font-weight: 600; color: var(--primary); padding: 0 16px 6px; }
.module-desc { font-size: .82rem; color: var(--text-light); padding: 0 16px 10px; }
.module-meta { padding: 8px 16px; border-top: 1px solid var(--border); }
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  color: var(--text-light);
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 20px;
}
.module-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ============================================================
   MODULES — PREREQUISITE EDITOR
   ============================================================ */
.add-prereq-form { padding: 16px 20px; }
.add-prereq-row { display: flex; gap: 10px; }
.add-prereq-row .form-input { flex: 1; }

.prereq-sortable-list { list-style: none; padding: 8px 0; }
.prereq-sortable-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid #f1f5f9;
  transition: background var(--transition);
}
.prereq-sortable-item:last-child { border-bottom: none; }
.prereq-sortable-item:hover { background: #f8fafc; }
.prereq-sortable-item.dragging { opacity: .5; background: #f0f9ff; }

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

.prereq-order-badge {
  width: 22px; height: 22px;
  background: #f1f5f9;
  color: var(--text-light);
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.prereq-label-text { flex: 1; font-size: .875rem; color: var(--text); }
.prereq-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }

/* ============================================================
   ADMIN — USERS
   ============================================================ */
.user-row { display: flex; align-items: center; gap: 8px; }
.user-avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.toggle-active-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-active-btn.active   { background: var(--success-bg); color: #166534; }
.toggle-active-btn.inactive { background: #f1f5f9; color: var(--text-light); }
.toggle-active-btn:hover    { opacity: .8; }

/* ============================================================
   ADMIN — LOGS
   ============================================================ */
.action-code {
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .78rem;
  color: #6d28d9;
  font-family: monospace;
}
.entity-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--info-bg);
  color: var(--info);
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 500;
}
.btn-details { color: var(--info); }
.btn-details:hover { background: var(--info-bg); color: var(--info); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-light); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: .4; }
.breadcrumb .current { color: var(--primary); font-weight: 500; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-accent   { color: var(--accent) !important; }
.text-primary-c{ color: var(--primary) !important; }
.font-bold     { font-weight: 700; }
.d-flex        { display: flex; }
.d-none        { display: none !important; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }  .gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 8px; }   .mt-2 { margin-top: 16px; }  .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.w-100 { width: 100%; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tooltip */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--primary); color: white;
  padding: 4px 10px; border-radius: 4px;
  font-size: .72rem; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .18s; z-index: 9999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .session-header-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
  }
  .sidebar-toggle { display: flex; }
  .topbar-menu-btn { display: flex; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }

  .filter-grid { flex-direction: column; }
  .filter-group { min-width: 100%; }

  .form-grid-2 { grid-template-columns: 1fr; padding: 16px; }
  .form-col-2  { grid-column: span 1; }

  .planner-picker-bar { flex-direction: column; align-items: stretch; }
  .planner-picker-id-search { flex-wrap: wrap; }

  .company-card-header { flex-direction: column; align-items: flex-start; }
  .company-bulk-actions { flex-wrap: wrap; }

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

  .topbar-title h1 { font-size: .9rem; }
  .auth-card { padding: 28px 20px; }

  .add-prereq-row { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .badge-lg   { padding: 4px 10px; font-size: .75rem; }
  .session-title { font-size: 1rem; }
  .global-progress { flex-direction: column; text-align: center; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-actions .btn span { display: none; }
  .data-table tbody td { padding: 8px 10px; font-size: .8rem; }
}

/* ===== DOCS MODAL ===== */
dialog.docs-modal {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: 560px;
  max-width: 95vw;
  max-height: 80vh;
  overflow: hidden;
  /* explicit centering — needed when ancestors have transforms */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog.docs-modal[open] {
  display: flex;
  flex-direction: column;
}
dialog.docs-modal::backdrop {
  background: rgba(27, 42, 74, .45);
  backdrop-filter: blur(2px);
}
.docs-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}
.docs-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}
.docs-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--bg);
  min-height: 80px;
}
.docs-modal-loading {
  color: var(--text-muted);
  font-size: .875rem;
  text-align: center;
  padding: 24px 0;
}
.docs-modal-empty {
  color: var(--text-muted);
  font-size: .875rem;
  text-align: center;
  padding: 24px 0;
}
.docs-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}
.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.doc-item-icon { color: var(--text-muted); flex-shrink: 0; }
.doc-item-info { flex: 1; min-width: 0; }
.doc-item-name {
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-item-meta { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.doc-item-source {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.doc-item-source.source-public { background: var(--info-bg); color: var(--info); }
.doc-item-source.source-admin  { background: var(--warning-bg); color: var(--warning); }

/* ===== DOC COUNT BADGE ===== */
.btn-icon { position: relative; }
.doc-count-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: var(--white);
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
  line-height: 1;
}
.btn-icon-docs-filled { color: var(--accent); }
.btn-icon-docs-filled:hover { color: var(--accent-dark); }
