/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bs-primary: #1a4f8a;
  --bs-primary-rgb: 26, 79, 138;
}

/* ─── Global ─────────────────────────────────────────────────────────────── */
body {
  background-color: #f4f6fb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ─── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  background-color: #1a4f8a !important;
}

.navbar-brand {
  font-size: 1.1rem;
  letter-spacing: .02em;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  border-radius: .75rem;
}

.card-header {
  border-radius: .75rem .75rem 0 0 !important;
}

/* Bordure colorée à gauche pour les cartes de caisse */
.caisse-card {
  border-left: 4px solid #dee2e6 !important;
  border: 1px solid #e9ecef;
}

.border-start-success { border-left-color: #198754 !important; }
.border-start-warning { border-left-color: #ffc107 !important; }
.border-start-danger  { border-left-color: #dc3545 !important; }
.border-start-secondary { border-left-color: #6c757d !important; }

/* ─── Stat icons ─────────────────────────────────────────────────────────── */
.stat-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Amount boxes ───────────────────────────────────────────────────────── */
.amount-box {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
}

.amount-box .text-muted {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ─── Écart display ──────────────────────────────────────────────────────── */
.ecart-display {
  border: 2px solid #dee2e6;
  background: #f8f9fa;
  transition: all .2s ease;
}

.ecart-neutral {
  border-color: #dee2e6;
  background: #f8f9fa;
  color: #6c757d;
}

.ecart-ok {
  border-color: #198754;
  background: #d1e7dd;
  color: #0f5132;
}

.ecart-warn {
  border-color: #ffc107;
  background: #fff3cd;
  color: #664d03;
}

.ecart-danger {
  border-color: #dc3545;
  background: #f8d7da;
  color: #842029;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  color: #6c757d;
  border-bottom-width: 1px;
}

.table td { vertical-align: middle; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-control:focus,
.form-select:focus {
  border-color: #1a4f8a;
  box-shadow: 0 0 0 .2rem rgba(26, 79, 138, .2);
}

.form-label {
  font-size: .875rem;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  font-weight: 500;
  letter-spacing: .02em;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  background-color: #1a4f8a;
  border-color: #1a4f8a;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #153f6f;
  border-color: #153f6f;
}

.btn-outline-primary {
  color: #1a4f8a;
  border-color: #1a4f8a;
}

.btn-outline-primary:hover {
  background-color: #1a4f8a;
  border-color: #1a4f8a;
}

/* ─── Denominations (saisie espèces) ─────────────────────────────────────── */
.denom-row {
  border-bottom: 1px solid #f0f3f7;
  padding: .15rem 0;
  transition: background-color .15s ease;
}

.denom-row:last-child {
  border-bottom: none;
}

.denom-row:focus-within {
  background-color: #f1f6fb;
}

.denom-label {
  min-width: 48px;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
}

.denom-input {
  flex: 1 1 auto;
  min-width: 50px;
  max-width: 80px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.denom-soustotal {
  min-width: 80px;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
  color: #146c43;          /* vert un peu plus foncé pour le contraste */
}

/* ─── Suppression des flèches spinner sur input number ──────────────────── */
input[type=number].no-spin::-webkit-outer-spin-button,
input[type=number].no-spin::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ─── Tableau de bord : largeur réduite sur PC ───────────────────────────── */
.dashboard-wrap {
  max-width: 1200px;
}

.cat-mini {
  transition: transform .15s ease, box-shadow .15s ease;
  border-left: 3px solid #e0e6ee;
}
.cat-mini:hover {
  transform: translateY(-2px);
  border-left-color: #1a4f8a;
}

/* Tableau des journées du dashboard : lignes cliquables et aérées */
.journees-table tbody tr {
  transition: background-color .15s ease;
}
.journees-table tbody tr:hover {
  background-color: #f4f6fb;
}
.journees-table tbody td {
  padding-top: .75rem;
  padding-bottom: .75rem;
}

/* ─── Page journée — colonnes neutres avec accent discret ────────────────── */
.journee-col {
  border-top: 3px solid transparent !important;
}
.journee-col.accent-matin   { border-top-color: #b8c5d6 !important; }   /* slate clair */
.journee-col.accent-aprem   { border-top-color: #7a8eaa !important; }   /* slate moyen */
.journee-col.accent-journee { border-top-color: #1a4f8a !important; }   /* bleu marine */

.recap-box {
  background-color: #f4f6fb;
  border: 1px solid #e3e7ef;
}

/* ─── Calendrier planning ────────────────────────────────────────────────── */
.calendar-table {
  table-layout: fixed;
  margin-bottom: 0;
  border-collapse: separate !important;     /* espacement entre les cellules */
  border-spacing: 6px !important;           /* 6px de gap entre chaque jour */
}
.calendar-table thead th {
  background: transparent !important;
  border: none !important;
  padding: 4px 8px;
  text-align: center;
}
.planning-table { background: #eef2f7; padding: 4px; }

/* Chaque jour = une carte distincte avec ombre et coins arrondis */
.planning-cell {
  padding: 0 !important;
  vertical-align: top !important;
  height: 150px;
  position: relative;
  border: 1px solid #cbd2dc !important;
  border-radius: 8px !important;
  background-color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  overflow: hidden;                          /* pour que border-radius soit propre */
  transition: box-shadow .15s ease, transform .12s ease;
}
.planning-cell:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.planning-cell.out-of-month {
  background-color: #ebedf0 !important;
  opacity: .55;
  box-shadow: none;
}
.planning-cell.out-of-month .cell-half {
  background-color: #ebedf0 !important;
  cursor: not-allowed;
  border-bottom-color: #dde0e5 !important;
}
.planning-cell.out-of-month .cell-header {
  background-color: #dde0e5 !important;
  color: #a3a8b1;
}
.planning-cell.out-of-month .day-num {
  color: #a3a8b1 !important;
  font-weight: 400;
}
.planning-cell.out-of-month:hover { transform: none; box-shadow: none; }

.planning-cell.today {
  border-color: #1a4f8a !important;
  border-width: 2px !important;
  box-shadow: 0 0 0 3px rgba(26, 79, 138, .15), 0 2px 6px rgba(0,0,0,.08);
}
.planning-cell.today .day-num { color: #1a4f8a; font-weight: 700; }
.planning-cell.today .cell-header {
  background: #e7eff8 !important;
  border-bottom-color: #1a4f8a !important;
}

.planning-cell.weekend:not(.out-of-month) {
  background-color: #f6f9fc;
}
.planning-cell.weekend:not(.out-of-month) .cell-half {
  background: #f6f9fc;
}

.cell-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cell-header {
  padding: 2px 6px;
  border-bottom: 1px solid #ebeef3;
  background: #fafbfd;
  flex-shrink: 0;
  height: 22px;
}
.day-num {
  font-weight: 600;
  font-size: .85rem;
}
.btn-edit {
  background: transparent;
  border: none;
  padding: 0 4px;
  color: #94a3b8;
  font-size: .8rem;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
}
.btn-edit:hover { background: #e2e8f0; color: #1a4f8a; }

.cell-half {
  flex: 1;
  padding: 3px 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background-color .12s ease;
}
.cell-half.cell-matin {
  background: #fafbfd;
  border-bottom: 1px solid #e2e8f0;    /* trait fin et doux entre matin et aprem */
}
.cell-half.cell-aprem {
  background: #fafbfd;
}
.cell-half:hover:not(.disabled) {
  filter: brightness(.96);
}
.half-label {
  position: absolute;
  top: 2px;
  right: 6px;
  font-size: .62rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  pointer-events: none;
}
.half-content {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-content: flex-start;
}

/* Mode "compact" : 3 ou 4 salariés sur la même demi-journée
   → réduit badges + masque les horaires pour gagner de la place */
.half-content.crowded .emp-line {
  font-size: .72rem;
  padding: 1px 7px;
  margin-bottom: 2px;
}
.half-content.crowded .emp-line .emp-hours {
  display: none;
}

/* Mode "very-crowded" : 5+ salariés → encore plus compact */
.half-content.very-crowded .emp-line {
  font-size: .65rem;
  padding: 1px 5px;
  margin-bottom: 1px;
  font-weight: 600;
}

.emp-line {
  display: inline-block;
  font-size: .85rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
  line-height: 1.4;
}
/* Dans les cellules du planning : taille modérée + cliquable pour suppression */
.planning-cell .emp-line {
  font-size: .82rem;
  font-weight: 600;
  padding: 2px 9px;
  margin-bottom: 3px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  position: relative;
}
.planning-cell .emp-line:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,.15);
}
/* (suppression directe désactivée — le clic ouvre maintenant le modal détail) */
.planning-cell .emp-line .emp-hours {
  font-size: .65rem;
  font-weight: 500;
}
.emp-line.emp-full-day {
  font-weight: 700;
  padding: 2px 8px 2px 10px;
  position: relative;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.1);
}
.emp-line .full-day-tag,
.emp-line .emp-hours {
  display: inline-block;
  font-size: .68rem;
  font-weight: 500;
  margin-left: 4px;
  padding: 0 4px;
  background: rgba(0,0,0,.12);
  border-radius: 3px;
  vertical-align: 1px;
}

/* Statuts spéciaux : différenciation visuelle */
.emp-line.statut-conges     { box-shadow: inset 0 0 0 1px rgba(20,108,75,.4); }
.emp-line.statut-sans_solde { box-shadow: inset 0 0 0 1px rgba(108,117,125,.4); font-style: italic; }
.emp-line.statut-absent     { opacity: .65; text-decoration: line-through; }

/* Chips de statut (mode rapide) */
.status-chip {
  background: #e2e8f0;
  color: #475569;
  border: 2px solid transparent;
  padding: 3px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  font-size: .8rem;
  transition: all .12s;
}
.status-chip:hover { transform: translateY(-1px); }
.status-chip.active {
  background: #1a4f8a;
  color: white;
  border-color: #1a4f8a;
}

/* Magasin fermé (cellule) */
.planning-cell.closed {
  background: repeating-linear-gradient(
    -45deg, #f8fafc, #f8fafc 8px, #eef1f5 8px, #eef1f5 16px
  );
}
.closed-overlay {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #64748b;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background-color .12s ease;
}
.closed-overlay:hover {
  background-color: rgba(26, 79, 138, .06);
}

/* Chips employés en mode rapide */
.employee-chip {
  border: 2px solid transparent;
  background: #e2e8f0;
  color: #475569;
  padding: 4px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  transition: transform .12s ease, box-shadow .12s ease;
}
.employee-chip:hover { transform: translateY(-1px); }
.employee-chip.active {
  border-color: #1a4f8a;
  box-shadow: 0 0 0 3px rgba(26, 79, 138, 0.15);
  transform: scale(1.04);
}

@media (max-width: 768px) {
  .planning-cell { height: 100px; }
  .day-num { font-size: .75rem; }
  .emp-line { font-size: .62rem; padding: 1px 4px; }
}

/* ─── Indicateur auto-save (haut à droite, sous la navbar) ───────────────── */
.autosave-indicator {
  position: fixed;
  top: 4.5rem;
  right: 1rem;
  padding: .4rem .9rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  color: white;
  z-index: 2000;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.autosave-saving { background-color: #6c757d; }
.autosave-saved  { background-color: #198754; }
.autosave-error  { background-color: #dc3545; pointer-events: auto; }

/* ─── Tableau attentes/saisi/écart ───────────────────────────────────────── */
.attentes-table input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.attentes-table .shared-cat {
  background-color: #fafcff;
}

.attentes-table tbody tr:hover {
  background-color: #eef4fb;
}

.attentes-table .ecart-cell .badge {
  min-width: 78px;
  font-variant-numeric: tabular-nums;
}

/* ─── Mini-tableaux d'attentes (groupes Caisse / Loto N / PMU N…) ────────── */
.mini-attente {
  background: #ffffff;
  border-color: #e3e8ef !important;
  transition: box-shadow .15s ease;
}

.mini-attente:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.mini-attente .mini-attente-header {
  font-size: .82rem;
  letter-spacing: .02em;
}

.mini-attente .mini-attente-header i {
  font-size: .95rem;
}

.mini-attente .attentes-table thead th {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  font-weight: 600;
}

.mini-attente .attentes-table td {
  padding-top: .35rem;
  padding-bottom: .35rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Tableau attentes : largeur minimale par colonne pour préserver la lisibilité */
  .attentes-table { min-width: 580px; }
  .attentes-table input[type="number"] { font-size: .9rem; }
}

@media (max-width: 576px) {
  .container-fluid { padding-left: .75rem; padding-right: .75rem; }
  .stat-icon { width: 44px; height: 44px; }
  .denom-card { padding: .5rem !important; }
  .denom-card .fw-bold { font-size: .9rem; }
  .denom-card .form-control { font-size: .95rem; padding: .3rem .4rem; }
  /* Boutons plus grands pour le toucher */
  .btn { min-height: 38px; }
  /* Footer modaux : laisser respirer */
  .modal-footer { flex-wrap: wrap; gap: .5rem; }
  .modal-footer > * { flex: 1; }
  /* Cartes session : éviter overflow horizontal */
  h4.fw-bold { font-size: 1.15rem; }
  h5.fw-bold { font-size: 1.05rem; }
}

/* Empêcher le zoom auto sur input (iOS) en gardant police >= 16px */
@media (max-width: 576px) {
  input[type="number"], input[type="text"], input[type="date"], input[type="month"], textarea {
    font-size: 16px;
  }
}

/* ─── Tableau "mobile-stack" : transforme un table en cartes empilees ─────
   Utilise sur dashboard.html et journees_liste.html pour eviter le scroll
   horizontal sur smartphone. Chaque <td data-label="..."> devient une ligne
   "label / valeur" sous une carte par <tr>. */
@media (max-width: 767.98px) {
  table.mobile-stack,
  table.mobile-stack thead,
  table.mobile-stack tbody,
  table.mobile-stack tr,
  table.mobile-stack td,
  table.mobile-stack th {
    display: block;
    width: 100%;
  }
  /* On masque le thead (les labels sont injectes via data-label sur chaque td) */
  table.mobile-stack thead {
    display: none;
  }
  /* Chaque ligne devient une "carte" */
  table.mobile-stack tbody tr {
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    margin: .5rem .25rem;
    padding: .25rem 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
  }
  table.mobile-stack tbody tr:hover {
    background-color: #f8f9fa;
  }
  /* Pas de bordure inferieure sur les td (l'encadrement vient du tr) */
  table.mobile-stack tbody td {
    border: none;
    padding: .35rem .85rem;
    text-align: left !important;            /* override .text-end */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 2.25rem;
  }
  /* Label en gauche, valeur en droite : on pose le label en ::before */
  table.mobile-stack tbody td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6c757d;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    flex-shrink: 0;
  }
  /* Cellule d'action (le bouton ouvrir) : centree, sans label */
  table.mobile-stack tbody td.cell-action {
    justify-content: center;
    padding: .35rem .85rem .55rem;
  }
  table.mobile-stack tbody td.cell-action a {
    width: 100%;
  }
  /* Suppression du padding-start specifique a la 1ere colonne */
  table.mobile-stack tbody td.ps-3 {
    padding-left: .85rem;
  }
  table.mobile-stack tbody td.pe-3 {
    padding-right: .85rem;
  }
}

/* Neutralise le overflow-x du wrapper Bootstrap quand le tableau est en mobile-stack */
@media (max-width: 767.98px) {
  .table-responsive:has(table.mobile-stack) {
    overflow-x: visible;
  }
}

/* ─── Planning mobile : transforme le calendrier matrix en liste verticale ── */
@media (max-width: 767.98px) {
  .planning-table,
  .planning-table thead,
  .planning-table tbody,
  .planning-table tr {
    display: block;
    width: 100%;
  }
  /* En-tete des jours de la semaine inutile en liste */
  .planning-table thead {
    display: none;
  }
  /* Chaque "semaine" devient un simple flux vertical */
  .planning-table tbody tr {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
  }
  /* Chaque cellule = une carte jour pleine largeur */
  .planning-table td.planning-cell {
    display: block;
    width: 100%;
    height: auto !important;
    min-height: auto !important;
    border: 1px solid #dee2e6 !important;
    border-radius: .5rem;
    margin: .5rem 0;
    padding: .5rem .75rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    vertical-align: top;
  }
  /* On masque les jours hors-mois pour gagner de la place */
  .planning-table td.planning-cell.out-of-month {
    display: none;
  }
  /* Aujourd'hui : liseré bleu */
  .planning-table td.planning-cell.today {
    border-left-width: 4px !important;
    border-left-color: #1a4f8a !important;
  }
  /* Weekend : fond legerement teinte pour le reperer */
  .planning-table td.planning-cell.weekend {
    background: #fafbfd;
  }
  /* Journee fermee : grise */
  .planning-table td.planning-cell.closed {
    background: #f8f9fa;
    opacity: .9;
  }
  /* En-tete de la carte jour : chiffre + jour semaine + bouton edit */
  .planning-table .cell-header {
    padding-bottom: .25rem;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: .35rem;
  }
  .planning-table .day-num {
    font-size: 1.15rem;
    font-weight: 700;
  }
  /* Jour de la semaine en mobile (cache en desktop) */
  .planning-table .day-name-mobile {
    display: inline-block;
    font-size: .85rem;
    color: #6c757d;
    margin-left: .5rem;
    font-weight: 500;
  }
  /* Moities matin/aprem : cote a cote sur 2 colonnes en mobile */
  .planning-table .cell-content {
    display: block;
  }
  .planning-table .cell-half {
    padding: .35rem .5rem;
    min-height: auto;
    border-top: 1px solid #f0f2f5;
  }
  .planning-table .cell-half:first-of-type {
    border-top: none;
  }
  .planning-table .half-label {
    font-size: .72rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .2rem;
  }
  /* Plus de marge entre les badges salaries pour eviter le serrage */
  .planning-table .emp-line {
    display: block;
    margin: .2rem 0;
    padding: .25rem .45rem;
    font-size: .85rem;
  }
}

/* Le span "jour semaine" en mobile est cache en desktop */
.day-name-mobile {
  display: none;
}
