/* ===========================================================================
   Seven RH — Design system
   Inspiré de Lucca / Factorial / PayFit / Notion / Linear : sobre, arrondi,
   animations discrètes. Variables CSS centralisées pour un futur dark mode.
   ========================================================================= */

:root {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-border: #e6e8eb;
  --color-text: #1a1d24;
  --color-text-muted: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-soft: #eef2ff;
  --color-success: #16a34a;
  --color-success-soft: #ecfdf3;
  --color-warning: #b45309;
  --color-warning-soft: #fff7ed;
  --color-info: #2563eb;
  --color-info-soft: #eff6ff;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-muted-soft: #f1f2f4;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --mobile-nav-height: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Repère de focus clavier pour les lignes/cartes cliquables rendues via des <tr>/<div role="button">
   (salariés, organigramme, favoris, notifications) — sans ça, le focus ajouté au clavier serait invisible. */
[role="button"]:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
p { margin: 0; line-height: 1.5; }

.text-muted { color: var(--color-text-muted); font-size: 14px; }

/* ---------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------- */

#app-shell {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  font-weight: 700;
  font-size: 16px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: white;
  font-weight: 700;
}

#sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  /* #sidebar est en position:fixed (hauteur = 100vh) : sans ça, un compte avec beaucoup d'entrées
     de menu (Directeur...) sur un écran court (téléphone) poussait les derniers éléments
     ("Paramètres"...) sous le bas de l'écran, purement inatteignables (rien ne défilait). */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover { background: var(--color-muted-soft); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); }

.nav-section-label {
  padding: 14px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  opacity: 0.7;
}
.nav-section-label:first-child { padding-top: 4px; }
.nav-item.disabled { opacity: 0.6; }

.nav-icon { font-size: 16px; }
.nav-label { flex: 1; }
.nav-soon {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-muted-soft);
  padding: 2px 6px;
  border-radius: 999px;
}

#main-column {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title { font-weight: 600; font-size: 14px; color: var(--color-text-muted); }

/* Bandeau persistant "accès d'essai restreint" — entreprises non souscrites (§ migration 0012). */
.non-souscrit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 28px;
  background: var(--color-warning-soft);
  color: var(--color-warning);
  border-bottom: 1px solid var(--color-warning);
  font-size: 13px;
  font-weight: 500;
}

.non-souscrit-banner .btn { flex-shrink: 0; }

.form-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-warning);
}
.form-hint .btn-link { font-size: 12px; text-decoration: underline; }

/* Console BERTOLIS (§9.6) — écran séparé de l'app-shell salarié, pas de sidebar. */
.bertolis-topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.bertolis-main { max-width: 1100px; margin: 0 auto; padding: 28px; }

.topbar-search { position: relative; flex: 1; max-width: 480px; min-width: 0; }
.topbar-search .input { width: 100%; }

/* Manquait entièrement : sans ça, .notif-wrapper/.user-menu-wrapper (deux <div> block) s'empilaient
   verticalement au lieu de se placer côte à côte — la cloche rendait à moitié hors écran (top négatif)
   et chevauchait l'avatar, à toutes les largeurs d'écran (pas seulement mobile). */
.topbar-user { display: flex; align-items: center; gap: 16px; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}

.search-results.open { display: block; }

.search-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: 10px 14px 4px;
}

/* Sprint SIRH premium §12 (reprise) : sections FAQ/Bonnes pratiques du Centre d'aide */
.help-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--color-border); }
.help-section p { margin-bottom: 10px; font-size: 14px; }
.help-section p:last-child { margin-bottom: 0; }
.help-tips { margin: 0; padding-left: 20px; font-size: 14px; }
.help-tips li { margin-bottom: 6px; }
.help-tips li:last-child { margin-bottom: 0; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.search-result-item:hover, .search-result-item.highlighted { background: var(--color-muted-soft); }
.search-result-icon { font-size: 16px; flex-shrink: 0; }
.search-result-label { font-weight: 600; font-size: 13px; }
.search-result-sublabel { font-size: 12px; color: var(--color-text-muted); }

.search-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--color-text-muted);
}

#view-root {
  padding: 28px 32px;
  max-width: 1440px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

/* ---------------------------------------------------------------------
   Vue header / KPI
   --------------------------------------------------------------------- */

