/* Thème tactile — contraste élevé, zones ≥ 48px */
:root {
  --bg-page: #e4e9f0;
  --bg-card: #ffffff;
  --bg-input: #f4f6f9;
  --bg-suggest: #ffffff;
  --bg-suggest-active: #e8f2fc;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --border: #c5ced9;
  --border-focus: #0369a1;
  --accent: #0369a1;
  --accent-soft: rgba(3, 105, 161, 0.14);
  --accent-press: #075985;
  --shadow-card: 0 4px 24px rgba(15, 23, 42, 0.08), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  --shadow-float: 0 12px 40px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-sm: 14px;
  --touch-min: 52px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(3, 105, 161, 0.15);
}

body {
  position: relative;
  background: var(--bg-page);
  padding-bottom: var(--safe-bottom);
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 10% 0%, rgba(3, 105, 161, 0.09), transparent 55%),
    radial-gradient(700px 400px at 100% 30%, rgba(14, 116, 144, 0.07), transparent 50%),
    linear-gradient(180deg, #dbe4ee 0%, var(--bg-page) 55%, #dce3ec 100%);
}

/* ── Shell ── */
.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(560px, 100% - 1rem);
  margin: 0 auto;
  padding: clamp(0.75rem, 3vw, 2rem) 0.5rem clamp(1rem, 4vw, 2.5rem);
}

/* ── Hero card ── */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: clamp(1rem, 3.5vw, 1.65rem);
}

