/* ERP Tyler's Foodtrailers — design de base */
:root {
  --brun: #8C5A29;
  --brun-fonce: #5f3d1b;
  --brun-tres-fonce: #3f2912;
  --brun-clair: #b07e4a;
  --creme: #f7f2ec;
  --blanc: #ffffff;
  --texte: #2c2419;
  --texte-doux: #7a6a56;
  --bordure: #e6dccf;
  --vert: #2e7d32;
  --rouge: #c62828;
  --orange: #e65100;
  --ombre: 0 1px 3px rgba(63, 41, 18, .12);
  --rayon: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--creme);
  color: var(--texte);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--brun); }

/* ---------- Structure app */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brun-fonce), var(--brun-tres-fonce));
  color: #f0e6d9;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo { padding: 14px 16px 6px; text-align: center; }
.sidebar-logo img { max-width: 128px; height: auto; }

.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 0; scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.3) transparent; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  font-size: 14px;
  color: #e8dcc9;
  text-decoration: none;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); }
.sidebar nav a.actif {
  background: rgba(255,255,255,.12);
  border-left-color: #f0c98a;
  color: #fff;
}
.sidebar nav .ico { width: 22px; text-align: center; }

.sidebar-pied {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.sidebar-pied a { color: #f0c98a; text-decoration: none; }
.sidebar-pied a:hover { text-decoration: underline; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar */
.topbar {
  background: var(--blanc);
  border-bottom: 1px solid var(--bordure);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 600; color: var(--brun-fonce); order: -1; }

.burger {
  display: none;
  background: none;
  border: 1px solid var(--bordure);
  border-radius: 6px;
  font-size: 18px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--brun-fonce);
}

.recherche { margin-left: auto; width: min(380px, 100%); }
.recherche input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--bordure);
  border-radius: 20px;
  background: var(--creme);
  font-size: 14px;
}
.recherche input:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Contenu */
.contenu { padding: 22px; max-width: 1200px; width: 100%; }

.carte {
  background: var(--blanc);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 18px;
}
.carte h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texte-doux);
  margin-bottom: 12px;
}

/* Cartes statuts remorques */
.cartes-statuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.carte-statut { text-align: center; padding: 14px 8px; border-top: 3px solid var(--brun-clair); }
.carte-statut .chiffre { font-size: 28px; font-weight: 700; color: var(--brun-fonce); }
.carte-statut .libelle { font-size: 12.5px; color: var(--texte-doux); margin-top: 2px; }
.statut-stock_lier { border-top-color: var(--vert); }
.statut-vendue     { border-top-color: var(--orange); }
.statut-livree     { border-top-color: var(--texte-doux); }

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

.chiffre-grand { font-size: 26px; font-weight: 700; color: var(--brun-fonce); }
.sous-info { color: var(--texte-doux); font-size: 13px; margin-top: 4px; }
.vide { color: var(--texte-doux); font-style: italic; }

.liste-alertes { list-style: none; }
.liste-alertes .alerte {
  background: #fdecea;
  color: var(--rouge);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-weight: 500;
}

.liste-rdv { list-style: none; }
.liste-rdv li { padding: 6px 0; border-bottom: 1px solid var(--bordure); font-size: 14px; }
.liste-rdv li:last-child { border-bottom: 0; }
.rdv-date {
  display: inline-block;
  background: var(--creme);
  border-radius: 5px;
  padding: 1px 7px;
  font-weight: 600;
  color: var(--brun-fonce);
  margin-right: 8px;
  font-size: 12.5px;
}

.carte-placeholder { text-align: center; padding: 48px 20px; color: var(--texte-doux); }
.carte-placeholder h2 { margin-bottom: 8px; }

