/* R42 产品展示 H5小程序 */
:root {
  --primary: #FF6B35; --bg: #F5F5F5; --card: #FFF; --text: #333; --muted: #999; --border: #eee;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  padding-bottom: calc(8.5rem + env(safe-area-inset-bottom));
}
img { max-width: 100%; display: block; }
button, a { font: inherit; color: inherit; }
a { text-decoration: none; }

.mp-navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1rem; background: var(--primary); color: #fff;
}
.mp-navbar h1 { flex: 1; font-size: 1rem; text-align: center; font-weight: 700; }
.mp-navbar__back, .mp-navbar__search { width: 2rem; text-align: center; color: #fff; }

.mp-tabbar {
  position: fixed; left: 0; right: 0; bottom: calc(4.25rem + env(safe-area-inset-bottom));
  z-index: 200; display: flex; background: var(--card); border-top: 1px solid var(--border);
}
.mp-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: .4rem 0; font-size: .62rem; color: var(--muted); position: relative;
}
.mp-tab.active { color: var(--primary); font-weight: 700; }
.mp-tab__icon { font-size: 1.1rem; position: relative; }
.tab-badge {
  position: absolute; top: -4px; right: -8px; min-width: 14px; height: 14px;
  background: var(--primary); color: #fff; border-radius: 999px; font-size: .55rem; line-height: 14px; text-align: center;
}

.contact-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 210;
  padding: .4rem .75rem calc(.4rem + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--border);
}
.contact-footer__btns { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; }
.contact-footer__cta, .contact-footer__btn {
  padding: .38rem .8rem; border-radius: 999px; font-size: .72rem; font-weight: 600;
}
.contact-footer__cta { background: var(--primary); color: #fff; border: none; }
.contact-footer__btn { background: var(--card); border: 1px solid var(--border); cursor: pointer; }
.contact-footer__brand { text-align: center; font-size: .6rem; color: var(--muted); margin-top: .3rem; }

.search-bar {
  display: flex; align-items: center; gap: .5rem; margin: .75rem 1rem;
  padding: .55rem .85rem; background: var(--card); border-radius: 999px; color: var(--muted); font-size: .85rem;
}
.banner-swiper { margin: 0 1rem .75rem; border-radius: 10px; overflow: hidden; }
.banner-swiper img { width: 100%; height: 140px; object-fit: cover; }

.cat-tabs { display: flex; gap: .4rem; overflow-x: auto; padding: 0 1rem .75rem; -webkit-overflow-scrolling: touch; }
.cat-tab {
  flex-shrink: 0; padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); font-size: .78rem; cursor: pointer;
}
.cat-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 0 1rem .5rem; font-size: .78rem; color: var(--muted); }
.toolbar button { background: none; border: none; color: var(--text); margin-right: .5rem; cursor: pointer; }
.sort-menu { padding: 0 1rem .5rem; }
.sort-menu button { display: block; width: 100%; text-align: left; padding: .45rem 0; background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer; }
.filter-tags { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 1rem .5rem; }
.filter-tag { font-size: .68rem; padding: .2rem .5rem; border-radius: 999px; background: rgba(255,107,53,.12); color: var(--primary); }