/* ── Header ── */
.head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.btn-settings {
  margin-left: auto;
  flex-shrink: 0;
  width: var(--touch-min);
  height: var(--touch-min);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-settings:hover { background: #fff; border-color: var(--accent); color: var(--accent); }

.head-badge {
  flex-shrink: 0;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(3, 105, 161, 0.28);
  color: var(--accent);
}
.head-icon { width: 26px; height: 26px; }

.head-text { min-width: 0; }

.title {
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.15rem;
  line-height: 1.15;
  color: var(--text);
}
.sub {
  margin: 0;
  font-size: clamp(0.8rem, 2.8vw, 1rem);
  color: var(--muted);
  font-weight: 500;
}

/* ── Search ── */
.label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.field-wrap { position: relative; }

.input-prefix {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}

.input {
  width: 100%;
  min-height: var(--touch-min);
  font-size: clamp(1.2rem, 4.5vw, 1.45rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 0.85rem 1rem 0.85rem 2.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  /* Empêche le zoom iOS sur focus */
  font-size: max(16px, clamp(1.1rem, 4vw, 1.45rem));
}
.input::placeholder { color: #94a3b8; font-weight: 500; }
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: #fff;
}

.hint {
  margin: 0.65rem 0 0;
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  color: var(--muted);
  line-height: 1.4;
}
kbd {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12em 0.4em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-soft);
}

/* ── Suggest ── */
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--bg-suggest);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float);
  max-height: min(55vh, 380px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  z-index: 10;
}
.suggest li {
  min-height: var(--touch-min);
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: clamp(0.95rem, 3vw, 1.05rem);
  border-radius: var(--radius-sm);
  color: var(--text);
  border: 2px solid transparent;
}
.suggest li:hover,
.suggest li[aria-selected="true"] {
  background: var(--bg-suggest-active);
  border-color: rgba(3, 105, 161, 0.2);
}
.suggest .s-desc {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── PWA Install Banner ── */
.pwa-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid rgba(3, 105, 161, 0.3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  animation: slideDown 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pwa-banner-icon { font-size: 1.4rem; flex-shrink: 0; }
.pwa-banner-text {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
}
.pwa-install {
  flex-shrink: 0;
  padding: 0.45rem 0.85rem !important;
  min-height: 38px !important;
  font-size: 0.88rem !important;
  background: linear-gradient(180deg, #0284c7, var(--accent)) !important;
  color: #fff !important;
  border-color: var(--accent-press) !important;
}
.pwa-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 8px;
  min-width: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
}
.pwa-dismiss:hover { background: var(--bg-input); color: var(--text); }

.legal {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.legal strong { color: var(--text-soft); font-weight: 600; }

/* ── Backdrop ── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(4px);
  z-index: 40;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Popup ── */
.popup {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  padding: 0;
  width: min(520px, calc(100% - 0.75rem));
  max-height: min(94dvh, 660px);
  border-radius: calc(var(--radius) + 4px);
  background: transparent;
  z-index: 50;
}

/* Sur petits écrans : popup collé en bas comme une bottom sheet */
@media (max-width: 480px) {
  .popup {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .popup-inner {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding-bottom: calc(1rem + var(--safe-bottom)) !important;
    /* Drag handle visuel */
    padding-top: 0 !important;
  }
  .popup-inner::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0.65rem auto 0.5rem;
  }
}

.popup-inner {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-float);
  padding: 0 1.1rem 1rem;
  overflow: hidden auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: popIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  @keyframes popIn {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

.popup-accent {
  height: 4px;
  margin: 0 -1.1rem 0.85rem;
  background: linear-gradient(90deg, var(--accent), #0d9488);
}

.popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.popup-title {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.btn-close {
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-soft);
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border-radius: 14px;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.btn-close:hover, .btn-close:active { background: #fff; border-color: var(--border-focus); color: var(--text); }

/* ── Data grid ── */
.grid { margin: 0; }
.grid .row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}
.grid .row:last-of-type { border-bottom: none; }
.grid dt {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.grid dd {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.1rem);
  color: var(--text-soft);
  font-weight: 500;
}
.mono {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  color: var(--text) !important;
  letter-spacing: -0.02em;
}
.row-desc dd {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: clamp(1rem, 3vw, 1.15rem);
}
.msrp-dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.msrp-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(1.45rem, 6vw, 1.85rem);
  letter-spacing: -0.02em;
  color: var(--text) !important;
}
.msrp-cad {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  border: 2px solid rgba(3, 105, 161, 0.25);
  background: var(--accent-soft);
}

/* ── Popup footer ── */
.popup-foot {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.55rem;
  padding-top: 0.9rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--border);
}
@media (min-width: 400px) {
  .popup-foot { flex-direction: row; justify-content: stretch; }
  .popup-foot .btn { flex: 1; }
}

/* ── Buttons ── */
.btn {
  font-family: inherit;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  font-weight: 700;
  min-height: var(--touch-min);
  padding: 0.65rem 1rem;
  border-radius: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn.ghost {
  background: var(--bg-input);
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover, .btn.ghost:active { background: #fff; border-color: var(--border-focus); }
.btn.primary {
  background: linear-gradient(180deg, #0284c7 0%, var(--accent) 100%);
  color: #fff;
  border-color: var(--accent-press);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset;
}
.btn.primary:hover, .btn.primary:active { filter: brightness(1.05); }
.btn.outline {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
}
.btn.outline:hover, .btn.outline:active { background: var(--accent-soft); }

/* ── Aperçu label thermique ── */
.preview-wrap {
  margin: 0.75rem 0 0;
  padding: 0.85rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  overflow-x: auto;
  animation: popIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Ratio 2.25in × 1.25in → 216×120px */
.preview-label {
  width: 216px;
  height: 120px;
  background: #fff;
  border: 0.75pt solid #d3d3d3;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 5px;
  gap: 5px;
  font-family: Arial, Helvetica, system-ui, sans-serif;
  overflow: hidden;
  flex-shrink: 0;
}
.prev-qr {
  flex-shrink: 0;
  width: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1pt solid #d3d3d3;
  padding-right: 5px;
}
.prev-qr img, .prev-qr canvas { width: 72px !important; height: 72px !important; display: block; }
.prev-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-left: 5px;
  overflow: hidden;
}
.prev-sku { font-size: 10pt; font-weight: 700; color: #555555; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; line-height: 1; }
.prev-desc { font-size: 7.5pt; font-weight: 700; color: #000; line-height: 1.2; flex: 1; display: flex; align-items: center; word-break: break-word; overflow: hidden; }
.prev-divider { height: 1pt; background: #d3d3d3; margin: 2px 0; flex-shrink: 0; }
.prev-msrp { display: flex; flex-direction: row; align-items: baseline; font-size: 16pt; font-weight: 900; color: #000; letter-spacing: -0.04em; line-height: 1; }
.prev-msrp-dollar { font-size: 0.72em; font-weight: 900; margin-right: 0.02em; }
.prev-msrp-digits { font-size: 1em; font-weight: 900; }

/* ── Print ── */
.print-only {
  position: fixed;
  left: -9999px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}
@media print {
  body * { visibility: hidden; }
}

/* ── Responsive ── */
@media (max-width: 360px) {
  .shell { max-width: 100%; padding-left: 0.35rem; padding-right: 0.35rem; }
  .hero-card { padding: 0.85rem; }
  .title { font-size: 1.2rem; }
  .sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .backdrop, .popup-inner, .pwa-banner { animation: none; }
}
