/* ==================================================================
   FOOD MARKET — espace d'administration
   Même langage visuel que le back-office du Casino de Palavas :
   Poppins, fond gris clair, tout en pilule, accent rouge, cartes très
   arrondies posées sur le fond.
   ================================================================== */

.admin {
  --adm-fond:   #edeef0;
  --adm-carte:  #ffffff;
  --adm-trait:  #e6e7ea;
  --adm-rouge:  #d24300;
  --adm-rayon:  26px;
  --adm-ombre:  0 1px 2px rgba(16,24,40,.04), 0 12px 32px -18px rgba(16,24,40,.35);

  background: var(--adm-fond);
  font-family: Poppins, Rubik, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
}

/* Plusieurs blocs de cette page ont un display imposé : sans cela, `hidden`
   ne les cacherait pas (c'est le cas du cadre « Pas de photo »). */
.admin [hidden] { display: none !important; }

.admin h1, .admin h2, .admin h3 { letter-spacing: -.03em; }

/* ---------- Porte d'entrée ---------------------------------------- */

.porte {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  background: #fff;
  overflow-y: auto;
}

.porte__gauche {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3.5rem);
  max-width: 560px;
  margin-left: auto;
  width: 100%;
}
.porte__logo {
  height: 44px;
  width: auto;
  align-self: flex-start;   /* sinon la colonne flex l'étire sur toute la largeur */
}
.porte__titre {
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.12;
  margin-top: 1.75rem;
}
.porte__sous { color: var(--ink-3); font-size: .9375rem; margin-top: .875rem; max-width: 44ch; }

.porte__form { margin-top: 2rem; display: grid; gap: 1rem; }
.porte__legal { margin-top: 1.5rem; font-size: .75rem; color: var(--ink-4); line-height: 1.5; }
.porte__erreur {
  padding: .75rem 1rem;
  border-radius: 999px;
  background: #fff0e6;
  color: var(--brand-ink);
  font-size: .875rem;
  text-align: center;
}

