/* =====================================================================
   FOURNIL — feuille de style
   Palette : croûte (barre latérale), blé (accent), farine (fond),
             levain (positif), four (négatif)
   ===================================================================== */
:root {
  --croute: #3A2618;
  --croute-2: #4A3222;
  --ble: #D9A441;
  --ble-pale: #F6E7C4;
  --farine: #F5F5F1;
  --surface: #FFFFFF;
  --pierre: #E3E0D8;
  --encre: #2B2722;
  --encre-2: #6B645B;
  --levain: #2F7A55;
  --four: #B6402F;
  --ambre: #B7791F;

  --bs-body-font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --bs-body-color: var(--encre);
  --bs-body-bg: var(--farine);
  --bs-border-color: var(--pierre);
  --bs-primary: var(--croute);
  --bs-primary-rgb: 58, 38, 24;
  --bs-link-color: #7A4E1D;
  --bs-link-hover-color: var(--croute);
  --bs-focus-ring-color: rgba(217, 164, 65, .45);
}

body { font-size: .9375rem; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .display-num { font-family: "Bricolage Grotesque", "Manrope", system-ui, sans-serif; letter-spacing: -.01em; }
.tabular, td, .kpi-value { font-variant-numeric: tabular-nums; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.5rem; flex: 1; max-width: 1400px; width: 100%; }
.footer { padding: .75rem 1.5rem; font-size: .75rem; color: var(--encre-2); }

/* ---------- Barre latérale ---------- */
.sidebar { background: var(--croute); color: #EFE6DA; width: 248px; display: flex; flex-direction: column; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
}
.sidebar.offcanvas-lg { --bs-offcanvas-bg: var(--croute); --bs-offcanvas-width: 260px; }
/* Bootstrap force un fond transparent sur .offcanvas-lg au-delà de 992px : on rétablit le fond du menu */
@media (min-width: 992px) {
  .sidebar.offcanvas-lg { background-color: var(--croute) !important; }
}
/* Texte net sur fond sombre */
.sidebar { -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--ble); color: var(--croute);
  display: grid; place-items: center; font-size: 1.15rem; }
.brand-name { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 1.2rem; color: #fff; line-height: 1.1; }
.brand-sub { font-size: .78rem; color: #DCCDB9; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; }
.nav-group { font-size: .75rem; color: #C4B29C; padding: 1rem .75rem .35rem; font-weight: 700; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .75rem; border-radius: 8px;
  color: #F6EFE5; font-weight: 600; font-size: .92rem; }
.sidebar .nav-link i { font-size: 1.05rem; color: var(--ble); width: 1.1rem; }
.sidebar .nav-link:hover { background: var(--croute-2); color: #fff; }
.sidebar .nav-link.active { background: var(--ble); color: var(--croute); font-weight: 700; }
.sidebar .nav-link.active i { color: var(--croute); }
.sidebar .nav-link:focus-visible { outline: 2px solid var(--ble); outline-offset: 2px; }
.sidebar-user { display: flex; align-items: center; gap: .6rem; padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--croute-2); color: var(--ble);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.user-name { font-weight: 600; font-size: .85rem; color: #fff; }
.user-role { font-size: .75rem; color: #DCCDB9; }
.icon-link-side { color: #DCCDB9; padding: .25rem; font-size: 1.05rem; }
.icon-link-side:hover { color: var(--ble); }
.min-w-0 { min-width: 0; }

/* ---------- Barre du haut ---------- */
.topbar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--pierre); background: var(--surface); }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.topbar-date { color: var(--encre-2); font-size: .85rem; }
.btn-icon { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; border-radius: 8px;
  border: 1px solid var(--pierre); background: var(--surface); color: var(--encre); }
.btn-icon:hover { background: var(--farine); }

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--pierre); border-radius: 12px; }
.panel-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--pierre); }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-body { padding: 1.25rem; }
.panel-hint { color: var(--encre-2); font-size: .85rem; }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--pierre); border-radius: 12px; padding: 1rem 1.15rem; }
.kpi-label { color: var(--encre-2); font-size: .82rem; font-weight: 500; }
.kpi-value { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; }
.kpi-sub { font-size: .78rem; color: var(--encre-2); margin-top: .15rem; }
.text-pos { color: var(--levain) !important; }
.text-neg { color: var(--four) !important; }
.text-muted-2 { color: var(--encre-2); }

