/* 惠邻百货商城 前台样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --main: #ff4d4f;
  --main-dark: #e03c3e;
  --accent: #ff7a45;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #333333;
  --text-light: #777777;
  --border: #eeeeee;
  --gold: #faad14;
  --green: #52c41a;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; outline: none; }
.ic { vertical-align: -3px; flex-shrink: 0; }
.nav-link .ic { margin-right: 3px; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ===== 顶部 ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.logo img { height: 44px; }
.search-box { flex: 1; max-width: 460px; display: flex; border: 2px solid var(--main); border-radius: 20px; overflow: hidden; background: #fff; }
.search-box input { flex: 1; border: none; padding: 8px 16px; }
.search-box button { background: var(--main); color: #fff; padding: 0 22px; font-size: 14px; }
.top-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; font-size: 14px; }
.top-nav .nav-link { padding: 4px 2px; position: relative; }
.top-nav .nav-link:hover, .top-nav .nav-link.active { color: var(--main); }
.cart-badge { position: absolute; top: -4px; right: -14px; background: var(--main); color: #fff; border-radius: 9px; font-size: 11px; min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--main), var(--accent)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }

/* ===== 轮播图 ===== */
.banner { position: relative; border-radius: 12px; overflow: hidden; margin: 16px 0; }
.banner img { width: 100%; height: 300px; object-fit: cover; }
.banner-dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; }
.banner-dots span { width: 9px; height: 9px; border-radius: 5px; background: rgba(255,255,255,.55); cursor: pointer; transition: all .3s; }
.banner-dots span.on { width: 24px; background: #fff; }

/* ===== 分类入口 ===== */
.section { margin: 26px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; display: flex; align-items: center; }
.section-head h2::before { content: ''; display: inline-block; width: 4px; height: 20px; border-radius: 2px; background: linear-gradient(180deg, var(--main), var(--accent)); margin-right: 10px; }
.section-head h2 .sub { font-size: 13px; color: var(--text-light); font-weight: normal; margin-left: 8px; }
.section-head .more { color: var(--text-light); font-size: 13px; }
.section-head .more:hover { color: var(--main); }
.cat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.cat-card { background: var(--card); border-radius: 12px; padding: 18px 8px; text-align: center; transition: all .2s; box-shadow: 0 1px 4px rgba(0,0,0,.04); color: #8a8a8a; }
.cat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.08); color: var(--main); }
.cat-card .icon { font-size: 34px; height: 40px; display: flex; align-items: center; justify-content: center; }
.cat-card .name { margin-top: 8px; font-size: 14px; color: var(--text); }
.cat-card:hover .name { color: var(--main); }

