/* ============================================================
   Planning PMU — habillage général
   Refonte présentation (sept. 2026). Aucune logique modifiée :
   uniquement typographie, couleurs, espacements, composants.
   ============================================================ */

:root {
  /* palette */
  --pmu-bg:        #f5f6f7;
  --pmu-surface:   #ffffff;
  --pmu-surface-2: #f0f2f3;
  --pmu-ink:       #1f2530;
  --pmu-ink-soft:  #5a6472;
  --pmu-ink-faint: #8a94a2;
  --pmu-border:    #e3e6ea;
  --pmu-border-strong: #d4d9df;
  --pmu-brand:     #0f6b7a;
  --pmu-brand-dark:#0b515d;
  --pmu-brand-soft:#e4f0f2;
  --pmu-focus:     rgba(15, 107, 122, .25);
  --pmu-radius:    10px;
  --pmu-radius-sm: 7px;
  --pmu-shadow:    0 1px 2px rgba(20, 26, 38, .04), 0 6px 18px -8px rgba(20, 26, 38, .12);
  --pmu-shadow-sm: 0 1px 2px rgba(20, 26, 38, .06);
  --pmu-navh:      62px;

  /* overrides Bootstrap 5.3 (custom properties runtime) */
  --bs-body-font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bs-body-font-size: 0.95rem;
  --bs-body-color: var(--pmu-ink);
  --bs-body-bg: var(--pmu-bg);
  --bs-border-color: var(--pmu-border);
  --bs-border-radius: var(--pmu-radius-sm);
  --bs-border-radius-lg: var(--pmu-radius);
  --bs-border-radius-sm: 5px;
  --bs-link-color: var(--pmu-brand);
  --bs-link-hover-color: var(--pmu-brand-dark);
  --bs-primary: var(--pmu-brand);
  --bs-primary-rgb: 15, 107, 122;
  --bs-emphasis-color: var(--pmu-ink);
  --bs-secondary-color: var(--pmu-ink-soft);
  --bs-tertiary-bg: var(--pmu-surface-2);
}

/* ---------- base ---------- */
body {
  padding-top: var(--pmu-navh);
  background: var(--pmu-bg);
  color: var(--pmu-ink);
  font-feature-settings: "cv05", "ss01";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
.container { padding-top: 1.6rem; padding-bottom: 3rem; }

h1, h2, h3, h4, h5 { color: var(--pmu-ink); font-weight: 650; letter-spacing: -0.018em; }

/* titre de page — chaque écran ouvre sur un <h2> */
h2 {
  font-size: 1.5rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--pmu-border);
  display: flex; align-items: center; gap: .55rem;
}
h2::before {
  content: "";
  width: 4px; height: 1.05em;
  background: var(--pmu-brand);
  border-radius: 2px;
  flex: 0 0 auto;
}
h3 { font-size: 1.12rem; margin-top: 1.8rem; }
.text-muted { color: var(--pmu-ink-soft) !important; }
a { text-underline-offset: 2px; }

hr { border-color: var(--pmu-border); opacity: 1; }

/* ---------- navbar ---------- */
.navbar {
  --bs-navbar-padding-y: 0;
  min-height: var(--pmu-navh);
  background: var(--pmu-surface) !important;
  border-bottom: 1px solid var(--pmu-border);
  box-shadow: 0 1px 10px -4px rgba(20, 26, 38, .12);
  backdrop-filter: saturate(1.1);
}
.navbar .container-fluid { padding-inline: clamp(14px, 3vw, 28px); }
.navbar-brand {
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em;
  color: var(--pmu-brand) !important;
  padding-block: 0.9rem;
  display: inline-flex; align-items: center;
}
.navbar-brand .brand-mark {
  margin-right: .45rem; font-size: 1.15rem;
  filter: saturate(.85);
}
.navbar-nav { align-items: center; gap: .1rem; }
.navbar .nav-link {
  color: var(--pmu-ink-soft) !important;
  font-weight: 500; font-size: .9rem;
  padding: .5rem .7rem !important;
  border-radius: var(--pmu-radius-sm);
  transition: background-color .12s, color .12s;
}
.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: var(--pmu-brand) !important;
  background: var(--pmu-brand-soft);
}
.navbar .nav-link.dropdown-toggle::after { margin-left: .4em; opacity: .55; }
.navbar .dropdown-toggle.btn {
  border-color: var(--pmu-border-strong);
  color: var(--pmu-brand);
}

