/* ==========================================================================
   TechDealsNow storefront styles
   Mobile-first. Brand gradient: #4f46e5 (indigo) -> #06b6d4 (cyan).
   ========================================================================== */

:root {
  --brand-1: #4f46e5;
  --brand-2: #06b6d4;
  --grad: linear-gradient(135deg, var(--brand-1), var(--brand-2));

  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;

  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #dc2626;
  --bad-bg: #fef2f2;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--slate-900);
  background: var(--slate-100);
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-1); }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--white); color: var(--slate-900); padding: 8px 14px; border-radius: 8px;
  box-shadow: var(--shadow-md); transition: top .15s;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

/* ---------------- Top bar (sticky) ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: rgba(15, 23, 42, .92);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid rgba(148, 163, 184, .15);
}
.topbar__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--white); }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--grad);
  display: grid; place-items: center; font-weight: 800; color: var(--white);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .45);
}
.brand__name { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }

.cart-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, .08); color: var(--white);
  border: 1px solid rgba(148, 163, 184, .3);
  transition: background .15s, transform .15s;
}
.cart-btn:hover { background: rgba(255, 255, 255, .15); }
.cart-btn:active { transform: scale(.97); }
.cart-btn__label { font-weight: 600; font-size: .95rem; }
.cart-badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--grad); color: var(--white); font-size: .78rem; font-weight: 700;
}
.cart-badge.bump { animation: bump .35s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ---------------- Hero ---------------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(6, 182, 212, .28), transparent 60%),
    radial-gradient(800px 420px at -10% 10%, rgba(79, 70, 229, .35), transparent 60%),
    linear-gradient(180deg, var(--slate-900), var(--slate-950));
  color: var(--white);
  padding: 36px 0 28px;
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad);
}
.hero__inner { position: relative; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600; letter-spacing: .02em;
  color: #c7d2fe; background: rgba(79, 70, 229, .18); border: 1px solid rgba(129, 140, 248, .45);
}
.hero__title { margin: 14px 0 4px; font-size: clamp(2.1rem, 8vw, 3.6rem); line-height: 1.05; font-weight: 800; letter-spacing: -.03em; }
.hero__tagline { margin: 0; font-size: clamp(1.05rem, 3.6vw, 1.35rem); font-weight: 600; color: var(--slate-200); }
.hero__sub { margin: 8px 0 0; max-width: 620px; color: var(--slate-400); font-size: .98rem; }

.controls { margin-top: 22px; display: grid; gap: 14px; }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); color: var(--slate-500);
  border-radius: 12px; padding: 0 14px; min-height: 50px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, .35);
  border: 2px solid transparent; transition: border-color .15s;
}
.search:focus-within { border-color: var(--brand-2); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--slate-900); font-size: 1rem; padding: 12px 0;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 6px 6px 10px; margin: -6px -6px -10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; cursor: pointer; white-space: nowrap;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  font-weight: 600; font-size: .92rem;
  color: var(--slate-200); background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(148, 163, 184, .3);
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: rgba(255, 255, 255, .12); }
.chip.is-active { background: var(--grad); color: var(--white); border-color: transparent; box-shadow: 0 6px 18px rgba(79, 70, 229, .4); }

/* ---------------- Product grid ---------------- */
main.container { padding-top: 22px; padding-bottom: 48px; }
.results-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-bar__count { margin: 0; color: var(--slate-500); font-size: .92rem; font-weight: 500; }

.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.card {
  display: flex; flex-direction: column;
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--slate-200); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card.is-soldout { opacity: .7; }