/* La colonne de droite : une photo du magasin et deux cartes posées dessus. */
.porte__droite {
  position: relative;
  border-radius: var(--adm-rayon);
  overflow: hidden;
  background: var(--ink);
}
.porte__droite img { width: 100%; height: 100%; object-fit: cover; }
.porte__droite::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(9,12,16,.75) 0%, rgba(9,12,16,.15) 45%, transparent 70%);
}
.porte__cartes {
  position: absolute;
  z-index: 2;
  left: 1.25rem; right: 1.25rem; bottom: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.porte__carte-info {
  background: #fff;
  border-radius: 18px;
  padding: .875rem 1rem;
}
.porte__carte-info .val { font-size: 1.375rem; font-weight: 700; line-height: 1.1; }
.porte__carte-info .lib { color: var(--adm-rouge); font-size: .8125rem; font-weight: 500; margin-top: .125rem; }
.porte__carte-info .det { color: var(--ink-2); font-size: .75rem; margin-top: .375rem; line-height: 1.35; }

@media (max-width: 900px) {
  .porte { grid-template-columns: 1fr; }
  .porte__droite { display: none; }
  .porte__gauche { margin-inline: auto; padding: 1.5rem .5rem; }
}

/* ---------- Champs ------------------------------------------------ */

.champ { display: block; }
.champ > span {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: .5rem;
}
.champ input, .champ select, .champ textarea {
  width: 100%;
  height: 52px;
  padding: 0 1.125rem;
  border: 1px solid var(--adm-trait);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .9375rem;
  color: var(--ink);
  transition: border-color var(--t), box-shadow var(--t);
}
.champ textarea {
  height: auto; min-height: 96px;
  padding: .875rem 1.125rem;
  border-radius: 20px;
  resize: vertical;
  line-height: 1.5;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
  outline: 0;
  border-color: var(--adm-rouge);
  box-shadow: 0 0 0 3px rgba(210,67,0,.12);
}
.champ-duo { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.admin .btn { border-radius: 999px; font-weight: 600; min-height: 48px; }
.admin .btn--brand { background: var(--adm-rouge); }
.admin .btn--brand:hover { background: #b83a00; }

/* ---------- En-tête du bureau ------------------------------------- */

.adm-head {
  position: sticky;
  top: 0;
  z-index: 40;
  /* Fond plein : en translucide, le tableau se devinait derrière l'en-tête. */
  background: var(--adm-fond);
  border-bottom: 1px solid var(--adm-trait);
}
.adm-head__in {
  max-width: var(--max);
  margin-inline: auto;
  padding: .75rem var(--gutter);
  display: flex;
  align-items: center;
  gap: .875rem;
}
.adm-head .logo__img { height: 30px; }
.adm-head__tag {
  padding: .3125rem .75rem;
  border-radius: 999px;
  background: rgba(210,67,0,.1);
  color: var(--adm-rouge);
  font-size: .75rem;
  font-weight: 600;
}
.adm-head__actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.adm-head .btn--soft { background: #fff; border: 1px solid var(--adm-trait); }
.adm-head .btn--soft:hover { background: #f6f7f8; }
/* Rien à enregistrer : le bouton devient neutre au lieu de rester rouge. */
.adm-head .btn[disabled] {
  opacity: 1;
  background: #fff;
  color: var(--ink-3);
  border: 1px solid var(--adm-trait);
  cursor: default;
}

.adm-etat { font-size: .8125rem; color: var(--ink-3); white-space: nowrap; }
.adm-etat b { color: var(--ink); font-weight: 600; }

.adm-main { padding-block: 1.5rem 3rem; }

/* ---------- Chiffres ---------------------------------------------- */

.adm-chiffres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chiffre {
  background: var(--adm-carte);
  border-radius: var(--adm-rayon);
  padding: 1.125rem 1.25rem;
  box-shadow: var(--adm-ombre);
}
.chiffre__val { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.chiffre__lib { font-size: .8125rem; color: var(--ink-3); margin-top: .25rem; }
.chiffre--rouge .chiffre__val { color: var(--adm-rouge); }

/* ---------- Barre d'outils ---------------------------------------- */

.adm-barre {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  margin-bottom: 1.25rem;
}
.adm-recherche {
  background: #fff;
  border: 1px solid var(--adm-trait);
  height: 48px;
  flex: 1 1 280px;
}
.adm-select {
  height: 48px;
  padding: 0 2.25rem 0 1.125rem;
  border: 1px solid var(--adm-trait);
  border-radius: 999px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f7480' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 1rem center;
  font: inherit;
  font-size: .9375rem;
  color: var(--ink);
  appearance: none;
  cursor: pointer;
}

/* ---------- Tableau ------------------------------------------------ */

.adm-tableau {
  background: var(--adm-carte);
  border-radius: var(--adm-rayon);
  box-shadow: var(--adm-ombre);
  overflow: hidden;
}
.adm-tableau table { width: 100%; border-collapse: collapse; }
.adm-tableau th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-3);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--adm-trait);
}
.adm-tableau td {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--adm-trait);
  vertical-align: middle;
}
.adm-tableau tr:last-child td { border-bottom: 0; }
.adm-tableau tbody tr.is-modifie { background: #fff7f2; }
.adm-tableau tbody tr.is-modifie td:first-child { box-shadow: inset 3px 0 0 var(--adm-rouge); }
.adm-tableau tbody tr.is-retire { opacity: .45; }
.adm-tableau tbody tr.is-retire .l-nom { text-decoration: line-through; }

.l-produit { display: flex; align-items: center; gap: .875rem; min-width: 0; cursor: pointer; }
.l-produit:hover .l-nom { color: var(--adm-rouge); }
.l-vignette {
  width: 46px; height: 46px;
  border-radius: 14px;
  border: 1px solid var(--adm-trait);
  background: #fff;
  object-fit: contain;
  padding: 4px;
  flex: none;
}
.l-vignette--vide { display: grid; place-items: center; background: var(--adm-fond); color: var(--ink-4); font-size: .625rem; }
.l-nom { font-weight: 600; font-size: .9375rem; transition: color var(--t); }
.l-marque { font-size: .75rem; color: var(--ink-3); }
.l-neuf {
  margin-left: .375rem;
  padding: .0625rem .5rem;
  border-radius: 999px;
  background: var(--ouvert-bg);
  color: var(--ouvert);
  font-size: .6875rem;
  font-weight: 600;
}

.adm-prix-col { width: 160px; }
.l-prix { display: flex; align-items: center; gap: .375rem; }
.l-prix input {
  width: 100px;
  height: 42px;
  padding: 0 .75rem;
  border: 1px solid var(--adm-trait);
  border-radius: 999px;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.l-prix input:focus { outline: 0; border-color: var(--adm-rouge); box-shadow: 0 0 0 3px rgba(210,67,0,.12); }
.l-prix input.is-vide { color: var(--ink-3); font-weight: 400; }
.l-prix span { color: var(--ink-3); font-size: .875rem; }

.l-modifier {
  border: 1px solid var(--adm-trait);
  background: #fff;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 1rem;
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t), border-color var(--t);
}
.l-modifier:hover { background: var(--adm-fond); border-color: var(--ink-4); }

.adm-vide { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); }

/* ---------- Fiche latérale ---------------------------------------- */

.tiroir-fond {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9,12,16,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}
.tiroir-fond.is-open { opacity: 1; pointer-events: auto; }

.fiche {
  position: fixed;
  top: .75rem; right: .75rem; bottom: .75rem;
  z-index: 61;
  width: min(460px, calc(100% - 1.5rem));
  background: #fff;
  border-radius: var(--adm-rayon);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 1.5rem));
  transition: transform 260ms cubic-bezier(.2, 0, .2, 1);
  box-shadow: 0 30px 60px -30px rgba(9,12,16,.5);
  overflow: hidden;
}
.fiche.is-open { transform: none; }
.fiche__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--adm-trait);
}
.fiche__head h2 { font-size: 1.125rem; font-weight: 700; }
.fiche__corps { flex: 1; overflow-y: auto; padding: 1.5rem; display: grid; gap: 1rem; }
.fiche__pied {
  display: flex; gap: .625rem;
  padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--adm-trait);
}
.fiche__pied .btn { flex: 1; }

