/* ===========================================================================
   CBS Training Control Center — Feuille de styles
   =========================================================================== */

:root {
  --c-termine: #16a34a;
  --c-cours: #f59e0b;
  --c-nondebute: #9ca3af;
  --c-echec: #dc2626;
}

html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

/* Scrollbars discrètes */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* Navigation latérale */
#nav a, #nav button {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .85rem; margin: 0 .5rem; border-radius: .5rem;
  color: #c7d2fe; font-weight: 500; transition: background .15s, color .15s;
  text-align: left; width: calc(100% - 1rem);
}
#nav a:hover, #nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav a.active, #nav button.active { background: #2563eb; color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
#nav a i, #nav button i { width: 1.1rem; text-align: center; font-size: .95rem; }
#nav .nav-group { padding: .75rem .85rem .35rem; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #64748b; font-weight: 700; }

/* Cartes KPI */
.kpi-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: .85rem;
  padding: 1rem 1.15rem; transition: transform .15s, box-shadow .15s; position: relative; overflow: hidden;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -12px rgba(15,23,42,.25); }
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.kpi-card .kpi-label { font-size: .78rem; color: #64748b; font-weight: 500; margin-top: .15rem; }
.kpi-card .kpi-icon { position: absolute; right: .9rem; top: .9rem; font-size: 1.15rem; opacity: .16; }

/* Panneaux */
.panel { background: #fff; border: 1px solid #e2e8f0; border-radius: .85rem; }
.panel-head { padding: .9rem 1.15rem; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.panel-title { font-weight: 600; font-size: .95rem; color: #1e293b; display: flex; align-items: center; gap: .5rem; }

/* Tableaux */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.tbl thead th {
  background: #f8fafc; color: #475569; font-weight: 600; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .04em; padding: .65rem .75rem; text-align: left; border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
.tbl tbody td { padding: .6rem .75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 70vh; }

/* Badges de statut */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-TERMINE { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.badge-EN_COURS { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.badge-NON_DEBUTE { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-ECHEC { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.badge-ELEVEE { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.badge-MOYENNE { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.badge-SURVEILLER { background: #fef9c3; color: #a16207; border-color: #fef08a; }
.badge-CONFORME { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }

/* Barres de progression */
.progress { height: .5rem; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.progress-sm { height: .35rem; }

/* Cellules de matrice */
.matrix { border-collapse: separate; border-spacing: 2px; font-size: .8rem; }
.matrix th { position: sticky; top: 0; background: #f8fafc; z-index: 2; padding: .4rem .5rem; font-size: .72rem; color: #475569; font-weight: 600; }
.matrix td { padding: 0; }
.matrix .sticky-col { position: sticky; left: 0; background: #fff; z-index: 3; padding: .4rem .6rem; box-shadow: 1px 0 0 #e2e8f0; min-width: 190px; }
.matrix thead .sticky-col { background: #f8fafc; z-index: 4; }
.cell-btn {
  width: 100%; min-width: 42px; height: 30px; border-radius: .35rem; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .72rem; font-weight: 700;
  transition: transform .1s, filter .1s; color: #fff;
}
.cell-btn:hover { transform: scale(1.08); filter: brightness(1.08); }
.cell-TERMINE { background: #16a34a; }
.cell-EN_COURS { background: #f59e0b; }
.cell-NON_DEBUTE { background: #cbd5e1; color: #475569; }
.cell-ECHEC { background: #dc2626; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .5rem .9rem; border-radius: .55rem; font-size: .84rem; font-weight: 600; transition: all .15s; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-ghost { background: #fff; color: #334155; border-color: #e2e8f0; }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: .32rem .6rem; font-size: .76rem; border-radius: .45rem; }
.btn-icon { width: 2rem; height: 2rem; padding: 0; }

/* Champs */
.field { width: 100%; padding: .5rem .7rem; border: 1px solid #cbd5e1; border-radius: .5rem; font-size: .85rem; background: #fff; outline: none; transition: border .15s, box-shadow .15s; }
.field:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 1rem; padding-right: 1.9rem; }

/* Modales */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 1.5rem 1rem; overflow-y: auto; z-index: 55; }
.modal-box { background: #fff; border-radius: .9rem; width: 100%; max-width: 640px; box-shadow: 0 25px 50px -12px rgba(0,0,0,.4); margin: auto; animation: pop .18s ease; }
.modal-box.modal-lg { max-width: 1000px; }
.modal-box.modal-xl { max-width: 1280px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-body { padding: 1.25rem; }
.modal-foot { padding: .9rem 1.25rem; border-top: 1px solid #f1f5f9; display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }

/* Toasts */
.toast { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem; border-radius: .6rem; background: #fff; border-left: 4px solid #64748b; box-shadow: 0 10px 25px -8px rgba(15,23,42,.35); min-width: 280px; max-width: 400px; animation: slideIn .25s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.success { border-left-color: #16a34a; }
.toast.error { border-left-color: #dc2626; }
.toast.warning { border-left-color: #f59e0b; }
.toast.info { border-left-color: #2563eb; }

/* Dropzone */
.dropzone { border: 2px dashed #cbd5e1; border-radius: .9rem; padding: 2.5rem 1rem; text-align: center; transition: all .18s; background: #f8fafc; cursor: pointer; }
.dropzone:hover, .dropzone.dragover { border-color: #2563eb; background: #eff6ff; }

/* Divers */
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .65rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe; }
.skeleton { background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: .4rem; }
@keyframes sk { to { background-position: -200% 0; } }
.link { color: #1d4ed8; font-weight: 600; cursor: pointer; }
.link:hover { text-decoration: underline; }
.section-title { font-size: 1.25rem; font-weight: 700; color: #0f172a; letter-spacing: -.01em; }
.section-sub { font-size: .85rem; color: #64748b; margin-top: .15rem; }
.divider { height: 1px; background: #f1f5f9; }
.stat-line { display: flex; justify-content: space-between; align-items: center; padding: .45rem 0; font-size: .85rem; }
.stat-line + .stat-line { border-top: 1px dashed #f1f5f9; }

/* Impression */
@media print {
  #sidebar, header, footer, #toast-container { display: none !important; }
  .lg\:pl-64 { padding-left: 0 !important; }
  .panel { break-inside: avoid; }
}

/* Accessibilité daltonisme : motifs + libellés toujours présents */
.cell-btn::after { content: attr(data-label); font-size: .62rem; font-weight: 700; }
.cell-btn.icon-only::after { content: none; }
@media (max-width: 1023px) {
  .matrix .sticky-col { min-width: 150px; }
}