/* ---------- Flash */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-weight: 500; }
.flash-succes { background: #e8f5e9; color: var(--vert); }
.flash-erreur { background: #fdecea; color: var(--rouge); }

/* ---------- Boutons & formulaires */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-principal { background: var(--brun); color: #fff; }
.btn-principal:hover { background: var(--brun-fonce); }

label { display: block; margin-bottom: 12px; font-weight: 500; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 11px;
  margin-top: 4px;
  border: 1px solid var(--bordure);
  border-radius: 7px;
  font-size: 15px;
  background: var(--blanc);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brun-clair);
  outline-offset: 0;
  border-color: var(--brun);
}

/* ---------- Pages auth (login / setup) */
.page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--creme) 60%, #eaddcb);
  padding: 16px;
}
.carte-auth {
  background: var(--blanc);
  border: 1px solid var(--bordure);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(63,41,18,.14);
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
}
.auth-logo { display: block; margin: 0 auto 14px; max-width: 170px; }
.carte-auth h1 { text-align: center; font-size: 20px; color: var(--brun-fonce); margin-bottom: 14px; }
.auth-sous-titre { text-align: center; color: var(--texte-doux); font-size: 14px; margin-bottom: 14px; }
.carte-auth .btn { width: 100%; margin-top: 6px; }

/* ---------- Responsive (Mike : téléphone/tablette) */
@media (max-width: 900px) {
  .burger { display: block; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: 4px 0 18px rgba(0,0,0,.25);
  }
  /* transition activée au 1er clic seulement : pas de flash au chargement */
  .sidebar.anime { transition: transform .2s ease; }
  .sidebar.ouverte { transform: translateX(0); }
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .topbar h1 { order: 0; }
  .recherche { order: 1; width: 100%; margin-left: 0; }
  .contenu { padding: 14px; }
}

/* ============ Phase B ============ */