/* ===== 商品网格 ===== */
.product-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.product-card { background: var(--card); border-radius: 12px; overflow: hidden; transition: all .2s; box-shadow: 0 1px 4px rgba(0,0,0,.04); display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.09); }
.product-card .p-img { aspect-ratio: 1; background: #fafafa; }
.product-card .p-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card .p-body { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; }
.product-card .p-name { font-size: 14px; line-height: 1.45; height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.product-card .p-meta { margin-top: 8px; display: flex; align-items: baseline; gap: 8px; }
.price { color: var(--main); font-size: 20px; font-weight: 700; }
.price::before { content: '¥'; font-size: 13px; }
.price-small::before { font-size: 12px; }
.price-small { font-size: 16px; }
.sales { color: var(--text-light); font-size: 12px; }
.product-card .p-tag { margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--gold); }
.product-card .p-actions { margin-top: 10px; display: flex; gap: 8px; }
.product-card .p-actions button { flex: 1; padding: 8px 0; border-radius: 18px; font-size: 13px; }

/* ===== 按钮 ===== */
.btn { display: inline-block; padding: 9px 22px; border-radius: 20px; font-size: 14px; text-align: center; transition: all .2s; line-height: 1.4; }
.btn-main { background: var(--main); color: #fff; }
.btn-main:hover { background: var(--main-dark); }
.btn-main.disabled, .btn.disabled { background: #ccc !important; cursor: not-allowed; }
.btn-ghost { border: 1px solid var(--main); color: var(--main); background: #fff; }
.btn-ghost:hover { background: #fff1f0; }
.btn-gray { border: 1px solid #ddd; color: #666; background: #fff; }
.btn-gray:hover { border-color: #bbb; color: #333; }
.btn-sm { padding: 5px 14px; font-size: 12px; border-radius: 14px; }
.btn-lg { padding: 13px 38px; font-size: 16px; border-radius: 26px; }
.btn-block { display: block; width: 100%; }

/* ===== 面包屑/筛选 ===== */
.filter-bar { background: #fff; border-radius: 12px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filter-bar .chip { padding: 5px 16px; border-radius: 15px; background: #f5f5f5; color: #555; font-size: 13px; }
.filter-bar .chip.on { background: var(--main); color: #fff; }
.filter-bar .chip:hover:not(.on) { background: #eee; }
.filter-bar .divider { width: 1px; height: 18px; background: #e5e5e5; margin: 0 6px; }

/* ===== 商品详情 ===== */
.detail { background: #fff; border-radius: 12px; padding: 24px; display: grid; grid-template-columns: 400px 1fr; gap: 30px; }
.detail .d-img img { width: 100%; border-radius: 10px; aspect-ratio: 1; object-fit: cover; }
.detail h1 { font-size: 20px; line-height: 1.5; margin-bottom: 10px; }
.detail .d-price-row { background: #fff1f0; border-radius: 8px; padding: 14px 16px; display: flex; align-items: baseline; gap: 16px; margin: 12px 0; }
.detail .d-price-row .price { font-size: 28px; }
.detail .d-points { background: #fffbe6; border: 1px solid #ffe58f; color: #8c6d1f; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 12px 0; display: flex; align-items: center; gap: 8px; }
.qty-row { display: flex; align-items: center; gap: 14px; margin: 18px 0; }
.qty-ctrl { display: flex; border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
.qty-ctrl button { width: 34px; height: 34px; font-size: 16px; color: #555; background: #fafafa; }
.qty-ctrl button:hover:not(:disabled) { color: var(--main); }
.qty-ctrl button:disabled { color: #ccc; cursor: not-allowed; }
.qty-ctrl input { width: 52px; height: 34px; text-align: center; border: none; border-left: 1px solid #ddd; border-right: 1px solid #ddd; }
.d-actions { display: flex; gap: 14px; margin-top: 22px; }
.d-actions .btn { padding: 12px 40px; font-size: 15px; border-radius: 24px; }
.d-stock { color: var(--text-light); font-size: 13px; }

/* ===== 购物车 ===== */
.cart-page { background: #fff; border-radius: 12px; padding: 6px 20px 20px; }
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th { text-align: left; padding: 14px 8px; color: var(--text-light); font-size: 13px; font-weight: normal; border-bottom: 1px solid var(--border); }
.cart-table td { padding: 16px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cart-item .c-info { display: flex; align-items: center; gap: 12px; }
.cart-item img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; }
.cart-item .c-name { max-width: 340px; }
.cart-item .c-name:hover { color: var(--main); }
.checkbox { width: 17px; height: 17px; accent-color: var(--main); cursor: pointer; }
.cart-footer { display: flex; align-items: center; gap: 18px; padding: 16px 8px 0; flex-wrap: wrap; }
.cart-footer .total-box { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.cart-footer .sum { color: var(--main); font-size: 24px; font-weight: 700; }

/* ===== 表单 ===== */
.form-card { background: #fff; border-radius: 12px; padding: 28px; max-width: 520px; margin: 30px auto; }
.form-card h2 { margin-bottom: 20px; text-align: center; }
.form-item { margin-bottom: 16px; }
.form-item label { display: block; margin-bottom: 6px; color: #555; font-size: 13px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; transition: border .2s;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--main); }
.form-item textarea { resize: vertical; min-height: 70px; }
.form-error { color: var(--main); font-size: 13px; margin-top: 4px; min-height: 18px; }
.form-foot { text-align: center; margin-top: 8px; color: var(--text-light); font-size: 13px; }
.form-foot a { color: var(--main); }

/* ===== 结算页 ===== */
.checkout-page { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.panel { background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.panel h3 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.addr-item { border: 2px solid var(--border); border-radius: 10px; padding: 13px 16px; margin-bottom: 10px; cursor: pointer; transition: all .2s; position: relative; }
.addr-item.on { border-color: var(--main); background: #fff7f6; }
.addr-item .a-line1 { display: flex; gap: 10px; align-items: baseline; }
.addr-item .a-name { font-weight: 600; }
.addr-item .a-default { font-size: 11px; color: var(--main); border: 1px solid var(--main); border-radius: 3px; padding: 0 4px; }
.addr-item .a-detail { color: var(--text-light); font-size: 13px; margin-top: 2px; }
.pay-method { display: flex; gap: 12px; }
.pay-method .pm { flex: 1; border: 2px solid var(--border); border-radius: 10px; padding: 13px; text-align: center; cursor: pointer; }
.pay-method .pm.on { border-color: var(--main); background: #fff7f6; }
.pay-method .pm .pm-name { font-weight: 600; }
.pay-method .pm .pm-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.pay-method .pm.disabled { opacity: .45; cursor: not-allowed; }
.pm-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 700; margin-right: 7px; vertical-align: -5px; }
.pm-badge.ali { background: #1677ff; }
.pm-badge.wx { background: #07c160; }
.panel h3 .ic { color: var(--main); margin-right: 4px; }
.user-side nav a .ic { color: inherit; }
.sum-row { display: flex; justify-content: space-between; padding: 7px 0; color: #555; }
.sum-row.bold { font-weight: 700; color: var(--text); font-size: 15px; }
.sum-row .val { color: var(--text); }
.sum-row.total .val { color: var(--main); font-size: 22px; font-weight: 700; }

/* ===== 订单 ===== */
.order-tabs { display: flex; gap: 4px; background: #fff; border-radius: 12px 12px 0 0; padding: 0 12px; margin-top: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.order-tabs a { padding: 13px 18px; font-size: 14px; white-space: nowrap; border-bottom: 2px solid transparent; color: #555; }
.order-tabs a.on { color: var(--main); border-color: var(--main); font-weight: 600; }
.order-list { background: #fff; border-radius: 0 0 12px 12px; padding: 0 20px 20px; }
.order-card { border: 1px solid var(--border); border-radius: 10px; margin-top: 16px; overflow: hidden; }
.order-card .o-head { display: flex; align-items: center; gap: 14px; padding: 11px 16px; background: #fafafa; font-size: 13px; color: var(--text-light); flex-wrap: wrap; }
.order-card .o-head .o-status { margin-left: auto; color: var(--main); font-weight: 600; font-size: 14px; }
.order-card .o-body { padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.order-card .o-items { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.order-card .o-items img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
.order-card .o-sum { text-align: right; }
.order-card .o-actions { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px dashed var(--border); justify-content: flex-end; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; }
.st-pending_payment { background: #fff7e6; color: #d46b08; }
.st-paid { background: #e6f7ff; color: #096dd9; }
.st-shipped { background: #f6ffed; color: #389e0d; }
.st-completed { background: #f0f0f0; color: #666; }
.st-cancelled { background: #f5f5f5; color: #999; }
.st-pending_ship { background: #fff1f0; color: #cf1322; }

/* ===== 订单详情时间线 ===== */
.timeline { padding: 6px 0; }
.timeline .tl-item { display: flex; gap: 14px; padding: 7px 0; }
.timeline .tl-dot { width: 10px; height: 10px; border-radius: 50%; background: #ddd; margin-top: 7px; flex-shrink: 0; }
.timeline .tl-item:first-child .tl-dot { background: var(--main); }
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }

/* ===== 用户中心 ===== */
.user-layout { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; margin-top: 20px; }
.user-side { background: #fff; border-radius: 12px; overflow: hidden; }
.user-side .us-head { background: linear-gradient(135deg, var(--main), var(--accent)); color: #fff; padding: 22px 16px; text-align: center; }
.user-side .us-points { font-size: 13px; opacity: .92; margin-top: 4px; }
.user-side .us-points b { font-size: 17px; }
.user-side nav a { display: flex; align-items: center; gap: 10px; padding: 13px 20px; border-left: 3px solid transparent; color: #555; }
.user-side nav a:hover { background: #fafafa; }
.user-side nav a.on { border-color: var(--main); color: var(--main); background: #fff7f6; font-weight: 600; }
.user-main { min-height: 400px; }

/* ===== 积分商城 ===== */
.point-banner { background: linear-gradient(120deg, #722ed1, #eb2f96); border-radius: 12px; color: #fff; padding: 26px 30px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.point-banner h2 { font-size: 22px; }
.point-banner .my-points { background: rgba(255,255,255,.18); border-radius: 20px; padding: 8px 20px; }
.point-card { position: relative; }
.point-card .p-cost { color: #722ed1; font-weight: 700; font-size: 17px; }
.point-card .p-cost::after { content: ' 积分'; font-size: 12px; font-weight: normal; }
.point-card .p-tag { color: #722ed1; }

/* ===== 支付页 ===== */
.pay-page { max-width: 640px; margin: 30px auto; }
.pay-info { background: #fff; border-radius: 12px; padding: 26px; text-align: center; }
.pay-amount { font-size: 34px; color: var(--main); font-weight: 700; margin: 10px 0 4px; }
.pay-qr { margin: 18px auto; width: 260px; }
.pay-qr img { width: 100%; }
.mock-cashier { border: 2px dashed var(--gold); border-radius: 10px; padding: 18px; margin: 16px 0; background: #fffbe6; }
.pay-tip { color: var(--text-light); font-size: 13px; }
.pay-status-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; }
.spinner { width: 16px; height: 16px; border: 2px solid #ddd; border-top-color: var(--main); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 页脚 ===== */
.site-footer { background: #fff; border-top: 1px solid var(--border); margin-top: 40px; padding: 26px 0 30px; }
.site-footer .f-main { display: flex; flex-wrap: wrap; gap: 10px 40px; align-items: center; justify-content: center; color: var(--text-light); font-size: 13px; }
.site-footer .f-icp { text-align: center; margin-top: 10px; color: #999; font-size: 12px; }
.site-footer .f-icp a { color: #999; }
.site-footer .f-icp a:hover { color: var(--main); }

/* ===== 弹窗 / 提示 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; max-height: 88vh; overflow: auto; padding: 24px; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal h3 { margin-bottom: 16px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#toast-box { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: rgba(0,0,0,.78); color: #fff; padding: 10px 22px; border-radius: 20px; font-size: 14px; animation: fade .2s; max-width: 86vw; }
@keyframes fade { from { opacity: 0; transform: translateY(-6px); } }

/* ===== 分页 ===== */
.pager { display: flex; justify-content: center; gap: 8px; margin: 24px 0; }
.pager button { min-width: 34px; height: 34px; border-radius: 17px; border: 1px solid #ddd; background: #fff; color: #555; padding: 0 10px; }
.pager button.on { background: var(--main); border-color: var(--main); color: #fff; }
.pager button:disabled { color: #ccc; cursor: not-allowed; }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 60px 0; color: var(--text-light); }
.empty .icon { font-size: 52px; margin-bottom: 10px; }

/* ===== 手机底部导航栏 ===== */
.m-tabbar { display: none; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .detail { grid-template-columns: 1fr; }
  .checkout-page, .detail-grid { grid-template-columns: 1fr; }
  .user-layout { grid-template-columns: 1fr; }
  .banner img { height: 170px; }
}
@media (max-width: 768px) {
  /* 顶栏：只留 logo + 搜索，导航交给底部栏 */
  .top-nav { display: none; }
  .topbar-inner { flex-wrap: nowrap; height: auto; padding: 10px 0 8px; gap: 12px; }
  .search-box { order: 0; min-width: 0; flex: 1; }
  .logo img { height: 36px; }
  .banner img { height: 150px; }
  /* 底部导航栏 */
  .m-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    background: #fff; border-top: 1px solid #ececec;
    padding: 5px 0 calc(5px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .m-tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
    font-size: 11px; color: #777; padding: 3px 0; position: relative;
  }
  .m-tabbar a.on { color: var(--main); font-weight: 600; }
  .m-tabbar .cart-badge { top: -5px; right: calc(50% - 24px); }
  body { padding-bottom: 64px; }
  /* 用户中心：侧栏变顶部横滑菜单 */
  .user-side nav { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .user-side nav::-webkit-scrollbar { display: none; }
  .user-side nav a { white-space: nowrap; padding: 11px 13px; border-left: none; border-bottom: 3px solid transparent; font-size: 13px; }
  .user-side nav a.on { border-bottom-color: var(--main); background: #fff; }
  .user-side .us-head { padding: 14px 16px; display: flex; align-items: center; gap: 12px; text-align: left; }
  .user-side .us-head .avatar { margin: 0; }
}
@media (max-width: 560px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .form-card { padding: 20px; }
  .section { margin: 18px 0; }
  .section-head h2 { font-size: 17px; }
  /* 防 iOS 聚焦输入框时页面自动放大 */
  input, select, textarea { font-size: 16px; }
  .qty-ctrl input { font-size: 14px; }
  /* 详情页按钮平铺 */
  .d-actions { flex-wrap: wrap; gap: 10px; }
  .d-actions .btn { flex: 1; padding: 12px 0; }
  .detail .d-img img { border-radius: 0; }
  .detail { padding: 0 0 20px; border-radius: 0; }
  .detail > div:last-child { padding: 0 16px; }
  /* 购物车表格 → 卡片 */
  .cart-page { padding: 6px 12px 16px; }
  .cart-table, .cart-table tbody { display: block; width: 100%; }
  .cart-table thead { display: none; }
  .cart-table tr { display: flex; flex-wrap: wrap; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px 8px; margin: 10px 0; position: relative; background: #fff; }
  .cart-table td { border: none; padding: 2px 6px; display: block; }
  .cart-table td:nth-child(2) { flex: 1; min-width: 0; }
  .cart-table td:nth-child(6) { position: absolute; top: 6px; right: 4px; }
  .cart-item .c-info img { width: 60px; height: 60px; }
  .cart-item .c-name { max-width: 100%; font-size: 13px; }
  .cart-table td:nth-child(4) { margin-left: auto; }
  .cart-footer { gap: 10px; }
  .cart-footer .sum { font-size: 20px; }
  .btn-lg { padding: 11px 26px; font-size: 15px; }
  .pay-qr { width: 220px; }
  .point-banner { padding: 18px 20px; }
  .point-banner h2 { font-size: 18px; }
  .order-tabs { padding: 0 4px; }
  .order-tabs a { padding: 12px 12px; font-size: 13px; }
  .stat-grid { gap: 8px; }
}