.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; padding: 0 1rem 1rem; }
.product-card { background: var(--card); border-radius: 10px; overflow: hidden; position: relative; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.product-card__img { position: relative; aspect-ratio: 1; }
.product-card__img img { width: 100%; height: 100%; object-fit: cover; }
.card-tag { position: absolute; top: 6px; left: 6px; font-size: .6rem; padding: .15rem .35rem; border-radius: 4px; color: #fff; }
.card-tag--hot { background: #FF3B30; }
.card-tag--new { background: #34C759; }
.product-card__body { padding: .55rem; }
.product-card__body h3 { font-size: .78rem; line-height: 1.35; margin-bottom: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card__brand { font-size: .65rem; color: var(--muted); }
.product-card__price strong { color: var(--primary); font-size: .88rem; }
.product-card__price s { font-size: .65rem; color: var(--muted); margin-left: .25rem; }
.product-card__cart {
  position: absolute; right: .45rem; bottom: .45rem; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none; font-size: 1rem; line-height: 26px; cursor: pointer;
}
.list-tip, .empty { text-align: center; color: var(--muted); padding: 1rem; font-size: .82rem; }

.sheet { position: fixed; inset: 0; z-index: 300; }
.sheet__mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet__panel {
  position: absolute; background: var(--card); padding: 1rem; max-height: 85vh; overflow-y: auto;
}
.sheet:not(.sheet--bottom) .sheet__panel { left: 0; top: 0; bottom: 0; width: 85vw; }
.sheet--bottom .sheet__panel { left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; }
.sheet__head { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.sheet__label { font-size: .78rem; color: var(--muted); margin: .75rem 0 .35rem; }
.sheet__tags, .sheet__colors { display: flex; flex-wrap: wrap; gap: .4rem; }
.sheet-tag { padding: .35rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); font-size: .72rem; cursor: pointer; }
.sheet-tag.active { border-color: var(--primary); color: var(--primary); }
.color-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.color-dot.active { box-shadow: 0 0 0 2px var(--primary); }
.sheet label { display: block; font-size: .78rem; margin-bottom: .5rem; }
.sheet input { width: 100%; padding: .45rem; border: 1px solid var(--border); border-radius: 6px; margin-top: .25rem; }

.sku-head { display: flex; gap: .75rem; margin-bottom: 1rem; }
.sku-head img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.sku-group { margin-bottom: .75rem; }
.sku-group > span { font-size: .78rem; color: var(--muted); }
.sku-colors, .sku-opts { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.sku-color { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #fff; cursor: pointer; }
.sku-color.active { outline: 2px solid var(--primary); }
.sku-color.disabled, .sku-opt.disabled { opacity: .35; pointer-events: none; }
.sku-opt { padding: .35rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; font-size: .78rem; }
.sku-opt.active { border-color: var(--primary); color: var(--primary); }
.sku-qty { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; }
.sku-qty button { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: .65rem 1rem; border-radius: 999px; font-weight: 600; border: none; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-block { display: block; width: 100%; }

.page-product { padding-bottom: 4.5rem; }
.gallery-main img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.thumb-strip { display: flex; gap: .4rem; padding: .5rem 1rem; overflow-x: auto; }
.thumb { flex-shrink: 0; width: 56px; height: 56px; border: 2px solid transparent; border-radius: 6px; overflow: hidden; padding: 0; cursor: pointer; background: none; }
.thumb.active { border-color: var(--primary); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.price-block { padding: .75rem 1rem; background: var(--card); }
.price { font-size: 1.35rem; color: var(--primary); }
.price-block s { color: var(--muted); margin-left: .35rem; }
.promos span { display: inline-block; font-size: .65rem; padding: .15rem .4rem; margin: .35rem .25rem 0 0; border-radius: 4px; background: rgba(255,107,53,.12); color: var(--primary); }
.sold { font-size: .72rem; color: var(--muted); margin-top: .35rem; }
.p-name { padding: .75rem 1rem; font-size: .95rem; background: var(--card); margin-top: .5rem; }
.p-name span { color: var(--primary); font-size: .78rem; }
.sku-entry { display: block; width: calc(100% - 2rem); margin: .5rem 1rem; padding: .65rem; background: var(--card); border: 1px solid var(--border); border-radius: 8px; text-align: left; cursor: pointer; }
.delivery, .desc { margin: .5rem 1rem; padding: .75rem; background: var(--card); border-radius: 8px; font-size: .82rem; }
.delivery-extra { color: var(--muted); margin-top: .25rem; }
.spec-table { width: calc(100% - 2rem); margin: .5rem 1rem; background: var(--card); border-collapse: collapse; font-size: .78rem; border-radius: 8px; overflow: hidden; }
.spec-table th, .spec-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border); text-align: left; }
.spec-table th { color: var(--muted); width: 30%; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: calc(4.25rem + env(safe-area-inset-bottom));
  z-index: 150; display: flex; align-items: center; background: var(--card); border-top: 1px solid var(--border); padding: .35rem;
}
.bottom-bar button, .bottom-bar a { flex: 0 0 auto; padding: .35rem .5rem; background: none; border: none; font-size: .65rem; text-align: center; cursor: pointer; }
.btn-cart, .btn-buy { flex: 1 !important; margin: 0 .2rem; padding: .55rem !important; border-radius: 999px; color: #fff !important; font-size: .82rem !important; }
.btn-cart { background: #FFB347 !important; }
.btn-buy { background: var(--primary) !important; }

.page-category { padding: 1rem; }
.cat-card {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: 1rem; margin-bottom: .5rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; font-size: .9rem;
}

.page-cart { padding: 1rem; }
.cart-item { display: flex; gap: .65rem; align-items: center; padding: .75rem; background: var(--card); border-radius: 10px; margin-bottom: .5rem; }
.cart-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.cart-item h4 { font-size: .82rem; }
.cart-item p { font-size: .72rem; color: var(--muted); }
.cart-footer {
  position: fixed; left: 0; right: 0; bottom: calc(4.25rem + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; padding: .65rem 1rem;
  background: var(--card); border-top: 1px solid var(--border); z-index: 120;
}

.page-user { padding: 1rem; }
.user-header { display: flex; gap: .75rem; align-items: center; padding: 1rem; background: var(--card); border-radius: 12px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.user-stats { display: flex; gap: 1rem; margin: .75rem 0; }
.user-stats div { flex: 1; text-align: center; padding: .75rem; background: var(--card); border-radius: 10px; }
.user-stats strong { display: block; font-size: 1.1rem; color: var(--primary); }
.user-link { display: block; padding: .75rem 1rem; margin-bottom: .5rem; background: var(--card); border-radius: 10px; }
.user-note { font-size: .72rem; color: var(--muted); margin-top: 1rem; line-height: 1.6; }

.page-search { padding: 1rem; }
.page-search input { width: 100%; padding: .65rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem; }
.search-section { margin-bottom: 1rem; }
.search-section__head { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.search-section__head button { background: none; border: none; color: var(--primary); cursor: pointer; }
.search-chip { display: inline-block; margin: 0 .35rem .35rem 0; padding: .35rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-size: .75rem; cursor: pointer; }

.mp-toast {
  position: fixed; left: 50%; bottom: calc(7rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: .5rem 1rem; border-radius: 999px; font-size: .78rem;
  z-index: 999; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mp-toast--show { opacity: 1; }

body[data-page="product"] .mp-tabbar { display: none; }
body[data-page="search"] .mp-tabbar { display: none; }