/* Barre d'action de page */
.barre-page { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.barre-page > div { display: flex; gap: 8px; flex-wrap: wrap; }
.filtres { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filtres input[type=search] { width: 220px; }
.filtres select, .filtres input { width: auto; margin-top: 0; }
.filtres .inline, label.inline { display: flex; align-items: center; gap: 5px;
  font-weight: 400; margin: 0; white-space: nowrap; }
.btn-secondaire { background: var(--blanc); color: var(--brun-fonce);
  border: 1px solid var(--bordure); }
.btn-secondaire:hover { background: var(--creme); }
.inline-form { display: inline; }

/* Tableaux */
.carte-table { padding: 6px 0; overflow-x: auto; }
.table-scroll { overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th { text-align: left; padding: 9px 12px; color: var(--texte-doux);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--bordure); }
.tableau td { padding: 9px 12px; border-bottom: 1px solid var(--bordure); }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .c { text-align: center; }
.tableau .r { text-align: right; }
.ligne-lien { cursor: pointer; }
.ligne-lien:hover { background: var(--creme); }

/* Badges */
.badge { display: inline-block; background: var(--creme); color: var(--brun-fonce);
  border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge-marge { background: #e8f5e9; color: var(--vert); }
.badge-averifier { background: #fff3e0; color: var(--orange); }
.badge-brouillon { background: #eee; color: #555; }
.badge-envoye { background: #e3f2fd; color: #1565c0; }
.badge-accepte, .badge-soldee { background: #e8f5e9; color: var(--vert); }
.badge-refuse, .badge-annulee, .badge-impayee { background: #fdecea; color: var(--rouge); }
.badge-facture { background: #ede7f6; color: #5e35b1; }
.badge-acompte { background: #fff3e0; color: var(--orange); }

/* Formulaires */
.carte-form { margin-bottom: 16px; }
.grille-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 16px; }
.actions-form { display: flex; gap: 10px; margin-top: 12px; }
.inline-haut { display: flex; align-items: center; gap: 8px; margin-top: 26px; }
.titre-section { font-size: 14px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--texte-doux); margin: 18px 0 10px; }
label small { color: var(--texte-doux); font-weight: 400; }
.info-marge { background: var(--creme); border-radius: 8px; padding: 10px 14px;
  margin: 10px 0; }

/* Grille produits */
.grille-produits { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.carte-produit { padding: 0; overflow: hidden; text-decoration: none; color: var(--texte);
  transition: box-shadow .15s; display: block; }
.carte-produit:hover { box-shadow: 0 4px 14px rgba(63,41,18,.18); }
.carte-produit.inactif { opacity: .55; }
.produit-photo { height: 140px; background: var(--creme); display: flex;
  align-items: center; justify-content: center; overflow: hidden; }
.produit-photo img { width: 100%; height: 100%; object-fit: cover; }
.sans-photo { font-size: 42px; opacity: .5; }
.produit-infos { padding: 10px 12px 12px; }
.produit-nom { font-weight: 600; margin-bottom: 4px; }
.produit-prix { color: var(--brun-fonce); font-weight: 700; margin-bottom: 6px; }
.produit-prix small { color: var(--texte-doux); font-weight: 400; }
.produit-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* Galerie photos */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; }
.galerie-item { position: relative; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--bordure); }
.galerie-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.galerie-item form { position: absolute; top: 4px; right: 4px; }
.btn-suppr { background: rgba(198,40,40,.9); color: #fff; border: 0; border-radius: 50%;
  width: 24px; height: 24px; cursor: pointer; font-size: 12px; line-height: 1; }
.btn-suppr:hover { background: var(--rouge); }

/* Éditeur de documents */
.carte-lignes { margin-bottom: 16px; }
.recherche-produit { display: flex; gap: 8px; margin-bottom: 10px; position: relative;
  flex-wrap: wrap; }
.recherche-produit input[type=search] { flex: 1; min-width: 220px; margin-top: 0; }
.resultats-produits { position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--blanc); border: 1px solid var(--bordure); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(63,41,18,.2); max-height: 300px; overflow-y: auto; }
.resultat { display: flex; gap: 10px; align-items: center; padding: 9px 12px;
  cursor: pointer; border-bottom: 1px solid var(--bordure); }
.resultat:hover { background: var(--creme); }
.resultat:last-child { border-bottom: 0; }
.r-nom { flex: 1; font-weight: 500; }
.r-prix { color: var(--brun-fonce); font-weight: 600; white-space: nowrap; }
.r-poids { color: var(--orange); font-size: 12px; }
.vide-resultat { color: var(--texte-doux); font-style: italic; cursor: default; }
#editeur-lignes input[type=text] { margin-top: 0; padding: 6px 8px; font-size: 14px; }
#editeur-lignes .ch-fr { margin-bottom: 4px; }
#editeur-lignes .ch-nl { font-size: 12.5px; color: var(--texte-doux); }
#editeur-lignes .ch-qte { width: 54px; text-align: center; }
#editeur-lignes .ch-pu, #editeur-lignes .ch-pa { width: 90px; text-align: right; }
#editeur-lignes td { vertical-align: top; }
#editeur-lignes .ch-total { white-space: nowrap; font-weight: 600; padding-top: 14px; }
tr.est-option .ch-fr, tr.est-option .ch-nl { font-style: italic; }
.alerte-ptac { border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-weight: 600; }
.alerte-ptac.orange { background: #fff3e0; color: var(--orange); }
.alerte-ptac.rouge { background: #fdecea; color: var(--rouge); }
.confirme-ptac { display: flex; gap: 8px; align-items: center; background: #fdecea;
  color: var(--rouge); border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.totaux-editeur { display: flex; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 10px; }
.totaux-bloc { background: var(--creme); border-radius: 8px; padding: 10px 14px; }
.totaux-bloc.interne { border: 1px dashed var(--brun-clair); color: var(--texte-doux); }

/* Vue document */
.grille-doc { display: grid; grid-template-columns: 290px 1fr; gap: 14px; }
.doc-side .interne { border: 1px dashed var(--brun-clair); }
.actions-doc { display: flex; gap: 8px; flex-wrap: wrap; }
.iframe-apercu { width: 100%; height: 75vh; border: 1px solid var(--bordure);
  border-radius: 8px; background: #fff; }
.lien-lang { font-size: 12px; font-weight: 400; text-transform: none; margin-left: 8px; }
.liste-resultats { list-style: none; }
.liste-resultats li { padding: 7px 0; border-bottom: 1px solid var(--bordure); }
.liste-resultats li:last-child { border-bottom: 0; }

@media (max-width: 900px) {
  .grille-doc { grid-template-columns: 1fr; }
  .iframe-apercu { height: 60vh; }
  .filtres input[type=search] { width: 100%; }
}
