/* Olakoop Prix — styles
   Charte olakoop.org : Montserrat, orange et vert-bleu.
   Principe : le résultat se lit comme deux étiquettes de rayon côte à côte. */

@font-face { font-family: "Montserrat"; font-weight: 400; font-display: swap; src: url("fonts/montserrat-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 500; font-display: swap; src: url("fonts/montserrat-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url("fonts/montserrat-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url("fonts/montserrat-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 800; font-display: swap; src: url("fonts/montserrat-latin-800-normal.woff2") format("woff2"); }

:root {
  /* === Couleurs de la charte : à ajuster ici si besoin === */
  --orange: #F7A600;       /* orange du logo Olakoop */
  --teal: #04A695;         /* vert-bleu du logo Olakoop */
  --teal-dark: #037468;    /* vert-bleu foncé : boutons et titres (lisibilité) */
  --orange-strong: #F7A600;
  /* ======================================================= */
  --ink: #17393B;          /* texte : vert-bleu très foncé */
  --ink-soft: #577072;
  --floor: #EFF4F3;
  --paper: #FFFFFF;
  --orange-soft: #FDEBD8;
  --good: #1B7F3B;
  --good-bg: #E2F3E7;
  --bad: #C0362C;
  --bad-bg: #FBE5E2;
  --line: #CCDAD9;
  --focus: #F28C28;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--floor); color: var(--ink);
  font: 400 16px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--paper); color: var(--ink);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 0;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 16px;
  border-bottom: 4px solid var(--orange);
}
.brand { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; text-decoration: none; color: inherit; }
.brand-logo { display: block; height: 50px; width: auto; }
.brand-sub { font-size: 13px; font-weight: 600; color: var(--ink-soft); border-left: 2px solid var(--line); padding-left: 10px; line-height: 1.2; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
  padding: 9px 14px; font-weight: 600; font-size: 15px; border-radius: 8px 8px 0 0;
}
.tab[aria-selected="true"] { background: var(--orange); color: var(--ink); }
.admin .topbar { align-items: center; padding-bottom: 10px; }
.admin .brand { padding-bottom: 0; }

main { max-width: 600px; margin: 0 auto; padding: 20px 16px 8px; }

/* ---------- Recherche ---------- */
h1 { font-weight: 800; font-size: 24px; line-height: 1.2; margin: 0 0 16px; color: var(--teal-dark); }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.btn-photo { width: 62px; min-height: 62px; padding: 0; background: var(--paper); border-color: var(--orange); color: #B87A00; }
.btn-photo svg { width: 26px; height: 26px; }
.list-count { margin: 16px 2px 0; font-weight: 700; font-size: 15px; color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--teal); background: var(--paper); color: var(--teal-dark); font-weight: 700; font-size: 15px; text-align: center;
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-primary { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn-accent { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.btn-accent.big { min-height: 62px; font-size: 17px; }
.btn-danger { border-color: var(--bad); color: var(--bad); min-height: 36px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-link { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }

.or { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); margin: 18px 0 10px; font-size: 14px; }
.or::before, .or::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.search { display: flex; gap: 8px; }
.search input, .field input, .admin-search input, .login input {
  flex: 1; min-width: 0; min-height: 48px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: var(--paper);
}
.search input:focus, .field input:focus { border-color: var(--teal); outline: none; }
.hint { margin: 6px 2px 0; font-size: 13px; color: var(--ink-soft); }

/* ---------- Lecteur caméra ---------- */
.scanner { position: relative; margin-top: 16px; background: #000; border-radius: 12px; overflow: hidden; }
.scanner video { display: block; width: 100%; max-height: 62vh; object-fit: cover; }
.scan-frame {
  position: absolute; left: 8%; right: 8%; top: 50%; height: 34%; transform: translateY(-62%);
  border: 3px solid var(--orange); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none;
}
.scan-frame::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: rgba(242,140,40,.8); }
.scanner-bar { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; color: #fff; font-size: 14px; background: #000; }
.scan-hint { position: absolute; left: 0; right: 0; top: 10px; margin: 0; text-align: center; color: #fff; font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none; padding: 0 12px; }
#cam-name { font-size: 13px; color: #CDE7E6; }
.scanner-bar .btn { min-height: 40px; background: transparent; color: #fff; border-color: #fff; }

/* ---------- Messages ---------- */
.msg { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--paper); border-left: 5px solid var(--ink-soft); font-size: 15px; }
.msg-warn { border-left-color: var(--orange); }
.msg-error { border-left-color: var(--bad); }
.msg-ok { border-left-color: var(--good); }
.msg strong { display: block; margin-bottom: 2px; }
.loading { color: var(--ink-soft); }

/* ---------- Résultats ---------- */
.results { display: grid; gap: 14px; margin-top: 18px; }
.item { background: var(--paper); border-radius: 14px; padding: 14px; box-shadow: 0 1px 0 var(--line); }
.item-head { display: flex; gap: 12px; align-items: center; }
.item-img {
  width: 64px; height: 64px; flex: none; border-radius: 8px; background: var(--floor);
  object-fit: contain; display: grid; place-items: center; color: var(--ink-soft);
}
.item-img svg { width: 30px; height: 30px; }
.item h2 { font-weight: 700; font-size: 16px; line-height: 1.3; margin: 0; }
.item-meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }

.tickets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ticket {
  position: relative; border-radius: 6px; padding: 8px 12px 10px; min-height: 100px;
  display: flex; flex-direction: column; justify-content: space-between; min-width: 0;
}
.ticket-label { font-weight: 700; font-size: 14px; }
.ticket-price { font-weight: 800; font-size: clamp(26px, 8.4vw, 36px); line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket-unit { font-size: 12px; font-weight: 500; }
.ticket.coop { background: var(--orange); color: var(--ink); }
.ticket.coop::after { /* trou d'étiquette */
  content: ""; position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper);
}
.ticket.shop { background: var(--paper); border: 2px dashed var(--teal); }
.ticket.shop label { font-weight: 700; font-size: 14px; color: var(--teal-dark); }
.price-input { display: flex; align-items: baseline; gap: 4px; }
.price-input input {
  width: 100%; min-width: 0; border: 0; border-bottom: 2px solid var(--line); background: transparent;
  font-weight: 800; font-size: clamp(26px, 8.4vw, 36px); line-height: 1.05; letter-spacing: -.02em; padding: 0; color: var(--ink);
}
.price-input input::placeholder { color: #B9C9C8; }
.price-input input:focus { outline: none; border-bottom-color: var(--teal); }
.price-input span { font-weight: 800; font-size: 24px; }

.verdict { margin-top: 12px; display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; color: var(--ink-soft); }
.ecart {
  display: inline-block; font-weight: 800; font-size: 18px; line-height: 1; padding: 7px 10px; border-radius: 6px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ecart.good { background: var(--good-bg); color: var(--good); }
.ecart.bad { background: var(--bad-bg); color: var(--bad); }
.ecart.even { background: var(--floor); color: var(--ink); }
.verdict.good { color: var(--good); font-weight: 700; }
.verdict.bad { color: var(--bad); font-weight: 700; }

.save-open { width: 100%; margin-top: 12px; }
.save-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 600; font-size: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-note { margin: 0; font-size: 13px; color: var(--ink-soft); }
.saved { margin-top: 12px; color: var(--good); font-weight: 700; }

/* ---------- Historique ---------- */
.average {
  margin: 16px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--teal-dark); color: #fff;
  display: flex; align-items: center; gap: 14px;
}
.average-value { font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: -.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.average.good .average-value { color: #A6F0BC; }
.average.bad .average-value { color: #FFC2B8; }
.average-text { font-size: 14px; line-height: 1.4; }
.average-text strong { display: block; font-size: 15px; }

.history-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.h-item {
  background: var(--paper); border-radius: 10px; padding: 10px 12px;
  display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 12px; align-items: center;
}
.h-img { grid-row: 1 / span 3; width: 52px; height: 52px; border-radius: 8px; background: var(--floor); object-fit: contain; align-self: start; }
div.h-img { display: grid; place-items: center; color: var(--ink-soft); }
div.h-img svg { width: 24px; height: 24px; }
.h-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.h-item .ecart { grid-column: 3; grid-row: 1 / span 2; }
.h-prices { grid-column: 2; font-size: 14px; }
.h-where { grid-column: 2 / -1; font-size: 13px; color: var(--ink-soft); }
.more { width: 100%; margin-top: 12px; }
.empty { margin-top: 24px; color: var(--ink-soft); }

/* ---------- Pied de page ---------- */
footer { max-width: 600px; margin: 32px auto 0; padding: 16px 16px 28px; font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--line); }
footer p { margin: 0 0 6px; }
footer a { color: var(--teal-dark); font-weight: 600; }

/* ---------- Modération ---------- */
.admin-main { max-width: 1200px; }
.login { max-width: 360px; display: grid; gap: 10px; background: var(--paper); padding: 20px; border-radius: 12px; }
.login label { font-weight: 600; }
.admin-search { display: flex; gap: 8px; max-width: 600px; }
.admin-count { color: var(--ink-soft); }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: 12px; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--floor); text-align: left; vertical-align: top; }
.admin-table th { font-weight: 700; background: #F4F8F7; white-space: nowrap; }
.admin-table small { color: var(--ink-soft); }
.admin-table .ecart { font-size: 15px; padding: 4px 6px; }
.pager { display: flex; gap: 16px; margin: 14px 0; }
.pager a { color: var(--teal-dark); font-weight: 700; }

@media (max-width: 370px) {
  h1 { font-size: 21px; }
  .field-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .item { animation: arrive .18s ease-out; }
  @keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ---------- Listes par catégorie ---------- */
.toggle {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 2px; min-height: 44px;
  background: none; border: 0; color: var(--teal-dark); font-weight: 600; font-size: 14px; cursor: pointer; text-align: left;
}
.toggle-box { width: 22px; height: 22px; flex: none; border: 2px solid var(--teal-dark); border-radius: 6px; background: var(--paper); display: grid; place-items: center; }
.toggle[aria-pressed="true"] .toggle-box { background: var(--teal-dark); }
.toggle[aria-pressed="true"] .toggle-box::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }

/* Relevés déjà publiés pour ce produit */
.known { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--floor); }
.known-title { margin: 0 0 8px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.known .ecart { font-size: 14px; padding: 4px 6px; }
.known-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.known-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; font-size: 14px; }
.known-where { font-weight: 600; }
.known-price { font-weight: 700; white-space: nowrap; }
.known-meta { grid-column: 1 / -1; font-size: 12px; color: var(--ink-soft); }
.known-more { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
.groups { display: grid; gap: 18px; margin-top: 4px; }
.group-title {
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 3px solid var(--orange);
  font-weight: 800; font-size: 17px; color: var(--teal-dark); display: flex; align-items: baseline; gap: 8px;
}
.group-title span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row { background: var(--paper); border-radius: 10px; padding: 8px 10px; }
.row-head { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 10px; align-items: center; }
.row-img { width: 44px; height: 44px; border-radius: 8px; background: var(--floor); object-fit: contain; }
div.row-img { display: grid; place-items: center; color: var(--ink-soft); }
div.row-img svg { width: 22px; height: 22px; }
.row-name { font-weight: 600; font-size: 14px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.row-price { font-weight: 800; font-size: 16px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-price small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-soft); }
.row-action {
  border: 2px solid var(--teal); background: var(--paper); color: var(--teal-dark); border-radius: 8px;
  font-weight: 700; font-size: 13px; padding: 6px 8px; min-height: 36px; cursor: pointer;
}
.row-action[aria-expanded="true"] { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.item-inline { padding: 0; margin-top: 4px; box-shadow: none; }
.item-inline .tickets { margin-top: 10px; }

.info-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink-soft); background: var(--paper);
  color: var(--ink-soft); font-weight: 800; font-size: 16px; line-height: 1; cursor: pointer; flex: none;
}
.row-info { justify-self: center; }
.ticket.no-compare { background: var(--floor); border: 2px dashed var(--line); color: var(--ink-soft); }
.no-compare-text { font-size: 13px; line-height: 1.35; font-weight: 500; margin-top: 6px; }
.no-compare-info { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; font-size: 14px; }
.consult-note { margin: 10px 0 0; font-size: 13px; color: var(--ink-soft); }

.list-head { scroll-margin-top: 110px; display: grid; gap: 8px; margin-bottom: 4px; }
.list-title { margin: 0; font-size: 14px; color: var(--ink-soft); }
.list-title strong { display: block; font-size: 16px; color: var(--ink); }
.list-filter { min-height: 44px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 10px; background: var(--paper); }
.list-filter:focus { border-color: var(--teal); outline: none; }
.list-empty { margin: 0; color: var(--ink-soft); }

/* ---------- Fenêtre d'explication ---------- */
.why { border: 0; border-radius: 16px; padding: 20px; max-width: 420px; width: calc(100% - 32px); color: var(--ink); }
.why::backdrop { background: rgba(13, 40, 42, .55); }
.why h2 { margin: 0 0 10px; font-weight: 800; font-size: 19px; color: var(--teal-dark); }
.why p { margin: 0 0 10px; font-size: 15px; }
.why-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.why-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 0; padding: 6px 2px; min-height: 36px;
  background: none; border: 0; color: var(--ink-soft); font-size: 14px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left;
}
.why-link-icon {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; font-size: 12px; font-weight: 800; text-decoration: none;
}
.groups > .why-link { margin: 0 0 -6px; justify-self: start; }
.list-count + .why-link { margin-top: 0; }
.row-nobarcode .row-head { grid-template-columns: 44px 1fr auto; }