/* dropdown menus */
.dropdown-menu {
  border: 1px solid var(--pmu-border);
  border-radius: var(--pmu-radius);
  box-shadow: var(--pmu-shadow);
  padding: .35rem;
  font-size: .9rem;
  margin-top: .35rem !important;
}
.dropdown-item {
  border-radius: var(--pmu-radius-sm);
  padding: .5rem .7rem;
  color: var(--pmu-ink);
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--pmu-brand-soft);
  color: var(--pmu-brand-dark);
}
.dropdown-divider { border-color: var(--pmu-border); margin: .35rem .2rem; }

/* ---------- cards ---------- */
.card {
  border: 1px solid var(--pmu-border);
  border-radius: var(--pmu-radius);
  box-shadow: var(--pmu-shadow-sm);
  background: var(--pmu-surface);
}
.card + .card { margin-top: 1rem; }
.card-header {
  background: var(--pmu-surface);
  border-bottom: 1px solid var(--pmu-border);
  font-weight: 600; font-size: .95rem;
  color: var(--pmu-ink);
  padding: .85rem 1.1rem;
}
.card-body { padding: 1.1rem; }

/* ---------- buttons ---------- */
.btn {
  --bs-btn-border-radius: var(--pmu-radius-sm);
  font-weight: 550;
  letter-spacing: -0.005em;
}
.btn-primary {
  --bs-btn-bg: var(--pmu-brand);
  --bs-btn-border-color: var(--pmu-brand);
  --bs-btn-hover-bg: var(--pmu-brand-dark);
  --bs-btn-hover-border-color: var(--pmu-brand-dark);
  --bs-btn-active-bg: var(--pmu-brand-dark);
  --bs-btn-active-border-color: var(--pmu-brand-dark);
  --bs-btn-disabled-bg: var(--pmu-brand);
  --bs-btn-disabled-border-color: var(--pmu-brand);
  box-shadow: 0 1px 2px rgba(11, 81, 93, .25);
}
.btn-outline-primary {
  --bs-btn-color: var(--pmu-brand);
  --bs-btn-border-color: var(--pmu-brand);
  --bs-btn-hover-bg: var(--pmu-brand);
  --bs-btn-hover-border-color: var(--pmu-brand);
  --bs-btn-active-bg: var(--pmu-brand-dark);
}
.btn-outline-secondary {
  --bs-btn-color: var(--pmu-ink-soft);
  --bs-btn-border-color: var(--pmu-border-strong);
  --bs-btn-hover-bg: var(--pmu-surface-2);
  --bs-btn-hover-color: var(--pmu-ink);
  --bs-btn-hover-border-color: var(--pmu-border-strong);
  --bs-btn-active-bg: var(--pmu-surface-2);
  --bs-btn-active-color: var(--pmu-ink);
}
.btn-link { text-decoration: none; }
.btn-link:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.form-control, .form-select {
  border-color: var(--pmu-border-strong);
  border-radius: var(--pmu-radius-sm);
  color: var(--pmu-ink);
}
.form-control:focus, .form-select:focus {
  border-color: var(--pmu-brand);
  box-shadow: 0 0 0 3px var(--pmu-focus);
}
.form-label { font-weight: 550; font-size: .85rem; color: var(--pmu-ink-soft); margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--pmu-brand); border-color: var(--pmu-brand); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--pmu-focus); border-color: var(--pmu-brand); }
.input-group-text { background: var(--pmu-surface-2); border-color: var(--pmu-border-strong); color: var(--pmu-ink-soft); }

