@import url('https://fonts.googleapis.com/css2?family=Lora:wght@600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --noir: #12100c;
  --or: #c9a227;
  --or-clair: #e8c468;
  --vert: #163b2c;
  --vert-clair: #2d6a4f;
  --ivoire: #f6f1e4;
  --charbon: #2a251c;
  --gris-texte: #6b6353;
  --fond-clair: #fbf8f0;
  --rouge: #b23a3a;
}

html, body { overflow-x: hidden; max-width: 100%; }

body.dashboard-body {
  font-family: 'Poppins', sans-serif;
  background: var(--fond-clair);
  color: var(--charbon);
  min-height: 100vh;
}
body.dashboard-body a { text-decoration: none; color: inherit; }

.d-layout { display: flex; min-height: 100vh; }

.d-sidebar {
  width: 250px; flex-shrink: 0; background: var(--noir); color: #cfc8b4;
  padding: 1.2rem 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.d-sidebar .d-logo { display:flex; align-items:center; gap:10px; margin-bottom: 1.6rem; padding: 0 0.4rem; }
.d-sidebar .d-logo img { height: 34px; }
.d-sidebar .d-logo span { font-family: 'Lora', serif; font-weight: 700; color: var(--or-clair); font-size: 1rem; }
.d-sidebar-close { margin-left: auto; background: none; border: none; color: #cfc8b4; font-size: 1.6rem; line-height: 1; padding: 0 0.3rem; }
.d-sidebar .d-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1.5px; color: #7a7360; margin: 1.1rem 0.6rem 0.4rem; }
.d-sidebar a.d-link {
  display: flex; align-items: center; gap: 10px; padding: 0.55rem 0.7rem; border-radius: 8px;
  color: #cfc8b4; font-size: 0.87rem; font-weight: 500; margin-bottom: 2px;
}
.d-sidebar a.d-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.d-sidebar a.d-link.actif { background: var(--vert); color: #fff; }
.d-sidebar button.d-link-bouton {
  display: flex; align-items: center; gap: 10px; padding: 0.55rem 0.7rem; border-radius: 8px;
  color: #cfc8b4; font-size: 0.87rem; font-weight: 500; margin-bottom: 2px;
  background: none; border: none; width: 100%; text-align: left; cursor: pointer;
}
.d-sidebar button.d-link-bouton:hover { background: rgba(255,255,255,0.06); color: #fff; }
.d-sidebar .d-user { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 1rem; padding-top: 1rem; font-size: 0.8rem; }
.d-sidebar .d-user-link { color: #cfc8b4; display: block; }
.d-sidebar .d-user .du-role { color: #a79f8a; font-size: 0.72rem; }

.d-main { flex: 1; padding: 1.6rem 2rem; min-width: 0; }

/* ==========================================================
   Colonne de gauche figée, seul le centre defile — desktop.
   Au-dessus de 700px (le mobile garde son propre systeme avec
   la barre du bas et le sidebar en panneau coulissant).
   ========================================================== */
@media (min-width: 701px) {
  html, body.dashboard-body { height: 100%; overflow: hidden; }
  .d-layout { height: 100vh; min-height: 0; }
  .d-sidebar { position: static; height: 100vh; overflow-y: auto; }
  .d-main { height: 100vh; overflow-y: auto; }
}
.d-topbar { display:flex; justify-content: space-between; align-items:center; margin-bottom: 1.6rem; flex-wrap: wrap; gap: 1rem;}
.d-topbar h1 { font-family: 'Lora', serif; font-size: 1.5rem; margin: 0; color: var(--noir); }
.d-topbar .d-sous-titre { font-size: 0.82rem; color: var(--gris-texte); margin-top: 0.2rem; }

.d-kpi { background: #fff; border: 1px solid rgba(42,37,28,0.08); border-radius: 12px; padding: 1.1rem 1.3rem; box-shadow: 0 2px 8px rgba(18,16,12,0.05); height: 100%; }
.d-kpi .dk-valeur { font-family: 'Lora', serif; font-weight: 700; font-size: 1.6rem; color: var(--or); }
.d-kpi .dk-label { font-size: 0.74rem; color: var(--gris-texte); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.2rem; }

.d-card { background: #fff; border: 1px solid rgba(42,37,28,0.08); border-radius: 12px; padding: 1.2rem 1.3rem; box-shadow: 0 2px 8px rgba(18,16,12,0.05); margin-bottom: 1.3rem; }
.d-card h2 { font-family: 'Lora', serif; font-size: 1.1rem; margin-bottom: 0.9rem; }

.table-brand thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gris-texte); border-bottom: 1px solid rgba(42,37,28,0.1); font-weight: 600; }
.table-brand td { vertical-align: middle; font-size: 0.87rem; border-bottom: 1px solid rgba(42,37,28,0.06); }

.badge-brand { font-size: 0.7rem; padding: 0.32rem 0.7rem; border-radius: 50px; font-weight: 600; }
.badge-vert { background: rgba(45,106,79,0.14); color: var(--vert); }
.badge-or { background: rgba(201,162,39,0.16); color: #a6811c; }
.badge-gris { background: rgba(42,37,28,0.08); color: var(--gris-texte); }
.badge-rouge { background: rgba(178,58,58,0.12); color: #b23a3a; }

.btn-brand { background: var(--vert); color: #fff; border: none; border-radius: 8px; font-weight: 600; padding: 0.5rem 1.1rem; font-size: 0.87rem; }
.btn-brand:hover { background: var(--vert-clair); color: #fff; }
.btn-brand-or { background: var(--or); color: var(--noir); border: none; border-radius: 8px; font-weight: 600; padding: 0.5rem 1.1rem; font-size: 0.87rem; }
.btn-imprimer { background: var(--noir); color: var(--or-clair); border: none; border-radius: 8px; font-weight: 600; padding: 0.5rem 1.1rem; font-size: 0.87rem; }
.btn-imprimer:hover { background: #2a251c; color: var(--or-clair); }

.d-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; }

.dispatch-colonne { background: #fff; border-radius: 12px; padding: 1rem; min-height: 300px; border: 1px solid rgba(42,37,28,0.08); }
.dispatch-colonne h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gris-texte); margin-bottom: 0.8rem; }
.dispatch-carte {
  background: var(--fond-clair); border: 1px solid rgba(42,37,28,0.08); border-radius: 10px;
  padding: 0.8rem; margin-bottom: 0.7rem; font-size: 0.85rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.dispatch-carte:hover { border-color: var(--or); box-shadow: 0 6px 16px rgba(42,37,28,0.10); }
.dispatch-carte .dc-id { font-weight: 700; color: var(--noir); }
.dc-lien-apercu {
  display: block; text-decoration: none; color: inherit;
  border-radius: 6px; margin: -0.2rem -0.2rem 0.5rem -0.2rem; padding: 0.2rem;
  transition: background 0.15s ease;
}
.dc-lien-apercu:hover { background: rgba(201,162,39,0.08); color: inherit; }
.dc-corps { display: flex; align-items: flex-start; gap: 0.7rem; }
.dc-photos { display: flex; flex-shrink: 0; }
.dc-photos img {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.dc-photos img:not(:first-child) { margin-left: -16px; }
.dc-photos .dc-photo-reste {
  width: 44px; height: 44px; border-radius: 8px; border: 2px solid #fff;
  background: var(--noir); color: var(--or-clair); font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-left: -16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.dc-infos { flex: 1; min-width: 0; }
.dc-plats-noms { color: var(--gris-texte); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-voir-plus { font-size: 0.78rem; color: var(--or); font-weight: 600; }

.login-brand-wrap { min-height: 100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(180deg, var(--noir), #0e1e17); }
.login-brand-card { background: #fff; border-radius: 16px; padding: 2.4rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.login-brand-card img { height: 54px; display:block; margin: 0 auto 1rem; }
.login-brand-card h1 { font-size: 1.2rem; text-align:center; margin-bottom: 1.4rem; }

/* ---- Fiches (ingrédient, livreur, caisse) ---- */
.fiche-entete { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 0.4rem; }
.fiche-photo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid var(--or-clair); }
.fiche-photo-placeholder { width: 84px; height: 84px; border-radius: 50%; background: var(--fond-clair); display:flex; align-items:center; justify-content:center; font-size: 1.8rem; color: var(--gris-texte); border: 3px solid var(--or-clair); }
.fiche-stat { text-align: center; padding: 0.9rem 0.5rem; border-radius: 10px; background: var(--fond-clair); }
.fiche-stat .fs-valeur { font-family: 'Lora', serif; font-weight: 700; font-size: 1.25rem; }
.fiche-stat .fs-label { font-size: 0.7rem; color: var(--gris-texte); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.15rem; }
.etoiles-note { color: var(--or); letter-spacing: 1px; }

/* ---- Menu mobile : panneau glissant + overlay ---- */
.d-mobile-toggle { display: none; }
.d-overlay { display: none; }

@media (max-width: 900px) {
  .d-sidebar { position: fixed; left: -280px; top:0; bottom:0; z-index: 320; transition: left 0.25s ease; width: 270px; box-shadow: 6px 0 30px rgba(0,0,0,0.3); }
  .d-sidebar.ouvert { left: 0; }
  .d-sidebar-close { display: block; }
  .d-main { padding: 1.2rem; }
  .d-burger.d-mobile-toggle {
    display: flex !important; flex-direction: column; justify-content: center; gap: 5px;
    width: 42px; height: 38px; background: #fff; border: 1px solid rgba(42,37,28,0.12);
    border-radius: 8px; margin-bottom: 1rem; padding: 0 9px;
  }
  .d-burger span { display:block; height: 2px; background: var(--noir); border-radius: 2px; }
  .d-overlay.actif {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 310;
  }
}
@media (min-width: 901px) {
  .d-sidebar-close { display: none; }
}

/* ---- Impression : n'imprimer que la fiche, pas le menu ni les boutons ---- */
@media print {
  .d-sidebar, .d-mobile-toggle, .d-overlay, .no-print { display: none !important; }
  .d-main { padding: 0; }
  body.dashboard-body { background: #fff; }
  .d-card { box-shadow: none; border: 1px solid #ccc; }
  /* Neutralise le confinement de défilement desktop (colonne figée) :
     à l'impression, le contenu doit pouvoir s'étaler sur plusieurs
     pages au lieu d'être coupé à la hauteur d'un seul écran. */
  html, body.dashboard-body, .d-layout, .d-main { height: auto !important; overflow: visible !important; }
}

/* ---- Forcer un rendu clair et lisible sur les champs de formulaire ----
   (evite qu'un navigateur en mode sombre systeme ne rende les select/input
   avec un fond fonce et du texte peu lisible, non couvert par Bootstrap) */
.d-main .form-control,
.d-main .form-select,
.d-main textarea.form-control,
.login-brand-card .form-control {
  background-color: #fff;
  color: var(--charbon);
  border-color: rgba(42,37,28,0.18);
}
.d-main .form-control:focus,
.d-main .form-select:focus,
.login-brand-card .form-control:focus {
  background-color: #fff;
  color: var(--charbon);
}

/* ---------- Bandeau notifications PWA (staff) ---------- */
.bandeau-pwa {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--noir); color: #cfc8b4;
  padding: 0.8rem 1rem; display: none; align-items: center; justify-content: space-between; gap: 1rem;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.25);
}
.bandeau-pwa.visible { display: flex; }
.bandeau-pwa .bp-texte { font-size: 0.85rem; }
.bandeau-pwa .bp-texte small { display:block; color:#a79f8a; font-size: 0.72rem; }
.bandeau-pwa .bp-fermer { background:none; border:none; color:#a79f8a; font-size:1.1rem; }

/* ---------- Timeline animee (reprise du cote client, meme principe) ---------- */
.suivi-etape { display: flex; gap: 14px; padding: 0.7rem 0; align-items: center; }
.suivi-icone {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: rgba(18,16,12,0.06); color: rgba(18,16,12,0.3);
  transition: background 0.3s, color 0.3s;
}
.suivi-icone.fait { background: #3f7a4d; color: #fff; }
.suivi-icone.actif { background: var(--or); color: var(--noir); }

.suivi-icone.actif.anim-secoue { animation: suivi-secoue 0.6s ease-in-out infinite; }
.suivi-icone.actif.anim-sonne { animation: suivi-sonne 0.9s ease-in-out infinite; }
.suivi-icone.actif.anim-marche { animation: suivi-marche 1s ease-in-out infinite; }
.suivi-icone.actif.anim-roule { animation: suivi-roule 0.8s ease-in-out infinite; }
.suivi-icone.actif.anim-pulse { animation: suivi-pulse 1.4s ease-in-out infinite; }

@keyframes suivi-secoue {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
@keyframes suivi-sonne {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-4deg); }
}
@keyframes suivi-marche {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes suivi-roule {
  0%, 100% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
}
@keyframes suivi-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(201,162,39,0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(201,162,39,0); }
}

/* ==========================================================
   Filtre période / recherche + pagination — réutilisés sur
   Ventes, Caisse, Mouvements de stock et Rapports.
   ========================================================== */
.d-raccourcis-periode { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.d-filtres {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem;
  background: #fff; border: 1px solid rgba(18,16,12,0.08); border-radius: 12px;
  padding: 0.9rem 1rem;
}
.d-filtre-champ { min-width: 140px; }
.d-filtre-recherche { flex: 1 1 220px; }
.d-filtre-boutons { display: flex; gap: 0.5rem; min-width: auto; }

.d-pagination { display: flex; justify-content: center; margin-top: 1rem; }

/* Bloc liste + graphique : le graphique passe au-dessus de la liste sur
   petit écran, et à côté sur desktop. */
.d-liste-avec-graph { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: stretch; margin-bottom: 1rem; }
.d-liste-avec-graph > .d-graph-bloc { flex: 1 1 320px; min-width: 280px; }
.d-liste-avec-graph > .d-liste-bloc { flex: 2 1 480px; min-width: 320px; }
.d-graph-bloc {
  background: #fff; border: 1px solid rgba(18,16,12,0.08); border-radius: 12px;
  padding: 1rem 1.1rem; box-shadow: 0 2px 8px rgba(18,16,12,0.05);
}
.d-graph-canvas-wrap { position: relative; height: 220px; }

.fiche-stat-clic { cursor: pointer; transition: transform 0.15s; }
.fiche-stat-clic:hover { transform: translateY(-2px); }

@media print {
  .d-filtres, .d-pagination { display: none !important; }
}