.card__media { position: relative; aspect-ratio: 4 / 3; background: var(--slate-50); border-bottom: 1px solid var(--slate-100); }
.card__media img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.card__badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em; line-height: 1.4;
  background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200);
}
.badge--condition { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.badge--low { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge--soldout { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.badge--cat { background: rgba(255, 255, 255, .9); }

.card__body { display: flex; flex-direction: column; gap: 10px; padding: 16px; flex: 1; }
.card__title { margin: 0; font-size: 1.04rem; line-height: 1.3; font-weight: 700; }
.card__sku { margin: 0; font-size: .78rem; color: var(--slate-500); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.specs { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: .9rem; color: var(--slate-700); }
.specs li { position: relative; padding-left: 18px; }
.specs li::before {
  content: ""; position: absolute; left: 2px; top: .55em; width: 7px; height: 7px; border-radius: 2px;
  background: var(--grad);
}
.specs b { color: var(--slate-900); font-weight: 600; }

.card__foot { margin-top: auto; display: grid; gap: 12px; padding-top: 6px; }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.price--compare { font-size: .95rem; color: var(--slate-400); text-decoration: line-through; font-weight: 500; }
.price-save { font-size: .78rem; font-weight: 700; color: var(--ok); }

.card__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card__actions .btn { padding: 0 8px; white-space: nowrap; font-size: .9rem; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: filter .15s, background .15s, transform .1s, box-shadow .15s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--grad); color: var(--white); box-shadow: 0 6px 16px rgba(79, 70, 229, .28); }
.btn--primary:hover:not([disabled]) { filter: brightness(1.07); }
.btn--secondary { background: var(--slate-900); color: var(--white); }
.btn--secondary:hover:not([disabled]) { background: var(--slate-800); }
.btn--ghost { background: var(--white); color: var(--slate-900); border-color: var(--slate-200); }
.btn--ghost:hover:not([disabled]) { background: var(--slate-50); }
.btn--outline { background: var(--white); color: var(--brand-1); border-color: #c7d2fe; }
.btn--outline:hover:not([disabled]) { background: #eef2ff; }
.btn--block { width: 100%; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid var(--slate-200); color: var(--slate-700);
}
.icon-btn:hover { background: var(--slate-100); }

/* ---------------- Empty state & skeletons ---------------- */
.empty { text-align: center; padding: 48px 16px; color: var(--slate-500); }
.empty__title { font-size: 1.2rem; font-weight: 700; color: var(--slate-900); margin: 0 0 4px; }

.skeleton { background: var(--white); border-radius: var(--radius); border: 1px solid var(--slate-200); height: 420px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(226, 232, 240, .7), transparent);
  transform: translateX(-100%); animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.load-error { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecaca; padding: 16px; border-radius: var(--radius); }

/* ---------------- Footer ---------------- */
.footer { background: var(--slate-900); color: var(--slate-400); padding: 28px 0; border-top: 3px solid transparent; border-image: var(--grad) 1; }
.footer p { margin: 4px 0; }
.footer strong { color: var(--white); }
.footer__small { font-size: .85rem; }

/* ---------------- Cart drawer ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, .55);
  opacity: 0; transition: opacity .25s;
}
.overlay.is-open { opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column;
  background: var(--white); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  visibility: hidden;
}
.drawer.is-open { transform: translateX(0); visibility: visible; }
.drawer:focus { outline: none; }

.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--slate-200);
}
.drawer__head h2 { margin: 0; font-size: 1.15rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 8px 16px 16px; -webkit-overflow-scrolling: touch; }
.drawer__foot { border-top: 1px solid var(--slate-200); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; background: var(--slate-50); }
.drawer__note { margin: -4px 0 2px; font-size: .8rem; color: var(--slate-500); }

.cart-empty { text-align: center; color: var(--slate-500); padding: 40px 0; }

.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-line { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--slate-100); }
.cart-line__img { width: 64px; height: 64px; border-radius: 10px; background: var(--slate-50); border: 1px solid var(--slate-200); object-fit: contain; padding: 4px; }
.cart-line__title { margin: 0; font-size: .92rem; font-weight: 600; line-height: 1.3; }
.cart-line__sku { margin: 2px 0 0; font-size: .74rem; color: var(--slate-500); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cart-line__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cart-line__price { font-weight: 700; }
.cart-line__each { font-size: .75rem; color: var(--slate-500); font-weight: 500; display: block; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--slate-200); border-radius: 10px; overflow: hidden; }
.qty button { width: 36px; height: 36px; border: 0; background: var(--slate-50); cursor: pointer; font-size: 1.1rem; font-weight: 700; }
.qty button:hover:not([disabled]) { background: var(--slate-200); }
.qty button[disabled] { opacity: .4; cursor: not-allowed; }
.qty output { min-width: 36px; text-align: center; font-weight: 700; font-size: .95rem; }

.link-btn { background: none; border: 0; padding: 4px 0; color: var(--slate-500); text-decoration: underline; cursor: pointer; font-size: .82rem; }
.link-btn:hover { color: var(--bad); }

.subtotal { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.subtotal strong { font-size: 1.35rem; letter-spacing: -.02em; }

.checkout-msg { margin: 0; font-size: .85rem; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

/* ---------------- B2B panel ---------------- */
.b2b { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: var(--slate-50); border: 1px solid var(--slate-200); }
.b2b h3 { margin: 0 0 4px; font-size: 1.05rem; }
.b2b__lead { margin: 0 0 12px; font-size: .86rem; color: var(--slate-500); }
.field { display: grid; gap: 4px; margin: 0 0 10px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-size: .82rem; font-weight: 600; color: var(--slate-700); padding: 0; }
.field input:not([type="radio"]):not([type="checkbox"]), .field textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--slate-200); background: var(--white); font-size: 1rem;
}
.field input:focus, .field textarea:focus { outline: 0; border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.field-row { display: grid; gap: 0 10px; grid-template-columns: 1fr; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.radio {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--slate-200); background: var(--white);
  font-size: .9rem; font-weight: 500;
}
.radio:has(input:checked) { border-color: var(--brand-1); background: #eef2ff; color: var(--brand-1); font-weight: 600; }
.radio input { accent-color: var(--brand-1); width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
.form-error { margin: 0 0 10px; color: var(--bad); font-size: .85rem; font-weight: 600; }

.summary { margin-top: 14px; display: grid; gap: 8px; }
.summary__label { font-size: .82rem; font-weight: 600; color: var(--slate-700); }
.summary textarea {
  width: 100%; border-radius: 10px; border: 1px solid var(--slate-200); padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; line-height: 1.45;
  background: var(--white); resize: vertical;
}
.summary__actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.summary__actions .btn { padding: 0 10px; white-space: nowrap; font-size: .9rem; }
.summary__hint { margin: 0; font-size: .82rem; color: var(--ok); min-height: 1.2em; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0;
  background: var(--slate-900); color: var(--white); padding: 11px 18px; border-radius: 999px;
  font-size: .92rem; font-weight: 600; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Small phones: fit all four category chips ---------------- */
@media (max-width: 559px) {
  .chip { padding: 0 12px; font-size: .86rem; }
  .filters { gap: 6px; }
}

/* ---------------- Larger screens ---------------- */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr 1fr; }
  .summary__actions { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 860px) {
  .hero { padding: 56px 0 40px; }
  .controls { grid-template-columns: minmax(280px, 1fr) auto; align-items: center; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
}

@media (min-width: 1140px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