/* Select2 accordé au thème */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  border-color: var(--pmu-border-strong) !important;
  border-radius: var(--pmu-radius-sm) !important;
  min-height: 38px;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; padding-left: .75rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--pmu-brand) !important;
  box-shadow: 0 0 0 3px var(--pmu-focus);
}
.select2-dropdown { border-color: var(--pmu-border-strong); border-radius: var(--pmu-radius-sm); box-shadow: var(--pmu-shadow); }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--pmu-brand); }

/* ---------- tables ---------- */
.table {
  --bs-table-border-color: var(--pmu-border);
  --bs-table-color: var(--pmu-ink);
  --bs-table-hover-bg: var(--pmu-brand-soft);
  --bs-table-striped-bg: var(--pmu-surface-2);
  margin-bottom: 1rem;
  background: var(--pmu-surface);
}
.table > :not(caption) > * > * { padding: .55rem .7rem; }
.table.table-sm > :not(caption) > * > * { padding: .38rem .5rem; }
.table thead th {
  font-weight: 600;
  color: var(--pmu-ink);
  background: var(--pmu-surface-2);
  border-bottom: 1px solid var(--pmu-border-strong);
}
/* libellés d'en-tête soignés uniquement sur les tableaux non denses */
.table:not(.table-sm) thead th {
  font-size: .78rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--pmu-ink-soft);
  white-space: nowrap;
}
/* pas d'`overflow: hidden` ici : ça casserait `position: sticky` sur les
   en-têtes. L'arrondi est porté par le conteneur (.table-container) le cas échéant. */
.table-bordered { border: 1px solid var(--pmu-border); border-radius: var(--pmu-radius); }
.table-bordered > :not(caption) > * > * { border-color: var(--pmu-border); }

/* en-têtes de site du planning : teal plutôt que gris foncé */
thead th.bg-secondary,
.table thead th.bg-secondary,
th.bg-secondary.text-white {
  background: var(--pmu-brand) !important;
  color: #fff !important;
  text-transform: none;
  font-size: .82rem;
  letter-spacing: -0.005em;
  border-color: var(--pmu-brand-dark) !important;
}
thead th.bg-light, td.bg-light, .table .bg-light {
  background: var(--pmu-surface-2) !important;
}

/* ---------- alerts / flash ---------- */
.alert {
  border: 1px solid var(--pmu-border);
  border-left-width: 4px;
  border-radius: var(--pmu-radius-sm);
  box-shadow: var(--pmu-shadow-sm);
  font-size: .92rem;
}
.alert-success { border-left-color: #2f8f5b; background: #ecf6f0; color: #1c5a39; }
.alert-danger  { border-left-color: #c0392b; background: #fbecea; color: #8a2b21; }
.alert-warning { border-left-color: #b7791f; background: #fcf3e3; color: #7c5211; }
.alert-info    { border-left-color: var(--pmu-brand); background: var(--pmu-brand-soft); color: var(--pmu-brand-dark); }

/* ---------- badges ---------- */
.badge {
  font-weight: 600;
  letter-spacing: .01em;
  border-radius: 5px;
  padding: .32em .55em;
}
.text-bg-secondary { background: var(--pmu-surface-2) !important; color: var(--pmu-ink-soft) !important; }
.text-bg-light     { background: var(--pmu-surface-2) !important; color: var(--pmu-ink-soft) !important; }
.badge.bg-primary, .text-bg-primary { background: var(--pmu-brand) !important; }

/* ---------- DataTables ---------- */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--pmu-border-strong);
  border-radius: var(--pmu-radius-sm);
  padding: .3rem .55rem;
}
.dataTables_wrapper .dataTables_filter input:focus { outline: none; border-color: var(--pmu-brand); box-shadow: 0 0 0 3px var(--pmu-focus); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--pmu-radius-sm) !important;
  border: 1px solid transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--pmu-brand) !important; color: #fff !important; border-color: var(--pmu-brand) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--pmu-brand-soft) !important; color: var(--pmu-brand-dark) !important; border-color: var(--pmu-border) !important;
}
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length { color: var(--pmu-ink-soft); font-size: .85rem; }
table.dataTable thead .sorting::after, table.dataTable thead .sorting::before { opacity: .3; }

