/* ==========================================================================
   BNE — Groupe Scolaire Bonne Nouvelle
   Feuille de style applicative (CSS natif, complément du CDN Tailwind)
   ========================================================================== */

:root {
  --bne-primary: #1e3a8a;
  --bne-accent: #d4a017;
  --bne-sidebar-from: #1e3a8a;
  --bne-sidebar-to: #0f172a;
  --bne-sidebar-bg: linear-gradient(180deg, #1e3a8a 0%, #0f172a 100%);
  --bne-sidebar-text: #eff6ff;
  --bne-body-bg: #f9fafb;
  --bne-header-bg: #ffffff;
  --bne-success: #16a34a;
  --bne-warning: #d97706;
  --bne-danger: #dc2626;
  --bne-info: #0284c7;
  --bne-link: #1e3a8a;
  --bne-radius: .75rem;
  --bne-font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --bne-density: 1;
}

body {
  font-family: var(--bne-font);
  background: var(--bne-body-bg);
}

/* --------------------------------------------------------- Barre latérale */
.sidebar-gradient { background: var(--bne-sidebar-bg); }
.sidebar-gradient .sidebar-link { color: var(--bne-sidebar-text); }
.sidebar-link { border-left: 3px solid transparent; }
.sidebar-link.active {
  background: rgba(255, 255, 255, .14);
  border-left-color: var(--bne-accent);
  font-weight: 600;
}
.auth-bg { background: linear-gradient(135deg, var(--bne-sidebar-from, var(--bne-primary)) 0%, var(--bne-sidebar-to) 75%, #1e293b 100%); }

/* ------------------------------------------------------------- Composants */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: var(--bne-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.card-title { font-weight: 600; color: #374151; font-size: .95rem; }
.card-body { padding: 1.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: .5rem;
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .15s, background-color .15s;
  text-decoration: none;
  line-height: 1.25rem;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--bne-primary); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-accent { background: var(--bne-accent); color: #fff; }
.btn-accent:hover { opacity: .9; }
.btn-ghost { background: #fff; border-color: #d1d5db; color: #374151; }
.btn-ghost:hover { background: #f9fafb; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: .3rem .7rem; font-size: .78rem; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: .5rem;
  padding: .5rem .75rem;
  font-size: .875rem;
  background: #fff;
  color: #111827;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(191, 219, 254, .6);
}
.form-input:disabled, .form-select:disabled { background: #f3f4f6; color: #6b7280; }
.form-label {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: .25rem;
}
.form-hint { font-size: .7rem; color: #6b7280; margin-top: .2rem; }
.form-grid { display: grid; gap: .875rem; }

/* ---------------------------------------------------------------- Tableau */
.table-bne { width: 100%; font-size: .875rem; border-collapse: collapse; }
.table-bne thead th {
  text-align: left;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  font-weight: 600;
  padding: .55rem .75rem;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
.table-bne tbody td {
  padding: .6rem .75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table-bne tbody tr:hover { background: rgba(239, 246, 255, .55); }
.table-bne tfoot td { padding: .6rem .75rem; font-weight: 600; background: #f8fafc; }

.badge {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: 9999px;
  font-size: .7rem;
  font-weight: 500;
  white-space: nowrap;
}

.stat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: .75rem; padding: 1rem 1.15rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; color: #111827; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }

/* -------------------------------------------------------------- Pipeline */
.kanban-column { min-width: 265px; max-width: 265px; flex: 0 0 auto; }
.kanban-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: .5rem;
  padding: .6rem;
  margin-bottom: .5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  cursor: grab;
  font-size: .82rem;
  transition: box-shadow .15s, transform .15s, opacity .15s;
}
.kanban-card:hover { box-shadow: 0 4px 10px rgba(0, 0, 0, .09); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .4; transform: rotate(1.5deg); }
.kanban-dropzone { min-height: 60px; border-radius: .5rem; transition: background-color .15s, box-shadow .15s; padding: .25rem; }
.kanban-dropzone.drag-over { background: #eff6ff; box-shadow: inset 0 0 0 2px #93c5fd; }

/* ---------------------------------------------- Suivi par compétences */
.dot { display: inline-block; width: .9rem; height: .9rem; border-radius: 9999px; vertical-align: -1px; }
.dot-acquis { background: #22c55e; }
.dot-en_cours { background: #fbbf24; }
.dot-a_renforcer { background: #f87171; }
.dot-none { background: #e5e7eb; }

/* ---------------------------------------------------------------- Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.modal-panel {
  background: #fff;
  border-radius: .75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .35);
  width: 100%;
  max-width: 44rem;
  margin: 2rem 0;
}
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .875rem 1.25rem; border-top: 1px solid #f1f5f9; display: flex; justify-content: flex-end; gap: .5rem; }

/* ----------------------------------------------------------------- Toasts */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: .5rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .18);
  font-size: .85rem;
  animation: toast-in .22s ease-out;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-info { background: #2563eb; }
.toast-warning { background: #d97706; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 2rem; height: 2rem;
  border: 3px solid #dbeafe;
  border-top-color: var(--bne-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- Emploi du temps */
.timetable { width: 100%; border-collapse: collapse; }
.timetable th, .timetable td { border: 1px solid #e5e7eb; font-size: .75rem; padding: .25rem; vertical-align: top; }
.timetable th { background: #f8fafc; font-weight: 600; color: #4b5563; }
.timetable .slot { border-radius: .3rem; padding: .3rem .4rem; line-height: 1.15; background: #eff6ff; border-left: 3px solid var(--bne-primary); }

/* -------------------------------------------------------------- Documents */
.receipt-stamp {
  display: inline-block;
  border: 2.5px solid var(--bne-primary);
  color: var(--bne-primary);
  transform: rotate(-11deg);
  padding: .35rem 1rem;
  border-radius: .5rem;
  font-weight: 700;
  letter-spacing: .04em;
  font-size: .85rem;
  opacity: .85;
}
.doc-header { border-bottom: 3px double var(--bne-primary); padding-bottom: .75rem; }
.doc-title {
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-decoration: underline;
  margin: 1.5rem 0;
}
.signature-box { border-top: 1px solid #9ca3af; padding-top: .35rem; min-width: 11rem; text-align: center; font-size: .78rem; }

/* ---------------------------------------------------------------- Divers */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #9ca3af; }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; opacity: .5; }

.tab-link { padding: .5rem .9rem; font-size: .85rem; color: #4b5563; border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; }
.tab-link:hover { color: var(--bne-primary); }
.tab-link.active { color: var(--bne-primary); border-bottom-color: var(--bne-primary); font-weight: 600; }

.ged-tile { transition: box-shadow .15s, border-color .15s; }
.ged-tile:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .08); border-color: #bfdbfe; }

@media print {
  .no-print { display: none !important; }
}

/* ------------------------------------------------- Charte graphique (suite)
   Jetons pilotes depuis Paramètres › Charte graphique. */
.app-header { background: var(--bne-header-bg); }
.bne-link, a.bne-link:hover { color: var(--bne-link); }
.btn { border-radius: calc(var(--bne-radius) * .6); }
.btn-success { background: var(--bne-success); color: #fff; }
.btn-danger  { background: var(--bne-danger);  color: #fff; }
.text-bne-success { color: var(--bne-success); }
.text-bne-warning { color: var(--bne-warning); }
.text-bne-danger  { color: var(--bne-danger); }
.text-bne-info    { color: var(--bne-info); }
.bg-bne-success { background: var(--bne-success); }
.bg-bne-warning { background: var(--bne-warning); }
.bg-bne-danger  { background: var(--bne-danger); }
.bg-bne-info    { background: var(--bne-info); }

/* Densite compacte : resserre tableaux, cartes et champs */
.table-bne tbody td { padding: calc(.6rem * var(--bne-density)) .75rem; }
.card-body { padding: calc(1.25rem * var(--bne-density)); }

/* Apercu de la charte dans l'ecran de parametrage */
.theme-swatch {
  width: 100%; height: 2.5rem; border-radius: .5rem;
  border: 1px solid rgba(0, 0, 0, .1); cursor: pointer; padding: 0; background: none;
}
.theme-preview { border-radius: var(--bne-radius); overflow: hidden; border: 1px solid #e5e7eb; }
.theme-preview .tp-side { width: 92px; min-height: 190px; }
.theme-preview .tp-link { border-left: 3px solid transparent; }
.theme-preview .tp-link.on { border-left-color: var(--tp-accent); background: rgba(255, 255, 255, .16); }