.view-header { margin-bottom: 20px; }
.view-header-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.view-subtitle { color: var(--color-text-muted); font-size: 14px; margin-top: 2px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-icon { font-size: 20px; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-label { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

/* ---------------------------------------------------------------------
   Cartes
   --------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  min-width: 0;
}

/* ---------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

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

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-muted-soft); }

.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-danger:hover { background: #fde2e2; }

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 8px;
  display: inline-block;
  min-height: 24px;
}

.btn-icon {
  position: relative;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px;
}

/* Zone tactile agrandie (repère WCAG ~44x44) sans changer la taille visuelle, comme .chip-remove ci-dessous — le bouton fermer de modale (~15 endroits), la cloche et les icônes d'archivage des notifications en profitent tous d'un coup. */
.btn-icon::before {
  content: '';
  position: absolute;
  inset: -10px;
}

#btn-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
#btn-theme-toggle:hover { background: var(--color-muted-soft); }

/* Une fois connecté, le bouton est déplacé dans .topbar-user (voir showApp) : la position fixe
   chevauchait sinon la cloche/l'avatar, les rendant intouchables.
   position: relative (pas static) — sinon le ::before de .btn-icon (zone tactile agrandie,
   inset:-10px) perd son bloc de positionnement et s'étend jusqu'à l'ancêtre positionné suivant
   (#topbar), recouvrant toute la barre dont la recherche globale. */
#btn-theme-toggle.theme-toggle-inline {
  position: relative;
  top: auto;
  right: auto;
  z-index: auto;
  box-shadow: none;
}

/* ---------------------------------------------------------------------
   Formulaires / filtres
   --------------------------------------------------------------------- */

.input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .input:first-child { flex: 1; min-width: 220px; }

.form-section {
  border: none;
  padding: 0;
  margin: 0 0 22px;
}

.form-section legend {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 500; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------
   Table
   --------------------------------------------------------------------- */

.table-card { padding: 0; overflow-x: auto; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
}

.pagination-controls { display: flex; align-items: center; gap: 12px; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  padding: 16px 22px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
}

.table td {
  padding: 16px 22px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.table-row { cursor: pointer; transition: background-color 0.1s ease; }
.table-row:hover { background: var(--color-muted-soft); }
.table-row:last-child td { border-bottom: none; }

.employee-cell { display: flex; align-items: center; gap: 12px; }
.employee-name { font-weight: 600; }
.employee-matricule { font-size: 12px; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------
   Avatar
   --------------------------------------------------------------------- */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 13px;
}

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-row { display: flex; gap: 6px; margin-top: 8px; }

.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-muted { background: var(--color-muted-soft); color: var(--color-text-muted); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }

.anomaly-list { margin: 0; padding-left: 20px; }
.anomaly-list li { margin-bottom: 4px; }

/* ---------------------------------------------------------------------
   Détail salarié
   --------------------------------------------------------------------- */

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-header .avatar { width: 56px; height: 56px; font-size: 18px; }
.detail-header-info { flex: 1; }
.detail-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--color-text-muted); }
.info-value { font-weight: 500; text-align: right; }

/* ---------------------------------------------------------------------
   États vides / à venir
   --------------------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 8px;
}

.empty-icon { font-size: 32px; }

/* ---------------------------------------------------------------------
   Modales
   --------------------------------------------------------------------- */

#modal-root {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 21, 0.45);
  z-index: 50;
  padding: 20px;
}

#modal-root.open { display: flex; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.15s ease;
}

/* Beaucoup de modales enveloppent .modal-body + .modal-footer dans un <form> (pour le submit) —
   ce <form>, en display:block par défaut, casse la chaîne flex column de .modal : il grandit à la
   hauteur naturelle de son contenu au lieu de participer à la répartition flex, ce qui empêche
   .modal-body de jamais être contraint et donc de défiler (symptôme vu sur mobile : le bas des
   formulaires longs devenait inatteignable, aucun scroll nulle part). */
.modal > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.modal-large { max-width: 760px; }
.modal-small { max-width: 420px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--color-border);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
  /* Sans ça, un flex item garde par défaut min-height:auto (= sa hauteur de contenu naturelle),
     ce qui annule le overflow-y:auto ci-dessus : le corps grandissait au-delà de max-height:90vh
     de .modal au lieu de défiler dedans — sur mobile (viewport court), le bas des formulaires
     longs (fiche salarié...) devenait purement inatteignable, aucun scroll possible nulle part. */
  min-height: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------------
   Toasts
   --------------------------------------------------------------------- */

#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--color-text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--color-danger); }

