/* 永豐順客戶前台共用樣式 */

.shop-body {
  background: #fafafa;
  min-height: 100vh;
}

.shop-shell { max-width: 480px; margin: 0 auto; padding: 0; }

@media (min-width: 720px) {
  .shop-shell { max-width: 720px; }
}

/* 登入頁 */
.shop-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 24px;
  background: var(--bg);
}
.shop-login-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  /* belt-and-suspenders: margin auto + flex centering both apply */
  margin: 0 auto;
  /* prevent content inside (e.g. flex rows) from overflowing the card */
  overflow: hidden;
}

/* RWD: 手機螢幕全寬 */
@media (max-width: 767px) {
  .shop-login {
    padding: 0;
    align-items: flex-start;
  }
  .shop-login-card {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    padding: 28px 20px;
    overflow: visible;
  }
}

/* RWD: 桌面螢幕置中固定寬度 */
@media (min-width: 768px) {
  .shop-login {
    padding: 40px 24px;
  }
  .shop-login-card {
    max-width: 440px;
  }
}
.brand-large {
  text-align: center;
  margin-bottom: 28px;
}
.brand-large .logo {
  font-size: 34px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}
.brand-large .sub {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 14px;
}

.phone-input { font-size: 18px; height: 52px; letter-spacing: 1px; }

/* OTP 6 格 */
.otp-row {
  display: flex; gap: 8px; justify-content: space-between;
  margin: 12px 0 10px;
  /* 防止 row 本身溢出 card */
  width: 100%;
}
.otp-cell {
  flex: 1 1 0;    /* flex-basis: 0 → 6 格均分，不依賴 input 的 intrinsic size */
  min-width: 0;   /* 允許 flex item 縮小到小於 input 預設最小寬度 */
  width: 0;       /* 強制以 flex 計算為準，忽略 input 的 content-based min-width */
  height: 56px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  background: white;
  font-family: inherit;
}
.otp-cell:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}
.otp-cell.filled { border-color: var(--primary); background: #fff8f6; }

.countdown-text { color: var(--text-muted); font-size: 13px; text-align: center; margin-top: 6px; }
.resend-link { color: var(--primary); cursor: pointer; font-weight: 600; }
.resend-link:hover { text-decoration: underline; }
.resend-link.disabled { color: var(--text-muted); cursor: not-allowed; pointer-events: none; }

/* Step 進度條 */
.step-progress {
  display: flex; gap: 6px; margin-bottom: 20px;
}
.step-dot {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.step-dot.active { background: var(--primary); }

/* Wizard */
.wizard-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.wizard-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }

.choice-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: 2px solid var(--border-strong);
  border-radius: var(--radius); cursor: pointer;
  margin-bottom: 10px;
  background: white;
  transition: all .15s;
}
.choice-card:hover { border-color: var(--primary); }
.choice-card.selected { border-color: var(--primary); background: var(--primary-light); }
.choice-card .ico {
  width: 40px; height: 40px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.choice-card.selected .ico { background: var(--primary); color: white; }
.choice-card .body { flex: 1; }
.choice-card .body b { display: block; font-size: 15px; }
.choice-card .body .desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.wizard-nav { display: flex; gap: 8px; margin-top: 20px; }
.wizard-nav .btn { flex: 1; }
.wizard-nav .btn-back { flex: 0 0 auto; }

/* ============= Shop App Shell ============= */
.app-shell {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 76px; /* 預留底部導覽 */
  min-height: 100vh;
}
.shop-topbar {
  position: sticky; top: 0; z-index: 20;
  background: white;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.shop-topbar .greet {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}
.shop-topbar .greet small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }
.shop-topbar .cart-icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--primary-light);
  border: none; cursor: pointer;
  color: var(--primary);
  font-size: 18px;
}
.shop-topbar .cart-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  background: var(--danger); color: white;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.shop-topbar .cart-badge.hidden { display: none; }

.search-box {
  margin: 12px 18px;
  position: relative;
}
.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.search-box input:focus { background: white; border-color: var(--primary); }
.search-box::before {
  content: '🔍';
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px;
}

