/* ════════════════════════════════════════════════════════════════
   HACCPilot — Historique des scans (SL4.E3.d-front.a)
   CSS externalisé (Q1). Convention de préfixe hs- conservée.
   Refonte V2 : rows premium (cards, vignette 48×48, temps relatif,
   badge statut app-icons), empty state V2, tri interactif.
   ════════════════════════════════════════════════════════════════ */

:root {
  --hs-green:  #16A34A;
  --hs-orange: #EA580C;
  --hs-red:    #DC2626;
  --hs-blue:   #2563EB;
  --hs-bg:     #F8FAFC;
  --hs-card:   #fff;
  --hs-border: #E2E8F0;
  --hs-text1:  #1E293B;
  --hs-text2:  #64748B;
  --hs-text3:  #94A3B8;
  --hs-thumb-bg: #EBF4FD; /* container neutre bleuté fallback vignette (maquette V2) */
}

body { background: var(--hs-bg); }

/* ── Header ── */
.hs-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--hs-border);
  padding: 0 16px;
  height: 56px;
  gap: 8px;
}
.hs-header__back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--hs-blue); flex-shrink: 0;
  border-radius: 8px;
}
.hs-header__back:active { background: #EFF6FF; }
.hs-header__title {
  flex: 1;
  font-family: var(--font-display, 'Inter', sans-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--hs-text1);
  text-align: center;
}
.hs-header__action {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--hs-blue); flex-shrink: 0;
  border-radius: 8px;
}
.hs-header__action:active { background: #EFF6FF; }

/* ── Filters card (inchangé fonctionnellement — Q4) ── */
.hs-filters-card {
  margin: 12px 16px;
  background: var(--hs-card);
  border-radius: 12px;
  border: 1px solid var(--hs-border);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
}
.hs-filter-group { flex: 1; min-width: 0; }
.hs-filter-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--hs-text2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hs-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #F8FAFC;
  border: 1.5px solid var(--hs-border);
  border-radius: 9px;
  padding: 0 8px;
  height: 38px;
  gap: 5px;
}
.hs-select-wrap svg { flex-shrink: 0; color: var(--hs-text2); }
.hs-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--hs-text1);
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  min-width: 0;
}
.hs-select-wrap::after {
  content: '';
  pointer-events: none;
  border: 5px solid transparent;
  border-top-color: var(--hs-text2);
  margin-top: 4px;
  flex-shrink: 0;
}

/* ── Stats card (inchangé — Q4) ── */
.hs-stats-card {
  margin: 0 16px 12px;
  background: var(--hs-card);
  border-radius: 12px;
  border: 1px solid var(--hs-border);
  padding: 16px 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.hs-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
  border-right: 1px solid var(--hs-border);
  cursor: pointer;                 /* compteur cliquable = filtre par verdict */
  border-radius: 8px;
  transition: background .12s ease, box-shadow .12s ease;
}
.hs-stat:last-child { border-right: none; }
/* Carte de filtre verdict active (surlignage discret, teinte neutre + anneau). */
.hs-stat--active {
  background: #F1F5F9;
  box-shadow: inset 0 0 0 1.5px var(--hs-border);
}
.hs-stat__icon {
  width: var(--icon-container-size-md); height: var(--icon-container-size-md);
  border-radius: var(--icon-container-radius);
  background: var(--icon-container-bg);
  border: 1px solid var(--icon-container-border);
  display: flex; align-items: center; justify-content: center;
}
.hs-stat__icon--green  { color: var(--hs-green); }
.hs-stat__icon--orange { color: var(--hs-orange); }
.hs-stat__icon--red    { color: var(--hs-red); }
.hs-stat__icon--blue   { color: var(--hs-blue); }
.hs-stat__num { font-size: 22px; font-weight: 800; line-height: 1; }
.hs-stat__num--green  { color: var(--hs-green); }
.hs-stat__num--orange { color: var(--hs-orange); }
.hs-stat__num--red    { color: var(--hs-red); }
.hs-stat__num--blue   { color: var(--hs-blue); }
.hs-stat__lbl {
  font-size: 10px;
  font-weight: 500;
  color: var(--hs-text2);
  text-align: center;
  line-height: 1.2;
}