/* ---------------------------------------------------------------------
   Congés — onglets, soldes, actions de tableau
   --------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab { flex-shrink: 0; }

.tab {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.balance-card {
  position: relative;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--type-color, var(--color-primary));
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.balance-adjust-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 13px;
}

.balance-icon { font-size: 16px; margin-bottom: 4px; }
.balance-name { font-size: 13px; font-weight: 600; }
.balance-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.balance-sub { font-size: 12px; color: var(--color-text-muted); }

.type-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.table-actions { display: flex; gap: 10px; white-space: nowrap; }

.btn-link-danger { color: var(--color-danger); }

.checkbox-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.form-field-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text);
  cursor: pointer;
}

.form-field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

textarea.input { resize: vertical; font-family: inherit; }

/* ---------------------------------------------------------------------
   Calendrier
   --------------------------------------------------------------------- */

.calendar-nav { display: flex; gap: 8px; flex-wrap: wrap; }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.legend-holiday { background: var(--color-danger-soft); border: 1px solid var(--color-danger); }
.legend-school { background: var(--color-info-soft); border: 1px solid var(--color-info); }

.calendar-card { padding: 12px; overflow-x: auto; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  min-width: 640px;
}

.calendar-grid-header { margin-bottom: 6px; }

.calendar-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  padding: 6px 0;
}

.calendar-cell {
  min-height: 112px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-cell.out-month { opacity: 0.4; }
.calendar-cell.weekend { background: var(--color-muted-soft); }
.calendar-cell.today { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.calendar-cell.holiday { background: var(--color-danger-soft); }
.calendar-cell.school-holiday:not(.holiday) { background: var(--color-info-soft); }

/* §4 (reprise) : case cliquable pour ouvrir le détail du jour (openCalendarDayModal) — uniquement
 * quand la case a du contenu (cf. hasContent dans renderCalendarCell). */
.calendar-cell-clickable { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.calendar-cell-clickable:hover { border-color: var(--color-primary); }

.calendar-cell-header { display: flex; justify-content: space-between; }
.calendar-day-number { font-size: 13px; font-weight: 600; }

.calendar-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  width: fit-content;
}

.calendar-tag-holiday { background: var(--color-danger); color: white; }
.calendar-tag-school { background: var(--color-info); color: white; }

.calendar-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }

.calendar-badge {
  position: relative;
  font-size: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 1px 6px;
  cursor: default;
}

.calendar-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: white;
  font-size: 12px;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.calendar-badge:hover .calendar-tooltip { opacity: 1; }

/* Sprint SIRH premium §2 : demande non validée — visible mais visuellement distincte (semi-transparente, bordure en pointillés) d'une demande déjà validée. */
.calendar-badge-pending {
  opacity: 0.55;
  border-style: dashed;
  background: transparent;
}

/* ---------------------------------------------------------------------
   Paramètres — listes de référence
   --------------------------------------------------------------------- */

.settings-lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  /* La zone tactile agrandie de .chip-remove (::before, inset:-10px) déborde son propre bouton
     sans rien changer visuellement, mais compte dans le scrollWidth d'un ancêtre en
     overflow:visible — avec beaucoup de chips (Paramètres notamment), ça rendait toute la page
     horizontalement "scrollable" de quelques pixels sur un écran étroit. */
  overflow: hidden;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-muted-soft);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 13px;
}