/* 底部導覽 */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  height: 60px;
  z-index: 20;
}
.bottom-nav .item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  position: relative;
}
.bottom-nav .item .ico { font-size: 20px; }
.bottom-nav .item.active { color: var(--primary); }
.bottom-nav .item .badge {
  position: absolute;
  top: 6px; left: 50%;
  margin-left: 4px;
  min-width: 16px; height: 16px;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.bottom-nav .item .badge.hidden { display: none; }

/* 區塊標題 */
.section-head {
  display: flex; align-items: center;
  margin: 18px 18px 10px;
}
.section-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.section-head .more { margin-left: auto; font-size: 13px; color: var(--primary); cursor: pointer; }

/* 大分類橫向滑動 */
.category-row {
  display: flex; gap: 12px;
  padding: 0 18px;
  overflow-x: auto;
  scroll-behavior: smooth;
}
.category-row::-webkit-scrollbar { display: none; }
.cat-card {
  flex: 0 0 auto;
  width: 86px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: transform .1s;
}
.cat-card:hover { transform: translateY(-2px); text-decoration: none; }
.cat-card .emoji { font-size: 32px; line-height: 1; margin-bottom: 6px; }
.cat-card .name { font-size: 13px; font-weight: 600; }

/* 特價橫幅（橫向滑動） */
.special-row {
  display: flex; gap: 12px;
  padding: 0 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.special-row::-webkit-scrollbar { display: none; }
.special-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
  background: linear-gradient(135deg, #C0392B, #E74C3C);
  color: white;
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.special-card .tag {
  display: inline-block;
  background: white; color: var(--primary);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  margin-bottom: 8px;
}
.special-card .name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.special-card .price { font-size: 14px; opacity: .95; }
.special-card .price-big { font-size: 22px; font-weight: 700; }
.special-card .strike { text-decoration: line-through; opacity: .7; font-size: 12px; margin-left: 6px; }

/* 商品 grid */
.product-grid {
  padding: 0 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
.product-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform .1s, box-shadow .1s;
  display: flex; flex-direction: column;
  position: relative;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.product-card.oos { opacity: .55; }
.product-card .img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  overflow: hidden;
}
.product-card .img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.product-card .tag {
  position: absolute; top: 8px; right: 8px;
  background: var(--primary); color: white;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}
.product-card .oos-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.4); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.product-card .body {
  padding: 10px 12px;
  display: flex; flex-direction: column;
  flex: 1;
}
.product-card .pname { font-size: 14px; font-weight: 700; line-height: 1.3; }
.product-card .pmeta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.product-card .pprice { margin-top: auto; padding-top: 8px; }
.product-card .price-amt { color: var(--primary); font-size: 16px; font-weight: 700; }
.product-card .price-amt small { font-weight: 400; font-size: 11px; color: var(--text-muted); }
.product-card .price-strike { text-decoration: line-through; color: var(--text-muted); font-size: 11px; margin-left: 4px; }
.product-card .price-inquiry { color: var(--text-muted); font-size: 13px; font-weight: 600; }

/* 分類 tabs */
.cat-tabs {
  position: sticky; top: 70px;
  display: flex; gap: 8px;
  padding: 12px 18px;
  background: var(--bg);
  overflow-x: auto;
  z-index: 10;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  background: white;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.cat-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

.sub-cat-row {
  padding: 6px 18px 12px;
  display: flex; gap: 6px;
  overflow-x: auto;
}
.sub-cat-row::-webkit-scrollbar { display: none; }
.sub-cat-chip {
  flex: 0 0 auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  color: var(--text-muted);
}
.sub-cat-chip.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* 商品詳情 modal */
.product-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: none;
  align-items: flex-end;
}
.product-modal-backdrop.show { display: flex; }
@media (min-width: 720px) {
  .product-modal-backdrop { align-items: center; justify-content: center; }
}

.product-modal {
  background: white;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: slide-up .25s ease-out;
  overflow: hidden;
}
@media (min-width: 720px) {
  .product-modal { border-radius: 20px; max-height: 85vh; }
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.product-modal .close-btn {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  border: none; cursor: pointer;
  font-size: 18px;
  z-index: 2;
}
.product-modal .top-img {
  width: 100%; aspect-ratio: 4/3;
  background: #f3f4f6;
  position: relative;
}
.product-modal .top-img img { width: 100%; height: 100%; object-fit: cover; }
.product-modal .info { padding: 18px; flex: 1; overflow: auto; }
.product-modal h2 { margin: 0 0 4px; font-size: 20px; }
.product-modal .meta { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.product-modal .price-row {
  display: flex; align-items: baseline; gap: 6px; margin-bottom: 14px;
  font-size: 22px; font-weight: 700; color: var(--primary);
}
.product-modal .price-row small { font-weight: 400; font-size: 13px; color: var(--text-muted); }
.product-modal .price-strike { text-decoration: line-through; color: var(--text-muted); font-size: 14px; font-weight: 400; }

.unit-switch { display: flex; gap: 6px; margin-bottom: 12px; }
.unit-btn {
  flex: 1; padding: 8px; border: 1px solid var(--border-strong);
  background: white; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.unit-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.qty-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.qty-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border-strong);
  background: white; border-radius: 50%;
  font-size: 18px; cursor: pointer; font-family: inherit;
}
.qty-input {
  flex: 1; height: 44px; text-align: center;
  font-size: 18px; font-weight: 700;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
}

.conversion-box {
  background: #fff8f3;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  color: #6b3a1a;
}
.conversion-box b { color: var(--primary); }

.product-modal .stock-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.stock-現貨 { background: #dcfce7; color: #15803d; }
.stock-缺貨 { background: #fee2e2; color: #b91c1c; }
.stock-預購 { background: #dbeafe; color: #1d4ed8; }

.product-modal .footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: white;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .ico { font-size: 48px; margin-bottom: 12px; }
