/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f4f5f7; color: #1a1f36; }
a { cursor: pointer; }

/* ── Variables (matches Hydrofire intranet) ────────────────────────────────── */
:root {
  --red:        #C9222C;
  --red-dark:   #a81b24;
  --red-bg:     rgba(201,34,44,0.08);
  --red-bd:     rgba(201,34,44,0.22);
  --green:      #22a060;
  --green-bg:   rgba(62,207,142,0.08);
  --green-bd:   rgba(62,207,142,0.22);
  --orange:     #f5a623;
  --orange-bg:  rgba(245,166,35,0.08);
  --orange-bd:  rgba(245,166,35,0.22);
  --blue:       #2675BB;
  --muted:      #8a93a8;
  --border:     #e2e5ec;
  --surface:    #fff;
  --surface2:   #f0f1f4;
  --text:       #1a1f36;
  --radius:     8px;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 76px; display: flex; align-items: center; gap: 16px; }
.topbar-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; flex-shrink: 0; }
.topbar-logo img { height: 68px; }
.topbar-brand { font-size: 20px; font-weight: 800; color: var(--red); letter-spacing: -.5px; }
.topbar-tag { font-size: 10px; font-weight: 700; background: var(--red); color: #fff; padding: 2px 6px; border-radius: 4px; letter-spacing: .05em; }
.topbar-search { flex: 1; max-width: 520px; }
.topbar-search input {
  width: 100%; padding: 8px 14px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; outline: none; background: var(--surface2); transition: border .15s;
}
.topbar-search input:focus { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgba(192,57,43,.08); }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.cart-btn { position: relative; background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; border-radius: 6px; }
.cart-btn:hover { background: var(--surface2); }

.location-btn {
  display: flex; align-items: center; gap: 6px; background: none;
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px;
  cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap;
}
.location-btn:hover { background: var(--surface2); }
.location-btn svg { flex-shrink: 0; color: var(--red); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-box {
  background: #fff; border-radius: 12px; padding: 28px 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,.18); width: 90%; max-width: 480px;
}
.loc-opt {
  width: 100%; padding: 13px 16px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s;
}
.loc-opt:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.cart-badge {
  position: absolute; top: -2px; right: -4px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

.account-menu { position: relative; }
.account-btn {
  display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px 6px 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text);
}
.account-btn:hover { background: var(--surface2); }
.account-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.10);
  min-width: 160px; z-index: 200; overflow: hidden;
}
.account-dropdown a {
  display: block; padding: 10px 16px; font-size: 13px; color: var(--text); text-decoration: none;
}
.account-dropdown a:hover { background: var(--surface2); }

/* ── Specials banner ───────────────────────────────────────────────────────── */
.specials-banner {
  background: var(--red); color: #fff; text-align: center; padding: 10px 24px;
  font-size: 14px; font-weight: 600; letter-spacing: .02em;
}

/* ── Category nav ──────────────────────────────────────────────────────────── */
.cat-nav { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 60px; z-index: 99; }
.cat-nav-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; }
.cat-nav-inner::-webkit-scrollbar { display: none; }
.cat-btn {
  padding: 12px 16px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s;
}
.cat-btn:hover { color: var(--text); }
.cat-btn.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main { max-width: 1280px; margin: 0 auto; padding: 28px 24px; }