.chip-remove {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Zone tactile agrandie à 44x44 (repère WCAG) sans changer la taille visuelle du chip, via une zone invisible superposée. */
.chip-remove::before {
  content: '';
  position: absolute;
  inset: -13px;
}

.chip-remove:hover { background: var(--color-danger-soft); color: var(--color-danger); }

.chip-add-form { display: flex; gap: 8px; }
.chip-add-form .input { flex: 1; }

/* ---------------------------------------------------------------------
   Télétravail — planning hebdomadaire
   --------------------------------------------------------------------- */

.planning-table th, .planning-table td { text-align: center; }
.planning-table th:first-child, .planning-table td:first-child { text-align: left; }

.planning-cell { font-size: 16px; }
.planning-off { color: var(--color-text-muted); font-size: 13px; }
.planning-leave { background: var(--color-warning-soft); }
.planning-remote { background: var(--color-info-soft); }
.planning-office { background: var(--color-success-soft); }

/* Sprint SIRH premium §3 : "modification par glisser-déposer" du Planning (Semaine/Mois) */
.planning-cell[draggable="true"] { cursor: grab; }
.planning-cell-dragging { opacity: 0.4; }
.planning-cell-drop-target { outline: 2px dashed var(--color-primary); outline-offset: -2px; }

.planning-summary-row td {
  background: var(--color-muted-soft);
  font-size: 13px;
  border-top: 2px solid var(--color-border);
}

/* Sprint SIRH premium §2 : regroupement automatique du planning par service */
.planning-service-header td {
  background: var(--color-surface-alt, var(--color-muted-soft));
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  padding-top: 10px;
}

/* §4 (reprise) : grilles Planning/Horaires/Télétravail — beaucoup de colonnes (jours d'un mois) et
 * potentiellement beaucoup de lignes (salariés) ; sans repère fixe, on perd de vue à qui/quel jour
 * correspond une cellule dès qu'on scrolle. `max-height` borne la carte pour que le scroll ait lieu
 * DANS la carte (donc que `position: sticky` ait un vrai ancêtre défilant) plutôt que sur la page. */
.planning-scroll-card { max-height: 70vh; overflow: auto; }

.planning-scroll-card .planning-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 3;
}

.planning-scroll-card .planning-table th:first-child,
.planning-scroll-card .planning-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 2;
}

/* La cellule d'angle (coin haut-gauche) doit rester au-dessus des deux autres groupes de cellules sticky. */
.planning-scroll-card .planning-table thead th:first-child { z-index: 4; }

/* Sans ça, les lignes de regroupement par service (fond distinct) laissent transparaître ce fond
 * à travers la première colonne sticky, qui retomberait sinon sur le fond de carte par défaut. */
.planning-scroll-card .planning-service-header td:first-child { background: var(--color-surface-alt, var(--color-muted-soft)); }
.planning-scroll-card .planning-summary-row td:first-child { background: var(--color-muted-soft); }

/* ---------------------------------------------------------------------
   Dashboard — graphiques SVG faits maison et listes pratiques
   --------------------------------------------------------------------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------
   Paramètres > Abonnement — offres Stripe
   --------------------------------------------------------------------- */

.offres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.offre-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.offre-card-active { border-color: var(--color-primary); background: var(--color-primary-soft); }

.offre-card h3 { font-size: 15px; margin-bottom: 8px; }

.offre-prix { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.offre-prix .text-muted { font-size: 13px; font-weight: 500; }

.chart-card { display: flex; flex-direction: column; }
.chart-subtitle { margin-top: -8px; margin-bottom: 10px; }

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-donut { max-width: 200px; margin: 0 auto; }

.chart-label, .chart-value, .chart-axis-label {
  font-size: 11px;
  fill: var(--color-text-muted);
  font-family: var(--font-sans);
}

.chart-value { fill: var(--color-text); font-weight: 600; }

.chart-donut-total {
  font-size: 22px;
  font-weight: 700;
  fill: var(--color-text);
  font-family: var(--font-sans);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.chart-legend-item { display: flex; align-items: center; gap: 6px; }

.chart-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.mini-list { display: flex; flex-direction: column; gap: 4px; }

.mini-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.mini-list-item:last-child { border-bottom: none; }

/* Sprint SIRH premium §7 : centre d'action du tableau de bord */
.action-center-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

.action-center-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.action-center-item:hover { background: var(--color-muted-soft); border-color: var(--color-primary); }
.action-center-icon { font-size: 18px; }
.action-center-label { flex: 1; }
.action-center-arrow { color: var(--color-text-muted); }

/* Sprint SIRH premium §11 : timeline "Historique" d'une demande (congé/télétravail/note de frais) */
.timeline { display: flex; flex-direction: column; gap: 2px; }

.timeline-item {
  position: relative;
  padding: 8px 0 8px 20px;
  border-left: 2px solid var(--color-border);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
}

.timeline-item:last-child { border-left-color: transparent; }
.timeline-date { font-size: 12px; }
.timeline-label { font-size: 14px; margin-top: 2px; }

/* ---------------------------------------------------------------------
   Organigramme — arbre hiérarchique en CSS pur (lignes de connexion via ::before/::after)
   --------------------------------------------------------------------- */

.org-chart-card { overflow-x: auto; padding: 32px 24px; }

.org-tree, .org-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

.org-tree { justify-content: center; width: max-content; min-width: 100%; }

.org-tree ul { padding-top: 32px; position: relative; }

.org-tree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 0 14px;
}

/* Trait vertical de chaque enfant remontant vers la ligne horizontale de la fratrie */
.org-tree ul li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  height: 32px;
  border-left: 2px solid var(--color-border);
}