/* ---------- Fournée du jour (élément signature du tableau de bord) ---------- */
.fournee { background: var(--croute); color: #F3EADF; border-radius: 16px; padding: 1.5rem 1.75rem; position: relative; overflow: hidden; }
.fournee::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,164,65,.35), rgba(217,164,65,0) 70%); pointer-events: none; }
.fournee-titre { color: #C9B8A3; font-size: .9rem; }
.fournee-chiffre { font-family: "Bricolage Grotesque", sans-serif; font-size: clamp(2.6rem, 6vw, 3.6rem); font-weight: 700; color: #fff; line-height: 1; }
.fournee-unite { font-size: 1rem; color: var(--ble); font-weight: 600; margin-left: .35rem; }
.fournee-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-top: 1.25rem; position: relative; z-index: 1; }
.fournee-grid .lbl { font-size: .78rem; color: #C9B8A3; }
.fournee-grid .val { font-weight: 700; font-size: 1.15rem; color: #fff; font-variant-numeric: tabular-nums; }
.jauge { height: 10px; background: rgba(255,255,255,.12); border-radius: 99px; margin-top: 1.1rem; position: relative; z-index: 1; overflow: hidden; }
.jauge > span { display: block; height: 100%; background: var(--ble); border-radius: 99px; transition: width .6s ease; }
.fournee .btn-ble { background: var(--ble); color: var(--croute); font-weight: 700; border: 0; }
.fournee .btn-ble:hover { background: #E6B65A; }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .6rem .85rem; border-bottom-color: var(--pierre); }
.table thead th { font-size: .78rem; color: var(--encre-2); font-weight: 600; background: #FAF9F6; white-space: nowrap; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #FAF9F6; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #FBF6EA; }
.table-grille { font-size: .82rem; }
.table-grille td, .table-grille th { padding: .4rem .55rem !important; white-space: nowrap; }
.table-grille .col-fixe { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table-grille thead .col-fixe, .table-grille tfoot .col-fixe { background: #FAF9F6; }
.row-weekend td { background: #FCFBF8; }
.num { text-align: right; }

/* ---------- Formulaires ---------- */
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select { border-color: #D6D1C6; border-radius: 8px; }
.form-control:focus, .form-select:focus { border-color: var(--ble); box-shadow: 0 0 0 .2rem rgba(217,164,65,.3); }
.form-control-lg.num-input { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; }
.btn-primary { --bs-btn-bg: var(--croute); --bs-btn-border-color: var(--croute); --bs-btn-hover-bg: var(--croute-2);
  --bs-btn-hover-border-color: var(--croute-2); --bs-btn-active-bg: #2C1C11; --bs-btn-disabled-bg: var(--croute); font-weight: 600; }
.btn-outline-primary { --bs-btn-color: var(--croute); --bs-btn-border-color: #CDBFAE; --bs-btn-hover-bg: var(--croute);
  --bs-btn-hover-border-color: var(--croute); --bs-btn-active-bg: var(--croute); font-weight: 600; }
.btn { border-radius: 8px; }
.btn-link-danger { color: var(--four); background: none; border: 0; padding: .15rem .35rem; }
.btn-link-danger:hover { color: #8E2F22; }
.btn-link-plain { color: var(--encre-2); background: none; border: 0; padding: .15rem .35rem; }
.btn-link-plain:hover { color: var(--encre); }

/* Aperçu de calcul en direct */
.apercu { background: #FBF6EA; border: 1px dashed #E2C98F; border-radius: 10px; padding: 1rem; }
.apercu-ligne { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; font-size: .88rem; }
.apercu-ligne.manque { color: var(--four); font-weight: 600; }
.apercu-total { border-top: 1px solid #E2C98F; margin-top: .4rem; padding-top: .5rem; font-weight: 700; }

/* ---------- Badges ---------- */
.badge-dot { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; }
.badge-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--levain); }
.badge-warning { color: var(--ambre); }
.badge-danger { color: var(--four); }
.tag { display: inline-block; padding: .1rem .5rem; border-radius: 6px; font-size: .74rem; font-weight: 600; background: #F0ECE4; color: var(--encre-2); }
.tag-fixe { background: #EAF1F7; color: #2D5878; }
.tag-divers { background: #F4EDE0; color: #7A5A22; }
.tag-variable { background: #EEF3EC; color: #3F6B3A; }
.tag-auto { background: #F0ECE4; color: var(--encre-2); }

.statut-select[data-statut="P"]  { border-color: #9CC7AF; background-color: #F1F8F4; }
.statut-select[data-statut="CP"] { border-color: #9FB9D6; background-color: #F1F5FA; }
.statut-select[data-statut="A"]  { border-color: #E3A99F; background-color: #FCF2F0; }
.statut-select[data-statut="R"]  { border-color: #D6D1C6; background-color: #F7F6F2; }

/* ---------- Navigation par mois ---------- */
.month-nav { display: inline-flex; align-items: center; gap: .5rem; }
.month-label { font-weight: 700; min-width: 9.5rem; text-align: center; }

/* ---------- Connexion ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--farine); }
@media (min-width: 900px) { .login-page { grid-template-columns: 1.1fr 1fr; } }
.login-side { background: var(--croute); color: #F3EADF; padding: 3rem; display: none; flex-direction: column; justify-content: space-between; }
@media (min-width: 900px) { .login-side { display: flex; } }
.login-side h1 { font-size: clamp(2.2rem, 4vw, 3.2rem); font-weight: 700; color: #fff; line-height: 1.05; max-width: 14ch; }
.login-side p { color: #C9B8A3; max-width: 40ch; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem 1.25rem; }
.login-card { width: 100%; max-width: 380px; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--encre-2); }
.empty i { font-size: 1.8rem; display: block; margin-bottom: .5rem; color: #C8BBA8; }
.modal-content { border-radius: 14px; border: 0; }
.alert { border-radius: 10px; }
.nav-tabs .nav-link { color: var(--encre-2); font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--croute); border-bottom-color: var(--surface); }
.chart-box { position: relative; height: 280px; }

@media (max-width: 575.98px) {
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
  .panel-body { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .sidebar, .topbar, .footer, .no-print, .btn, .month-nav .btn { display: none !important; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; }
  body { background: #fff; font-size: 11px; }
  .table-grille { font-size: 9px; }
}