/* ── Product grid ──────────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.product-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; transition: box-shadow .15s, transform .15s; cursor: pointer;
}
.product-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.10); transform: translateY(-2px); }
.product-img { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--surface2); }
.product-img-placeholder { width: 100%; aspect-ratio: 1/1; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: #ccc; }
.product-body { padding: 12px; }
.product-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.35; }
.product-sku { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 8px; }
.product-rrp { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.product-price { font-size: 14px; font-weight: 600; color: var(--blue); margin-bottom: 2px; }
.product-vat { font-size: 11px; color: var(--muted); margin-top: 1px; }
.stock-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px; margin-bottom: 8px; }
.stock-in    { background: var(--green-bg); color: var(--green); }
.stock-low   { background: var(--orange-bg); color: var(--orange); }
.stock-out   { background: #f3f4f6; color: var(--muted); }
.special-ribbon { background: #e53e3e; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; display: inline-block; margin-bottom: 6px; letter-spacing: .3px; }
.add-to-cart-btn {
  width: 100%; padding: 8px; background: var(--red); color: #fff; border: none;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.add-to-cart-btn:hover { background: var(--red-dark); }
.add-to-cart-btn:disabled { background: #d1d5db; cursor: not-allowed; }
.btn-load-more { padding: 10px 32px; background: var(--red); color: #fff; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-load-more:hover { background: var(--red-dark); }
.btn-load-more:disabled { background: #d1d5db; cursor: not-allowed; }
.fp-filter-btn { padding: 5px 12px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); border-radius: 20px; background: #fff; color: var(--muted); cursor: pointer; transition: all .15s; white-space: nowrap; }
.fp-filter-btn:hover { border-color: var(--red); color: var(--red); }
.fp-filter-btn.active { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }

/* ── Cart drawer ───────────────────────────────────────────────────────────── */
.cart-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 300; }
.cart-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 380px; max-width: 100vw;
  background: #fff; z-index: 301; display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.cart-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; }
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item-img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--surface2); flex-shrink: 0; }
.cart-item-body { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 500; }
.cart-item-sku  { font-size: 11px; color: var(--muted); font-family: monospace; }
.cart-item-price { font-size: 13px; font-weight: 600; color: var(--red); margin-top: 4px; }
.cart-item-qty  { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.qty-btn { width: 26px; height: 26px; border: 1px solid var(--border); background: none; border-radius: 4px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.qty-val { font-size: 14px; font-weight: 600; min-width: 24px; text-align: center; }
.cart-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.cart-totals { margin-bottom: 14px; }
.cart-total-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.cart-total-row.grand { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.checkout-btn {
  width: 100%; padding: 12px; background: var(--red); color: #fff; border: none;
  border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.checkout-btn:hover { background: var(--red-dark); }
.cart-empty { text-align: center; color: var(--muted); font-size: 14px; padding: 40px 0; }

/* ── Pages ─────────────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p  { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* Orders table */
.orders-summary { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.summary-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; flex: 1; min-width: 160px; }
.summary-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.summary-card.overdue .value { color: var(--red); }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.data-table th { background: var(--surface2); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; text-align: left; }
.data-table td { padding: 12px 14px; font-size: 13px; border-top: 1px solid var(--border); }
.data-table tr:hover td { background: var(--surface2); }
.data-table tr.overdue td { border-left: 3px solid var(--red); }

/* Account page */
.account-section { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 24px; margin-bottom: 20px; }
.account-section h2 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-field input {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none;
}
.form-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(192,57,43,.08); }
.form-field input[readonly] { background: var(--surface2); color: var(--muted); cursor: not-allowed; }
.btn-save { padding: 9px 20px; background: var(--red); color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-save:hover { background: var(--red-dark); }

/* Status badges */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px; }
.badge-paid     { background: var(--green-bg); color: var(--green); }
.badge-unpaid   { background: var(--orange-bg); color: var(--orange); }
.badge-overdue  { background: var(--red-bg); color: var(--red); }
.badge-fulfilled  { background: #eff6ff; color: #1d4ed8; }
.badge-cancelled  { background: var(--red-bg); color: var(--red); }
.badge-partial  { background: var(--orange-bg); color: var(--orange); }

/* Toasts */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 11px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: slideIn .2s ease;
}
.toast.err { background: #991b1b; }
.toast.ok  { background: #166534; }
@keyframes slideIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar-search { display: none; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .orders-summary { flex-direction: column; }
  .cart-drawer { width: 100vw; }
}