/* Trait horizontal reliant les enfants entre eux (absent s'il n'y a qu'un seul enfant) */
.org-tree ul li:not(:only-child)::after {
  content: '';
  position: absolute;
  top: 0;
  height: 0;
  border-top: 2px solid var(--color-border);
}

.org-tree ul li:not(:only-child):first-child::after { left: 50%; right: 0; }
.org-tree ul li:not(:only-child):last-child::after { left: 0; right: 50%; }
.org-tree ul li:not(:only-child):not(:first-child):not(:last-child)::after { left: 0; right: 100%; width: 100%; }
.org-tree ul li:only-child::before { display: none; }

.org-node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  min-width: 150px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 1;
}

.org-node:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.org-node .avatar { width: 40px; height: 40px; }
.org-node-name { font-weight: 600; font-size: 13px; text-align: center; margin-top: 2px; }
.org-node-poste { font-size: 11px; color: var(--color-text-muted); text-align: center; }

/* §12 : replier/déplier les branches — petit bouton en coin, ne doit pas interférer avec le clic
   sur le nœud (qui ouvre la fiche du salarié) : voir evt.stopPropagation() dans bindOrganigrammeEvents. */
.org-node-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-muted-soft);
  color: var(--color-text-muted);
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.org-node-toggle:hover { background: var(--color-border); }

/* ---------------------------------------------------------------------
   Notifications (topbar)
   --------------------------------------------------------------------- */

.notif-wrapper { position: relative; }

.notif-bell {
  position: relative;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.notif-bell:hover { background: var(--color-muted-soft); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: none;
}

.notif-panel.open { display: block; }

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 0;
}

.notif-tabs { border-bottom: none; margin-bottom: 0; }
.notif-tabs .tab { padding: 8px 10px; font-size: 13px; }

.notif-list { padding: 4px 0; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  align-items: flex-start;
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--color-primary-soft); }
.notif-icon { font-size: 16px; margin-top: 2px; flex-shrink: 0; }
.notif-body { flex: 1; cursor: pointer; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-message { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.notif-date { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }
.notif-actions .btn-icon { font-size: 14px; }

/* ---------------------------------------------------------------------
   Menu utilisateur (topbar) — rôle, mot de passe, déconnexion
   --------------------------------------------------------------------- */

.user-menu-wrapper { position: relative; }

.user-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  display: none;
  overflow: hidden;
}

.user-menu-panel.open { display: block; }

.user-menu-header {
  padding: 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-menu-name { font-weight: 600; font-size: 14px; }

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
}

.user-menu-item:hover { background: var(--color-muted-soft); }

/* ---------------------------------------------------------------------
   Écran de connexion
   --------------------------------------------------------------------- */

#login-root {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text-muted);
}

.login-card h1 { margin: 0; }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-error {
  color: var(--color-danger);
  font-size: 13px;
  background: var(--color-danger-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------
   Assistant de première installation (onboarding)
   --------------------------------------------------------------------- */

.onboarding-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 4px;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
}

.onboarding-step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-muted-soft);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.onboarding-step.active .onboarding-step-dot { background: var(--color-primary); color: white; }
.onboarding-step.active .onboarding-step-label { color: var(--color-text); font-weight: 600; }
.onboarding-step.done .onboarding-step-dot { background: var(--color-success); color: white; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */

@media (max-width: 860px) {
  /* Barre de navigation en bas de l'écran (pattern natif mobile) plutôt qu'à gauche : plus
     atteignable au pouce, et n'empiète plus sur la largeur déjà réduite du contenu. #sidebar-nav
     passe d'un défilement vertical (colonne, hauteur = 100vh) à un défilement horizontal (ligne,
     hauteur fixe) — nécessaire car un rôle Directeur peut avoir une dizaine d'entrées de menu,
     largement plus que ce qu'une barre du bas peut afficher sans défiler. */
  #sidebar {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: var(--mobile-nav-height);
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--color-border);
    z-index: 40;
  }
  .sidebar-logo { display: none; }
  #sidebar-nav {
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-height: 0;
    gap: 2px;
  }
  .nav-section-label { display: none; }
  .nav-item {
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
    gap: 2px;
    padding: 6px 14px;
  }
  .nav-icon { font-size: 18px; }
  .nav-label { font-size: 10px; white-space: nowrap; }
  .logo-text, .nav-soon { display: none; }
  #main-column { margin-left: 0; padding-bottom: var(--mobile-nav-height); }
  #view-root { padding: 16px; }
  .calendar-cell { min-height: 64px; }
  .calendar-weekday { font-size: 10px; }
  #topbar { padding: 0 14px; gap: 10px; }
  .topbar-search { max-width: none; }
  .detail-header { flex-wrap: wrap; }
  .detail-header-actions { width: 100%; }
  #toast-root { bottom: calc(var(--mobile-nav-height) + 16px); }
  /* right:-8px avec une largeur proche de 100vw dépassait du bord gauche de l'écran dès que la
     cloche n'était pas collée tout au bord droit (ex. iPhone SE : jusqu'à 20px hors écran).
     position:fixed + left/right ancrés à la fenêtre (pas au petit wrapper de la cloche, qui rendait
     un simple left/right en absolute inutilisable) garantit une marge de 14px des deux côtés quel
     que soit l'endroit où la cloche se trouve dans la topbar. */
  .notif-panel {
    position: fixed;
    top: calc(var(--topbar-height) + 8px);
    left: 14px;
    right: 14px;
    width: auto;
  }
}