/* ── Section header + tri interactif (F) ── */
.hs-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 10px;
}
.hs-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hs-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hs-section-sort {
  font-size: 12px;
  color: var(--hs-text2);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: none;
  font-family: inherit;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: 8px;
}
.hs-section-sort:active { opacity: 0.55; background: #F1F5F9; }
.hs-section-sort svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Scan list : rows premium en cards individuelles (V2) ── */
#scan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}

.hs-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 16px;
  background: var(--hs-card);
  border: 1px solid var(--hs-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm, 0 1px 4px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04));
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
}
.hs-row:active { background: #F8FAFC; box-shadow: var(--shadow-xs, 0 1px 2px rgba(0,0,0,0.06)); }

/* Vignette 48×48 + fallback icône (C / Q5) */
.hs-thumb {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--hs-thumb-bg);
  display: flex; align-items: center; justify-content: center;
}
.hs-thumb__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.hs-thumb__fallback {
  width: 28px; height: 28px;
  color: var(--hs-blue);
  display: flex; align-items: center; justify-content: center;
}
/* L'app-icon `stock` est en stroke 0.75 (pensé pour un grand container) → quasi
   invisible à taille vignette (lu comme "carré vide"). On force des dimensions
   définies + une épaisseur de trait lisible à 28px. */
.hs-thumb__fallback svg { width: 100%; height: 100%; display: block; }
.hs-thumb__fallback svg * { stroke-width: 1.3; }

