/* ============================================================
   SHOP COMPANION v2.0 — Customer Panel Styles
   UPDATED: Logo via --logo-header token, mobile-first layout,
            sticky bottom navigation bar, touch-friendly targets,
            scan panel portrait optimization
   ============================================================ */

/* ── Header ── */
.cust-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,10,15,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.cust-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; gap: 12px; flex-wrap: nowrap;
}

/* Logo group — uses --logo-header token, object-fit preserves proportions */
.cust-logo { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.cust-logo-img {
  width: var(--logo-header, 40px);
  height: var(--logo-header, 40px);
  object-fit: contain;   /* preserve original proportions — no distortion */
  border-radius: 9px;
  box-shadow: 0 3px 12px rgba(26,107,255,0.3);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.cust-logo-img:hover { transform: scale(1.05); }

.cust-logo-title { font-family: var(--font-display); font-size: 1rem; color: var(--white); white-space: nowrap; }
.cust-logo-sub   { font-family: var(--font-data); font-size: 10px; color: var(--green); text-transform: uppercase; letter-spacing: 0.08em; }

/* User actions — right side of header */
.cust-user {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-body); font-size: 13px; color: var(--gray-200);
  flex-shrink: 0; min-width: 0;
}
.cust-user span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* ── Tab Bar (desktop — horizontal strip below header) ── */
.cust-tabs-bar { padding: 0 24px; border-top: 1px solid rgba(255,255,255,0.05); }
.cust-tabs {
  display: flex; gap: 0; overflow-x: auto; padding-bottom: 0;
  scrollbar-width: none;
}
.cust-tabs::-webkit-scrollbar { display: none; }

.cust-tab {
  padding: 13px 20px; background: none;
  border: none; border-bottom: 2px solid transparent;
  color: var(--gray-400); font-family: var(--font-subhead); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
  min-height: 44px; /* touch target */
}
.cust-tab:hover  { color: var(--white); }
.cust-tab.active { color: var(--blue-light); border-bottom-color: var(--blue); }

.cart-badge {
  background: var(--red); color: var(--white);
  border-radius: 999px; font-family: var(--font-data); font-size: 10px; font-weight: 700;
  padding: 1px 6px; margin-left: 4px; vertical-align: middle;
}

/* ── Main Panel ── */
.cust-main { padding: 24px; max-width: 1400px; margin: 0 auto; }
/* Bottom padding so sticky bottom-nav doesn't obscure content on mobile */
@media (max-width: 768px) {
  .cust-main { padding: 16px 14px 90px; /* 90px = bottom nav height + clearance */ }
}
.cust-panel { animation: fadeIn 0.2s ease; }

/* ── Shop Toolbar ── */
.shop-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ── Category Pills ── */
.category-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.pill {
  padding: 6px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent; color: var(--gray-200);
  font-family: var(--font-subhead); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  min-height: 34px; /* touch-friendly */
}
.pill:hover  { border-color: var(--blue-light); color: var(--blue-light); }
.pill.active { background: var(--blue); border-color: var(--blue); color: var(--white); }

/* ── Product Grid ── */
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px;
}
.product-card {
  background: var(--gray-800); border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.product-card:hover { border-color: rgba(26,107,255,0.4); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.product-card.out-of-stock { opacity: 0.45; pointer-events: none; }

.product-emoji { font-size: 2.8rem; line-height: 1; display: block; }
.product-name  { font-family: var(--font-body); font-weight: 700; font-size: 14px; line-height: 1.3; flex: 1; }
.product-type  { font-family: var(--font-data); font-size: 11px; color: var(--gray-400); margin-top: 1px; }
.product-meta  { font-family: var(--font-data); font-size: 11px; color: var(--gray-400); }
.product-expiry { font-family: var(--font-data); font-size: 10px; }
.product-price { font-family: var(--font-digital); font-size: 1.2rem; font-weight: 700; color: var(--blue-light); letter-spacing: 0.04em; }

.product-actions { display: flex; gap: 8px; }

/* Qty control — larger touch area */
.qty-control {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.05); border-radius: var(--radius-md); padding: 4px 8px;
}
.qty-btn {
  background: none; border: none; color: var(--white);
  font-size: 16px; width: 32px; height: 32px;
  cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.qty-btn:hover { background: rgba(255,255,255,0.12); }
.qty-val { font-family: var(--font-digital); font-weight: 700; font-size: 13px; min-width: 20px; text-align: center; }

/* Add to cart — taller for easier tapping */
.add-cart-btn {
  flex: 1; background: var(--blue); border: none; border-radius: var(--radius-md);
  color: var(--white); font-family: var(--font-subhead); font-weight: 600; font-size: 13px;
  padding: 8px; min-height: 38px;
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.add-cart-btn:hover { background: var(--blue-light); }

.add-list-btn {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md); color: var(--gray-200); font-size: 15px;
  width: 38px; height: 38px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.add-list-btn:hover { background: rgba(255,217,77,0.15); border-color: var(--yellow); color: var(--yellow); }

/* ── Expiry Labels ── */
.expiry-soon { color: var(--yellow); }
.expiry-past { color: var(--red); }
.expiry-ok   { color: var(--green); }

/* ── Lists Tab ── */
.lists-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.lists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.list-card { background: var(--gray-800); border: 1px solid rgba(255,255,255,0.07); border-radius: var(--radius-lg); padding: 18px; transition: border-color var(--transition); }
.list-card:hover { border-color: rgba(26,107,255,0.3); }
.list-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list-name { font-family: var(--font-display); font-size: 0.95rem; }
.list-item-preview { font-family: var(--font-data); font-size: 12px; color: var(--gray-400); padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; }
.list-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ── Cart Tab ── */
.cart-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.cart-item {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  background: var(--gray-800); border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg); margin-bottom: 10px; transition: border-color var(--transition);
}
.cart-item:hover { border-color: rgba(26,107,255,0.3); }
.cart-item-emoji { font-size: 1.9rem; }
.cart-item-info  { flex: 1; min-width: 0; }
.cart-item-name  { font-family: var(--font-body); font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-unit  { font-family: var(--font-data); font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.cart-item-price { font-family: var(--font-digital); font-weight: 700; font-size: 13px; color: var(--blue-light); margin-top: 4px; }
.cart-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.cart-item-subtotal { font-family: var(--font-digital); font-weight: 700; font-size: 1rem; }
.cart-remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: 17px; min-width: 32px; min-height: 32px; }

.cart-summary-card { position: sticky; top: 100px; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; font-family: var(--font-body); font-size: 13px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.summary-row:last-of-type { border-bottom: none; }
.summary-total { display: flex; justify-content: space-between; padding: 14px 0 0; font-family: var(--font-digital); font-size: 1.3rem; font-weight: 700; color: var(--green); }

/* ── Voucher Input ── */
.voucher-row { display: flex; gap: 8px; margin: 12px 0; }
.voucher-row .form-input { flex: 1; font-family: var(--font-data); letter-spacing: 0.08em; }
.voucher-applied { color: var(--green); font-family: var(--font-data); font-size: 12px; margin-top: 4px; }

/* ── QR Tab ── */
.qr-layout { display: flex; justify-content: center; padding: 20px 0; }
#qrOutput canvas, #qrOutput img { border-radius: var(--radius-md); border: 4px solid var(--blue); }
.qr-cart-preview { text-align: left; font-size: 13px; color: var(--gray-200); margin-top: 16px; }
.qr-item-line { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-family: var(--font-data); }

/* ── Rewards Tab ── */
.rewards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.voucher-card { background: var(--gray-800); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.voucher-card.available { border-color: rgba(29,233,139,0.3); }
.voucher-code { font-family: var(--font-data); font-size: 1rem; font-weight: 700; color: var(--blue-light); letter-spacing: 0.12em; background: rgba(26,107,255,0.1); padding: 6px 14px; border-radius: var(--radius-sm); text-align: center; }
.voucher-detail { font-family: var(--font-body); font-size: 12px; color: var(--gray-400); }

/* ── Customer Select List ── */
.customer-select-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.customer-select-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); min-height: 56px; /* touch target */ }
.customer-select-item:hover { background: var(--blue-glow); border-color: rgba(26,107,255,0.4); }
.csi-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 14px; flex-shrink: 0; }
.csi-name  { font-family: var(--font-subhead); font-weight: 600; }
.csi-email { font-family: var(--font-data); font-size: 11px; color: var(--gray-400); }

/* ── Terms screen ── */
.terms-screen { max-width: 820px; margin: 60px auto; padding: 0 24px; display:flex; flex-direction:column; align-items:center; text-align:center; }
.terms-screen h1  { font-family: var(--font-display); margin-bottom: 8px; }
.terms-screen .lead { font-family: var(--font-body); color: var(--gray-400); margin-bottom: 24px; }
.terms-screen .terms-box { text-align: left; margin: 0 auto 20px; width:100%; max-width:720px; }
.terms-agree-row { display: flex; align-items: center; gap: 10px; margin-top: 20px; font-family: var(--font-body); font-size: 14px; }
.terms-agree-row input[type=checkbox] { width: 20px; height: 20px; cursor: pointer; }

/* ══════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION
   Replaces tab strip for mobile — sticky, icon+label,
   one-hand reachable zone. Tabs bar is hidden on mobile.
══════════════════════════════════════════════ */
.cust-bottom-nav {
  display: none; /* hidden on desktop */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: rgba(10,10,15,0.97);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.08);
  /* Safe area for notch phones */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.cust-bottom-nav-inner {
  display: flex; align-items: stretch;
  height: 62px;
}
.cust-bnav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none;
  color: var(--gray-400); font-family: var(--font-subhead); font-size: 10px; font-weight: 600;
  cursor: pointer; transition: color var(--transition), background var(--transition);
  padding: 6px 4px; position: relative;
  border-radius: 0;
}
.cust-bnav-btn:active { background: rgba(255,255,255,0.05); }
.cust-bnav-btn.active { color: var(--blue-light); }
.cust-bnav-btn.active::after {
  content: ''; position: absolute; top: 0; left: 20%; right: 20%; height: 2px;
  background: var(--blue); border-radius: 0 0 2px 2px;
}
.cust-bnav-icon { font-size: 20px; line-height: 1; }
.cust-bnav-label { font-size: 9px; letter-spacing: 0.03em; }

/* Badge on bottom nav cart button */
.cust-bnav-badge {
  position: absolute; top: 6px; right: calc(50% - 16px);
  background: var(--red); color: #fff;
  border-radius: 999px; font-family: var(--font-data); font-size: 9px; font-weight: 700;
  padding: 1px 5px; min-width: 16px; text-align: center;
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Customer Panel
══════════════════════════════════════════════ */

/* ── 768px: switch to mobile layout ── */
@media (max-width: 768px) {
  /* Show bottom nav, hide desktop tab bar */
  .cust-bottom-nav { display: block; }
  .cust-tabs-bar   { display: none; }

  /* Compact header */
  .cust-header-inner { padding: 10px 14px; }

  /* Logo: slightly smaller on mobile */
  .cust-logo-img { width: 34px; height: 34px; }
  .cust-logo-title { font-size: 0.88rem; }

  /* Welcome text: shorter */
  .cust-user span { max-width: 80px; }

  /* Single-column cart */
  .cart-layout { grid-template-columns: 1fr; }
  .cart-summary-card { position: static; }

  /* Product grid: 2 columns, larger touch area per card */
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .product-card { padding: 14px; }
  .product-emoji { font-size: 2.2rem; }

  /* Shop toolbar: vertical stack on narrow screens */
  .shop-toolbar { flex-direction: column; align-items: stretch; }

  /* Rewards: single column */
  .rewards-grid { grid-template-columns: 1fr; }

  /* QR output responsive */
  #qrOutput img, #qrOutput canvas { width: min(240px, 80vw); height: auto; }

  /* Scanner: full-width portrait */
  .scanner-wrap { max-width: 100%; }

  /* Lists: single column */
  .lists-grid { grid-template-columns: 1fr; }

  /* Terms screen padding */
  .terms-screen { margin: 20px auto; }
}

/* ── 480px: extra small phones ── */
@media (max-width: 480px) {
  .cust-header-inner { padding: 8px 12px; gap: 8px; }
  .cust-logo-img { width: 30px; height: 30px; border-radius: 7px; }
  .cust-logo-title { font-size: 0.8rem; }
  .cust-logo-sub { display: none; } /* hide on tiny screens */

  /* Show only icon + name in header actions */
  .cust-user .btn { padding: 5px 10px; font-size: 11px; min-height: 34px; }

  /* 2-column product grid minimum 140px */
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .product-card { padding: 12px; gap: 8px; }
  .product-price { font-size: 1rem; }

  /* Category pills: smaller */
  .pill { padding: 5px 12px; font-size: 11px; }

  /* Modal bottom-sheet style on mobile */
  .modal-box { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; max-height: 85vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  /* Cart items: compact */
  .cart-item { gap: 10px; padding: 10px; }
  .cart-item-emoji { font-size: 1.5rem; }

  /* QR: full width */
  #qrOutput img, #qrOutput canvas { width: min(220px, 72vw); height: auto; }
}

/* ── Light theme header ── */
.light-theme .cust-header { background: rgba(255,255,255,0.94); border-bottom: 1px solid rgba(10,10,15,0.06); }
.light-theme .cust-logo-title { color: var(--white); }
.light-theme .cust-logo-sub   { color: var(--green); }
.light-theme .cust-user       { color: var(--gray-400); }
.light-theme .cust-tabs-bar   { border-top-color: rgba(10,10,15,0.05); }
.light-theme .cust-bottom-nav { background: rgba(255,255,255,0.97); border-top-color: rgba(10,10,15,0.06); }
.light-theme .cust-bnav-btn   { color: var(--gray-400); }
.light-theme .cust-bnav-btn.active { color: var(--blue); }

/* Ensure Terms header + lead are centered across breakpoints */
.terms-screen { text-align: center !important; }
.terms-screen > h1, .terms-screen > .lead { display: block; margin-left: auto; margin-right: auto; }
.terms-screen .terms-box { max-width: 100%; margin: 0 auto 20px; text-align: left; }

/* ── Top Sellers Row ── */
.top-sellers-section {
  margin-bottom: 20px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(26,107,255,0.1) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(26,107,255,0.2);
  border-radius: var(--radius-lg);
}
.top-sellers-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.top-sellers-title {
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 800;
  color: var(--white); letter-spacing: 0.01em;
}
.top-sellers-sub {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--blue-light); text-transform: uppercase; letter-spacing: 0.1em;
  background: rgba(26,107,255,0.18); border: 1px solid rgba(26,107,255,0.3);
  border-radius: 4px; padding: 2px 8px;
}
.top-sellers-row {
  display: flex; gap: 10px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: none;
}
.top-sellers-row::-webkit-scrollbar { display: none; }
.top-seller-card {
  flex-shrink: 0;
  width: 136px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.top-seller-card:hover {
  background: rgba(26,107,255,0.15);
  border-color: rgba(26,107,255,0.45);
  transform: translateY(-2px);
}
.top-seller-rank {
  position: absolute; top: 7px; right: 8px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 800;
  color: var(--blue-light); opacity: 0.6;
}
.top-seller-rank.rank-1 { color: #ffd700; opacity: 1; }
.top-seller-rank.rank-2 { color: #c0c0c0; opacity: 1; }
.top-seller-rank.rank-3 { color: #cd7f32; opacity: 1; }
.top-seller-emoji { font-size: 1.8rem; line-height: 1; }
.top-seller-name {
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  color: var(--white); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.top-seller-price {
  font-family: var(--font-digital); font-size: 0.9rem; color: var(--blue-light);
  font-weight: 700; letter-spacing: 0.03em;
}
.top-seller-meta {
  font-family: var(--font-data); font-size: 10px; color: var(--gray-400);
}
.top-seller-bar-wrap {
  width: 100%; height: 3px; background: rgba(255,255,255,0.07); border-radius: 2px;
  margin-top: 2px;
}
.top-seller-bar {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--blue-light));
  transition: width 0.6s ease;
}
@media (max-width: 480px) {
  .top-sellers-section { padding: 12px 14px; }
  .top-seller-card { width: 118px; padding: 10px 8px; }
  .top-seller-emoji { font-size: 1.5rem; }
  .top-seller-name { font-size: 11px; }
}

/* ── Product card highlight (from top seller click) ── */
@keyframes highlightPulse {
  0%   { box-shadow: 0 0 0 0 rgba(26,107,255,0.6); border-color: rgba(26,107,255,0.9); }
  60%  { box-shadow: 0 0 0 8px rgba(26,107,255,0); border-color: rgba(26,107,255,0.5); }
  100% { box-shadow: none; border-color: rgba(255,255,255,0.07); }
}
.product-card.highlighted {
  animation: highlightPulse 1.6s ease forwards;
}