/* ============================================================
   Fonctionnel (inchangé dans le comportement, couleurs accordées)
   ============================================================ */

/* --- planning : lignes / colonnes repères --- */
.weekend-row { background-color: #e9edf2 !important; }
.nuit-cell   { background-color: #dbe7fa !important; }
.date-cell   { background-color: #d7ece6 !important; font-weight: 600; color: var(--pmu-ink); }

table.dataTable tbody tr.highlighted td {
  background-color: #ffe8a8 !important;
  font-weight: 700;
}

.indispo-x  { background-color: #3a3f47 !important; color: #3a3f47 !important; }
.indispo-ca { background-color: #fcd669 !important; color: #6b4e07 !important; }

/* --- en-têtes / colonnes figées --- */
.sticky-top { position: sticky; top: 0; z-index: 2; background-color: var(--pmu-surface); }
.sticky-left { position: sticky; left: 0; z-index: 1; background-color: var(--pmu-surface); }
.thead th.sticky-left { z-index: 3; }

.sticky-header th {
  position: sticky; top: 0; z-index: 2;
  background-color: var(--pmu-surface);
  box-shadow: 0 2px 3px rgba(20, 26, 38, .08);
}

.stats-table th, .stats-table td {
  white-space: nowrap;
  padding: 4px 8px;
  font-size: 0.88rem;
}
.stats-table th.sticky-col,
.stats-table td.sticky-col {
  position: sticky; left: 0; background-color: var(--pmu-surface); z-index: 1;
}

.table.dataTable thead th {
  background-color: var(--pmu-surface-2);
  position: sticky; top: 0; z-index: 10;
}

.select2-container { width: 100% !important; max-width: 300px !important; }

thead tr:nth-child(1) th {
  background-color: var(--pmu-surface-2);
  position: sticky; top: 0; z-index: 2;
}
thead tr:nth-child(2) th {
  position: sticky; top: 38px; z-index: 1;
  background-color: var(--pmu-surface);
}
.hidden-button { display: none !important; }
.select-medecin { min-width: 200px; max-width: 300px; }

/* --- matrice de compétences --- */
.competences-table { border-collapse: collapse; width: max-content; }
.competences-table th,
.competences-table td {
  border: 1px solid var(--pmu-border);
  padding: 0.4rem;
  text-align: center;
  white-space: nowrap;
}
.competences-table thead th {
  position: sticky; top: 0; background: var(--pmu-surface-2); z-index: 3;
}
.competences-table th:first-child,
.competences-table td:first-child {
  position: sticky; left: 0; background: var(--pmu-surface); z-index: 2;
}
.competences-table thead th:first-child { z-index: 4; background: var(--pmu-surface-2); }

/* ---------- conteneur de tableau défilant : en-têtes de LIGNE et de COLONNE
   toujours visibles. Enrouler n'importe quel grand tableau dans
   <div class="table-container"> ... </div> pour l'obtenir. ---------- */
.table-container {
  overflow: auto;
  max-height: 78vh;
  border: 1px solid var(--pmu-border);
  border-radius: var(--pmu-radius);
}
/* le clip `overflow:hidden` de .table-bordered casse `position: sticky` :
   dans un conteneur défilant, c'est le conteneur qui porte bord + arrondi. */
.table-container > table,
.table-container > form > table,
.table-container table.table-bordered {
  overflow: visible;
  border-radius: 0;
  margin-bottom: 0;
}
/* en-tête de colonnes collé en haut */
.table-container thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--pmu-surface-2);
}
.table-container thead tr:nth-child(2) th { top: 2.4rem; z-index: 2; }
/* première colonne (intitulés de ligne) collée à gauche */
.table-container tbody th:first-child,
.table-container tbody td:first-child,
.table-container tfoot th:first-child,
.table-container tfoot td:first-child,
.table-container thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--pmu-surface);
}
/* coin haut-gauche : au-dessus des deux */
.table-container thead th:first-child { z-index: 4; background: var(--pmu-surface-2); }

table.sticky-table { border-collapse: collapse; width: 100%; }
.sticky-table th,
.sticky-table td {
  white-space: nowrap;
  padding: 8px;
  border: 1px solid var(--pmu-border);
  text-align: center;
}
.sticky-table thead th {
  position: sticky; top: 0; background-color: var(--pmu-surface-2); z-index: 10;
}
.sticky-table tbody th {
  position: sticky; left: 0; background-color: var(--pmu-surface-2); z-index: 5;
}
.sticky-table thead th:first-child { left: 0; z-index: 11; }

/* --- Retouche manuelle des simulations (sélecteur médecin partagé) --- */
#retouche-picker {
  /* > .prev-shell.fs-active (z-index 1200, generation_preview.html) : le
     sélecteur doit rester au-dessus même en plein écran, sinon il s'ouvre
     bien mais reste caché derrière le fond opaque du mode plein écran. */
  position: fixed; z-index: 1300; width: 340px; max-height: 60vh; overflow: auto;
  background: var(--pmu-surface); border: 1px solid var(--pmu-border-strong);
  border-radius: var(--pmu-radius); box-shadow: var(--pmu-shadow);
  display: none; font-size: .82rem;
}
#retouche-picker header {
  padding: 8px 12px; background: var(--pmu-surface-2); border-bottom: 1px solid var(--pmu-border);
  font-weight: 600; position: sticky; top: 0;
}
#retouche-picker input {
  width: 100%; border: 0; border-bottom: 1px solid var(--pmu-border); padding: 8px 12px; outline: none;
}
#retouche-picker .sec {
  padding: 4px 12px; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em; border-top: 1px solid var(--pmu-border);
}
#retouche-picker .sec.s-ok   { background: #e4f2ea; color: #1c5a39; }
#retouche-picker .sec.s-forc { background: #fcf3e3; color: #7c5211; }
#retouche-picker .sec.s-blk  { background: #fbecea; color: #8a2b21; }
#retouche-picker .opt { padding: 5px 12px; cursor: pointer; }
#retouche-picker .opt .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
#retouche-picker .opt .opt-right { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
#retouche-picker .opt .fiche-link { text-decoration: none; font-size: .9rem; opacity: .55; }
#retouche-picker .opt .fiche-link:hover { opacity: 1; }
#retouche-picker .opt .motifs { font-size: .72rem; color: var(--pmu-ink-soft); margin-top: 1px; }
#retouche-picker .opt:hover { background: var(--pmu-brand-soft); }
#retouche-picker .opt.g-forcable { color: #7c5211; }
#retouche-picker .opt.g-bloque { color: #8a2b21; cursor: not-allowed; }
#retouche-picker .opt.g-bloque:hover { background: #fbebec; }
#retouche-picker .opt .tag {
  font-size: .68rem; border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; white-space: nowrap;
}
#retouche-picker .opt .tag.q { color: var(--pmu-brand); }
#retouche-picker .opt.vider { color: var(--pmu-ink-soft); font-style: italic; border-bottom: 1px dashed var(--pmu-border); }

/* ---------- page Génération : en-tête + cartes ---------- */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.page-head h2 { margin-bottom: .4rem; }
.page-head .periode-picker {
  display: flex; align-items: center; gap: .55rem;
  flex: 0 0 auto;
}
.page-head .periode-picker .form-select { min-width: 260px; }

.card-icon { margin-right: .4rem; filter: saturate(.9); }

/* grille de formulaire plus aérée (remplace l'ancien row-cols-lg-auto) */
.gen-form .form-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: .3rem;
}

/* carte « zone dangereuse » : se distingue au premier coup d'œil */
.card-danger {
  border-color: #e7b3ac;
  background: linear-gradient(180deg, #fdf4f3, var(--pmu-surface) 4.5rem);
}
.card-danger .card-header {
  background: #fbecea;
  border-bottom-color: #f0d2ce;
  color: #8a2b21;
}