/* Bloc info (Anchor Left) */
.hs-row__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hs-row__name {
  font-size: 16px; font-weight: 600; color: var(--hs-text1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hs-row__dlc {
  font-size: 13px; font-weight: 400; color: var(--hs-text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hs-row__dlc--red { color: var(--hs-red); font-weight: 500; }
.hs-row__dlc--orange { color: var(--hs-orange); font-weight: 500; } /* DDM dépassée = vigilance, pas le rouge danger */
.hs-row__time { font-size: 13px; font-weight: 400; color: var(--hs-text3); }

/* Badge statut (D) */
.hs-badge {
  display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.hs-badge svg { width: 14px; height: 14px; }
.hs-badge--green  { background: #DCFCE7; color: var(--hs-green); }
.hs-badge--orange { background: #FFEDD5; color: var(--hs-orange); }
.hs-badge--red    { background: #FEE2E2; color: var(--hs-red); }
.hs-badge--gray   { background: #F1F5F9; color: var(--hs-text2); }

/* Chevron (Information ≠ Action) */
.hs-row__chevron {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--hs-text3);
  display: flex; align-items: center; justify-content: center;
}
.hs-row__chevron svg { width: 100%; height: 100%; }

/* ── États transitoires liste (chargement / erreur) ── */
.hs-status-block { padding: 40px 24px; text-align: center; }
.hs-status-block__icon  { font-size: 32px; margin-bottom: 10px; }
.hs-status-block__title { font-size: 15px; font-weight: 700; color: var(--hs-text1); margin-bottom: 6px; }
.hs-status-block__sub   { font-size: 13px; color: var(--hs-text2); }

/* ── Empty state V2 (G) ── */
.hs-empty-v2 {
  margin: 4px 16px 0;
  background: var(--hs-card);
  border: 1px solid var(--hs-border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm, 0 1px 4px rgba(0,0,0,0.08));
}
.hs-empty-v2__illus {
  width: 96px; height: 96px;
  margin: 0 auto 20px;
  border-radius: 24px;
  background: var(--hs-thumb-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--hs-blue);
}
.hs-empty-v2__illus svg { width: 44px; height: 44px; }
.hs-empty-v2__title { font-size: 18px; font-weight: 700; color: var(--hs-text1); margin-bottom: 8px; }
.hs-empty-v2__sub   { font-size: 14px; color: var(--hs-text2); line-height: 1.4; margin-bottom: 22px; }
.hs-empty-v2__cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  text-decoration: none;
  border: none;
}
.hs-empty-v2__cta svg { width: 20px; height: 20px; }
.hs-empty-v2__cta--primary { background: var(--hs-blue); color: #fff; }
.hs-empty-v2__cta--primary:active { background: #1D4ED8; }

/* ── Pagination (inchangé — Q4) ── */
.hs-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; padding: 18px 16px 14px;
}
.hs-pagination__label { font-size: 13px; color: var(--hs-text2); font-weight: 500; }
.hs-pagination__btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--hs-border);
  background: var(--hs-card);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--hs-text1);
}
.hs-pagination__btn:disabled { color: var(--hs-text3); border-color: #F1F5F9; cursor: default; }
.hs-pagination__btn:not(:disabled):active { background: #F8FAFC; }

/* ── Info banner ── */
.hs-info-banner {
  margin: 4px 16px 16px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
}
.hs-info-banner__icon { flex-shrink: 0; color: var(--hs-blue); margin-top: 1px; width: 18px; height: 18px; }
.hs-info-banner__icon svg { width: 100%; height: 100%; }
.hs-info-banner__title { font-size: 13px; font-weight: 700; color: var(--hs-blue); margin-bottom: 2px; }
.hs-info-banner__sub   { font-size: 12px; color: #1D4ED8; }

/* ── Scroll padding for fixed tab bar ── */
.hs-scroll {
  padding-bottom: calc(var(--tab-bar-h, 56px) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* ── Detail bottom sheet V2 (E3.d-front.b — consultation seule) ── */
.hs-ds-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 200;
  display: none; align-items: flex-end; justify-content: center;
}
.hs-ds-backdrop.open { display: flex; }
.hs-ds-sheet {
  position: relative;
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px;
  max-height: 70vh;                 /* défaut (statut gris/inconnu) */
  display: flex; flex-direction: column;
  animation: hs-ds-rise 0.22s ease;
}
.hs-ds-sheet--green  { max-height: 60vh; } /* conforme */
.hs-ds-sheet--orange { max-height: 70vh; } /* à vérifier */
.hs-ds-sheet--red    { max-height: 80vh; } /* non conforme */
@keyframes hs-ds-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

.hs-ds-handle {
  width: 36px; height: 4px; background: #E2E8F0; border-radius: 99px;
  margin: 10px auto 0; flex-shrink: 0;
}
.hs-ds-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; padding: 6px;
  border: none; background: #F1F5F9; color: var(--hs-text2);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.hs-ds-close svg { width: 100%; height: 100%; }
.hs-ds-close:active { background: #E2E8F0; }
.hs-ds-panel {
  overflow-y: auto;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}
.hs-ds-loading { padding: 40px 0; text-align: center; color: var(--hs-text2); font-size: 14px; }

/* Header */
.hs-ds-header { display: flex; align-items: center; gap: 14px; padding: 12px 40px 16px 0; }
.hs-ds-thumb { width: 56px; height: 56px; border-radius: 12px; }
.hs-ds-thumb .hs-thumb__fallback { width: 30px; height: 30px; }
.hs-ds-header__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hs-ds-name { font-size: 18px; font-weight: 700; color: var(--hs-text1); line-height: 1.2; }
.hs-ds-badgerow { display: flex; align-items: center; gap: 10px; } /* badge verdict + crayon Modifier (obs 2) */
.hs-ds-edit {
  width: 32px; height: 32px; border: none; background: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center; color: var(--hs-text2);
  -webkit-tap-highlight-color: transparent;
}
.hs-ds-edit:active { opacity: 0.6; }

/* Sections */
.hs-ds-section { padding: 14px 0; border-top: 1px solid var(--hs-border); }
.hs-ds-section__title {
  font-size: 12px; font-weight: 700; color: var(--hs-blue);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px;
}
.hs-ds-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 0; }
.hs-ds-row__k { font-size: 13px; color: var(--hs-text2); font-weight: 500; flex-shrink: 0; }
.hs-ds-row__v { font-size: 13px; color: var(--hs-text1); font-weight: 600; text-align: right; word-break: break-word; }
.hs-ds-row__v--red { color: var(--hs-red); }

/* Analyse HACCP — lignes explicatives (explication du statut serveur, Q6) */
.hs-ds-check { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; font-weight: 500; }
.hs-ds-check__ico { width: 16px; height: 16px; flex-shrink: 0; display: flex; }
.hs-ds-check__ico svg { width: 100%; height: 100%; }
.hs-ds-check--green  { color: var(--hs-green); }
.hs-ds-check--orange { color: var(--hs-orange); }
.hs-ds-check--red    { color: var(--hs-red); }

/* Masquage contextuel complet (A.4) pendant l'ouverture de la sheet */
body.hs-details-open .tab-bar { display: none !important; }