.fiche__photo { display: grid; gap: .75rem; justify-items: center; }
.fiche__photo img {
  width: 100%; max-width: 220px; aspect-ratio: 1;
  object-fit: contain; background: #fff;
  border: 1px solid var(--adm-trait); border-radius: 20px; padding: .75rem;
}
.fiche__photo-vide {
  width: 100%; max-width: 220px; aspect-ratio: 1;
  display: grid; place-items: center;
  border: 1px dashed var(--ink-4); border-radius: 20px;
  color: var(--ink-3); font-size: .875rem;
}
.fiche__photo label { cursor: pointer; }
.fiche__note { font-size: .8125rem; color: var(--ink-3); line-height: 1.5; }

.admin .drawer__close { background: var(--adm-fond); }

/* ---------- Téléphone --------------------------------------------- */

@media (max-width: 760px) {
  .adm-head__in { flex-wrap: wrap; gap: .625rem; }
  .adm-head__actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .adm-head__actions .btn { flex: 1 1 auto; }
  .adm-etat { order: -1; flex: 1 1 100%; white-space: normal; }

  /* style.css renvoie la barre de recherche en fin de ligne dans l'en-tête du
     site : ici elle doit rester en tête de la barre d'outils. */
  .adm-barre .searchbar { order: 0; flex: 1 1 100%; }
  .adm-select, .adm-barre .btn { flex: 1 1 auto; }

  .adm-tableau { overflow-x: auto; }
  .adm-tableau table { min-width: 0; }
  .adm-tableau th:nth-child(2), .adm-tableau td:nth-child(2),
  .adm-tableau th:nth-child(3), .adm-tableau td:nth-child(3) { display: none; }
  /* Sur téléphone, on touche la ligne pour ouvrir la fiche. */
  .adm-tableau th:last-child, .adm-tableau td:last-child { display: none; }
  .adm-tableau th, .adm-tableau td { padding: .75rem 1rem; }
  .l-vignette { width: 40px; height: 40px; border-radius: 12px; }
  .adm-prix-col { width: 120px; }
  .l-prix input { width: 86px; }
  .adm-chiffres { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .chiffre { padding: 1rem; }
  .chiffre__val { font-size: 1.5rem; }
}


/* ---------- Onglets ----------------------------------------------- */

.adm-onglets {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.adm-onglet {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  height: 44px;
  padding: 0 1.125rem;
  border: 1px solid var(--adm-trait);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.adm-onglet:hover { border-color: var(--ink-4); }
.adm-onglet.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.adm-onglet__nb {
  min-width: 22px; height: 22px;
  padding: 0 .375rem;
  border-radius: 999px;
  background: var(--adm-rouge);
  color: #fff;
  font-size: .75rem;
  display: inline-grid;
  place-items: center;
}
.adm-onglet__nb:empty { display: none; }

/* ---------- Déstockage du jour ------------------------------------ */

.dst-form {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--adm-carte);
  border-radius: var(--adm-rayon);
  box-shadow: var(--adm-ombre);
}
.dst-form__tete { grid-column: 1 / -1; }
.dst-form__tete h2 { font-size: 1.25rem; font-weight: 700; }
.dst-form__tete p { color: var(--ink-3); font-size: .875rem; margin-top: .25rem; }

.dst-photo {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px dashed var(--ink-4);
  border-radius: 22px;
  background: var(--adm-fond);
  color: var(--ink-2);
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.dst-photo:hover { border-color: var(--adm-rouge); color: var(--adm-rouge); }
.dst-photo.is-pleine { border-style: solid; border-color: var(--adm-trait); }
.dst-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dst-photo__vide { display: grid; justify-items: center; gap: .625rem; padding: 1rem; font-size: .9375rem; }
.dst-photo__vide .icon {
  width: 22px; height: 22px;
  padding: 11px;
  box-sizing: content-box;
  border-radius: 999px;
  background: #fff;
}
.dst-photo__changer {
  position: absolute;
  bottom: .75rem; left: 50%;
  transform: translateX(-50%);
  padding: .375rem .875rem;
  border-radius: 999px;
  background: rgba(15,23,32,.72);
  color: #fff;
  font-size: .8125rem;
  white-space: nowrap;
}
.dst-photo.is-envoi::after {
  content: 'Envoi de la photo…';
  position: absolute;
  top: .75rem; left: .75rem;
  padding: .25rem .625rem;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: .75rem;
}

/* Pendant que l'IA lit la photo (js/admin-destockage.js). */
.dst-photo.is-ia::before {
  content: 'L’IA lit la photo…';
  position: absolute;
  top: .75rem; right: .75rem;
  z-index: 1;
  padding: .25rem .625rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .75rem;
}

.dst-champs { display: grid; gap: 1rem; align-content: start; }
.champ em { font-style: normal; font-weight: 400; color: var(--ink-4); }
/* Ce que l'IA a compris, ou ce qui l'a gênée. */
.dst-ia {
  padding: .75rem 1rem;
  border-radius: 14px;
  background: var(--adm-fond);
  color: var(--ink-2);
  font-size: .875rem;
  line-height: 1.45;
}
.dst-ia--alerte { background: #fff0e6; color: var(--brand-ink); }

.dst-actions { display: flex; justify-content: flex-end; gap: .625rem; }
.dst-actions .btn--brand { min-width: 220px; }

.dst-liste-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 1rem;
}
.dst-liste-tete h2 { font-size: 1.125rem; font-weight: 700; }
.dst-liste-tete .btn--soft { background: #fff; border: 1px solid var(--adm-trait); }
.dst-liste { display: grid; gap: .75rem; }

.dst-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .75rem;
  background: var(--adm-carte);
  border-radius: 20px;
  box-shadow: var(--adm-ombre);
}
.dst-item.is-eteint { opacity: .6; }
.dst-item__photo {
  width: 72px; height: 72px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--adm-fond);
  display: grid;
  place-items: center;
  font-size: .625rem;
  color: var(--ink-4);
}
.dst-item__photo img { width: 100%; height: 100%; object-fit: cover; }
.dst-item__nom { font-weight: 600; }
.dst-item__prix { font-size: .875rem; color: var(--ink-2); margin-top: .125rem; }
.dst-item__prix s { color: var(--ink-4); margin-left: .25rem; }
.dst-item__etat {
  display: inline-block;
  margin-top: .375rem;
  padding: .0625rem .5rem;
  border-radius: 999px;
  background: var(--ouvert-bg);
  color: var(--ouvert);
  font-size: .6875rem;
  font-weight: 600;
}
.dst-item__etat--eteint { background: var(--adm-fond); color: var(--ink-3); }
.dst-item__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .375rem; }
.l-modifier--danger { color: var(--brand-ink); }
.l-modifier.is-arme { background: var(--adm-rouge); border-color: var(--adm-rouge); color: #fff; }

/* ---------- Messages reçus ---------------------------------------- */

.msg-liste { display: grid; gap: .75rem; }

.msg-item {
  background: var(--adm-carte);
  border-radius: 20px;
  box-shadow: var(--adm-ombre);
  overflow: hidden;
}
.msg-item.is-neuf { box-shadow: var(--adm-ombre), inset 3px 0 0 var(--adm-rouge); }

/* L'en-tête est le bouton qui déplie : toute la ligne est cliquable. */
.msg-item__tete {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .25rem 1rem;
  width: 100%;
  padding: .875rem 1rem;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.msg-item__tete:hover { background: var(--adm-fond); }

.msg-item__qui { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.msg-item.is-neuf .msg-item__qui { font-weight: 700; }
.msg-item__pastille {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--adm-rouge);
  flex: none;
}
.msg-item__quand { font-size: .8125rem; color: var(--ink-3); white-space: nowrap; }
.msg-item__extrait {
  grid-column: 1 / -1;
  font-size: .875rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-item__extrait:empty { display: none; }

.msg-item__corps { padding: 0 1rem 1rem; border-top: 1px solid var(--adm-trait); padding-top: .875rem; }
.msg-item__texte { line-height: 1.55; white-space: pre-line; }
.msg-item__de { margin-top: .625rem; font-size: .875rem; color: var(--ink-3); }
.msg-item__de a { color: var(--brand-ink); }
.msg-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-top: .875rem;
}
/* « Répondre » est un lien mailto, aligné sur les boutons voisins. */
.msg-item__actions .l-modifier {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

@media (max-width: 760px) {
  .msg-item__tete { grid-template-columns: 1fr; }
  .msg-item__quand { grid-row: 1; justify-self: start; }
  .msg-item__actions .l-modifier { flex: 1; justify-content: center; }
}

@media (max-width: 760px) {
  .dst-form { grid-template-columns: 1fr; gap: 1rem; padding: 1rem; }
  .dst-photo { aspect-ratio: 4 / 3; }
  .dst-actions .btn { flex: 1; min-width: 0; }
  .dst-item { grid-template-columns: 60px 1fr; }
  .dst-item__photo { width: 60px; height: 60px; }
  .dst-item__actions { grid-column: 1 / -1; }
  .dst-item__actions .l-modifier { flex: 1; }
}