@media (max-width: 480px) {
  /* Sous ce seuil, l'espace disponible (~270px après sidebar + marges) est inférieur
     aux minimums de colonne de ces grilles : on repasse en une seule colonne plutôt
     que de laisser le contenu déborder du conteneur. */
  .kpi-grid,
  .dashboard-grid,
  .detail-grid,
  .settings-lists-grid {
    grid-template-columns: 1fr;
  }

  /* Sur un téléphone, .topbar-user (thème + aide + notifs + compte) prenait à elle seule ~186px
     sur les ~275px disponibles, ne laissant qu'une barre de recherche d'à peine 80px de large.
     Resserre l'espacement (la zone tactile agrandie de .btn-icon::before, inset:-10px, reste bien
     assez grande même avec un espacement réduit) pour rendre la recherche réellement utilisable. */
  .topbar-user { gap: 6px; }
  .topbar-user .btn-icon { padding: 2px; }
}

/* ---------------------------------------------------------------------
   Dark mode (base prête, à étendre)
   --------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14161a;
    --color-surface: #1c1f26;
    --color-border: #2a2d36;
    --color-text: #f2f3f5;
    --color-text-muted: #9aa0ab;
    --color-primary-soft: #232244;
    --color-muted-soft: #23262e;
    --color-success-soft: #0f2a1c;
    --color-warning-soft: #2a1f0f;
    --color-info-soft: #10203a;
    --color-danger-soft: #2a1414;
  }
}

/* Thème choisi manuellement (bouton topbar) : l'emporte sur la préférence système ci-dessus grâce au sélecteur d'attribut, plus spécifique que ":root" seul. */
:root[data-theme="dark"] {
  --color-bg: #14161a;
  --color-surface: #1c1f26;
  --color-border: #2a2d36;
  --color-text: #f2f3f5;
  --color-text-muted: #9aa0ab;
  --color-primary-soft: #232244;
  --color-muted-soft: #23262e;
  --color-success-soft: #0f2a1c;
  --color-warning-soft: #2a1f0f;
  --color-info-soft: #10203a;
  --color-danger-soft: #2a1414;
}

:root[data-theme="light"] {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-border: #e6e8eb;
  --color-text: #1a1d24;
  --color-text-muted: #6b7280;
  --color-primary-soft: #eef2ff;
  --color-muted-soft: #f1f2f4;
  --color-success-soft: #ecfdf3;
  --color-warning-soft: #fff7ed;
  --color-info-soft: #eff6ff;
  --color-danger-soft: #fef2f2;
}

/* ---------------------------------------------------------------------
   Impression — n'imprime que le contenu marqué .print-area (notes de frais,
   fiche salarié, attestation de congé)
   --------------------------------------------------------------------- */

.print-header {
  margin-bottom: 20px;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 12px;
}

.print-header h1 { margin-bottom: 4px; }

.print-document h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: 20px 0 8px;
}

.print-attestation-text {
  line-height: 1.8;
  margin: 24px 0;
  font-size: 15px;
}

.print-signature {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 60px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.print-signature-line {
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
  min-width: 160px;
  text-align: center;
}

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 24px;
  }
}
