/* =============================================================
   微信服务号 H5 商城 —— 全局样式
   设计约束：仅微信内置浏览器 / 移动端优先 / 禁止下拉回弹
   ============================================================= */

:root {
    --primary: #FF4E3A;
    --primary-dark: #E8382A;
    --primary-light: #FFF1EF;
    --accent: #FFB020;
    --success: #07C160;
    --warning: #FF9F0A;
    --danger: #FA5151;
    --text: #1F2329;
    --text-2: #646A73;
    --text-3: #8F959E;
    --line: #EBEDF0;
    --bg: #F5F6F8;
    --card: #FFFFFF;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(31, 35, 41, .06);
    --header-h: 46px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    /* 禁止微信下拉回弹 + 页面整体滚动错乱 */
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    /* 禁止长按选中与系统菜单，贴近原生 App 体验 */
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}

img { display: block; max-width: 100%; border: 0; }
a { color: inherit; text-decoration: none; }
input, textarea, select, button { font-family: inherit; font-size: inherit; outline: none; border: 0; background: none; -webkit-appearance: none; appearance: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
ul, li { list-style: none; }

/* ---------- 通用布局 ---------- */
.page { min-height: 100vh; padding-bottom: calc(20px + var(--safe-bottom)); }
.page.has-tabbar { padding-bottom: calc(56px + var(--safe-bottom)); }
.page.has-fixedbar { padding-bottom: calc(64px + var(--safe-bottom)); }

.container { padding: 0 12px; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.center { display: flex; align-items: center; justify-content: center; }
.col { display: flex; flex-direction: column; }

.mt12 { margin-top: 12px; }
.text-primary { color: var(--primary); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 导航栏 ---------- */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 0 12px;
}
.navbar .nav-title { font-size: 16px; font-weight: 600; }
.navbar .nav-back {
    position: absolute; left: 4px; top: 0; height: 100%; width: 44px;
    display: flex; align-items: center; justify-content: center;
}
.navbar .nav-back svg { width: 20px; height: 20px; fill: var(--text); }
.navbar .nav-right { position: absolute; right: 12px; top: 0; height: 100%; display: flex; align-items: center; font-size: 13px; color: var(--primary); }
.navbar-placeholder { height: var(--header-h); }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }

/* ---------- 按钮 ---------- */
.btn {
    display: flex; align-items: center; justify-content: center;
    height: 44px; border-radius: 22px; font-size: 15px; font-weight: 500;
    background: var(--primary); color: #fff; width: 100%;
    transition: opacity .15s, transform .1s;
}
.btn:active { opacity: .85; transform: scale(.99); }
.btn.btn-sm { height: 32px; border-radius: 16px; font-size: 13px; padding: 0 14px; width: auto; display: inline-flex; }
.btn-primary { background: linear-gradient(135deg, #FF6B4A, #FF3B2F); }
.btn-gray { background: #F2F3F5; color: var(--text-3); }
.btn.disabled, .btn[disabled] { background: #DEE0E3 !important; color: #fff !important; pointer-events: none; }

/* ---------- 表单 ---------- */
.form-item {
    display: flex; align-items: center; min-height: 50px;
    background: #fff; padding: 0 14px; border-bottom: 1px solid var(--line);
}
.form-item:last-child { border-bottom: 0; }
.form-item .label { width: 84px; flex-shrink: 0; color: var(--text); font-size: 14px; }
.form-item input, .form-item textarea { flex: 1; font-size: 14px; color: var(--text); height: 50px; }
.form-item textarea { height: auto; padding: 14px 0; min-height: 70px; resize: none; }
.form-item input::placeholder, .form-item textarea::placeholder { color: #BBBFc4; }

/* ---------- 空状态 ---------- */
.empty { padding: 60px 20px; text-align: center; }
.empty svg { width: 96px; height: 96px; opacity: .35; margin-bottom: 12px; }
.empty .empty-text { color: var(--text-3); font-size: 14px; }
.empty .empty-action { margin-top: 16px; }

/* ---------- 加载 / Toast / 弹窗 ---------- */
#globalLoading {
    position: fixed; inset: 0; z-index: 9000;
    display: none; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .18);
}
#globalLoading.show { display: flex; }
.spinner {
    width: 36px; height: 36px; border: 3px solid rgba(255, 255, 255, .35);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toastWrap {
    position: fixed; left: 50%; top: 42%; transform: translateX(-50%);
    /* 高于微信引导层(.wx-guide z-index:10000)：引导层内点「复制链接」后的 toast 不能被其遮挡 */
    z-index: 10500; display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
}
.toast {
    background: rgba(0, 0, 0, .78); color: #fff; padding: 9px 16px;
    border-radius: 6px; font-size: 14px; max-width: 80vw; text-align: center;
    animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } }

.mask {
    position: fixed; inset: 0; z-index: 8000; background: rgba(0, 0, 0, .5);
    display: none; align-items: center; justify-content: center; padding: 24px;
}
.mask.show { display: flex; }
.dialog {
    background: #fff; border-radius: 14px; width: 100%; max-width: 320px; overflow: hidden;
}
.dialog-body { padding: 22px 20px; text-align: center; }
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.dialog-content { font-size: 14px; color: var(--text-2); line-height: 1.6; white-space: pre-wrap; text-align: left; }
.dialog-footer { display: flex; border-top: 1px solid var(--line); }
.dialog-footer .btn { border-radius: 0; height: 48px; background: #fff; color: var(--text-2); font-weight: 400; }
.dialog-footer .btn + .btn { border-left: 1px solid var(--line); }
.dialog-footer .btn.confirm { color: var(--primary); font-weight: 600; }

/* ---------- 列表加载更多 / 无更多 ---------- */
.load-more { text-align: center; padding: 16px 0; color: var(--text-3); font-size: 12px; }
.load-more .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); margin: 0 3px; animation: blink 1s infinite; }
.load-more .dot:nth-child(2) { animation-delay: .2s; }
.load-more .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* ---------- 下拉刷新 ---------- */
.pull-indicator {
    height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
    color: var(--text-3); font-size: 12px; transition: height .25s;
}

/* ---------- 底部 TabBar ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    display: flex; background: #fff; border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
}
.tabbar .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 54px; color: var(--text-3); font-size: 11px; gap: 2px;
}
.tabbar .tab.active { color: var(--primary); }
.tabbar .tab svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------- 固定底部操作栏 ---------- */
.fixed-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    display: flex; align-items: center; gap: 10px;
    background: #fff; border-top: 1px solid var(--line);
    padding: 8px 12px calc(8px + var(--safe-bottom));
}

/* ---------- 价格 ---------- */
.price { color: var(--primary); font-weight: 600; }
.price .symbol { font-size: 12px; margin-right: 1px; }
.price .int { font-size: 18px; }
.price .decimal { font-size: 12px; }
.price-del { color: var(--text-3); text-decoration: line-through; font-size: 12px; margin-left: 4px; }
.price-tag {
    display: inline-block; background: var(--primary-light); color: var(--primary);
    font-size: 11px; padding: 1px 6px; border-radius: 3px; margin-left: 6px; font-weight: 500;
}

/* ---------- 状态标签 ---------- */
.status-tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.status-tag.pending_upload { background: #E7F4FF; color: #2B7BFB; }  /* 待上传图片 */
.status-tag.reviewing { background: #F0EBFF; color: #7A5AF8; }       /* 审核中 */
.status-tag.producing { background: #FFF8E8; color: #D48806; }       /* 制作中 */
.status-tag.shipped { background: #E3F2FD; color: #1677C2; }         /* 已发货 */
.status-tag.completed { background: #E8F9EF; color: #07C160; }      /* 已完成 */
.status-tag.default { background: #E7F4FF; color: #2B7BFB; }       /* 默认地址标记 */

/* ---------- 图片预览 ---------- */
.img-preview {
    position: fixed; inset: 0; z-index: 9800; background: #000;
    display: none; align-items: center; justify-content: center;
}
.img-preview.show { display: flex; }
.img-preview img { max-width: 100%; max-height: 100%; }
.img-preview .img-close {
    position: absolute; right: 14px; top: 14px; z-index: 2;
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .35);
    display: flex; align-items: center; justify-content: center;
}
.img-preview .img-close svg { width: 18px; height: 18px; fill: #fff; }
.img-preview .img-count {
    position: absolute; left: 0; right: 0; bottom: 18px; z-index: 2;
    margin: 0 auto; max-width: 90px; text-align: center;
    color: rgba(255, 255, 255, .85); font-size: 12px;
    background: rgba(0, 0, 0, .35); padding: 3px 0; border-radius: 12px;
}

/* ---------- 骨架屏 ---------- */
.skeleton { background: linear-gradient(90deg, #F0F1F3 25%, #E6E8EB 37%, #F0F1F3 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-card { height: 90px; margin-bottom: 10px; }

/* ---------- 上传格子 ---------- */
.upload-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.upload-cell {
    position: relative; padding-top: 100%; border-radius: var(--radius-sm);
    background: #F5F6F8; border: 1px dashed #D0D3D9; overflow: hidden;
}
.upload-cell.filled { border: 1px solid var(--line); }
.upload-cell .inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); font-size: 11px; gap: 4px; }
.upload-cell .inner svg { width: 22px; height: 22px; fill: #BBBFc4; }
.upload-cell img.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-cell .del {
    position: absolute; right: 0; top: 0; width: 22px; height: 22px; z-index: 3;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 14px; line-height: 22px; text-align: center;
    border-bottom-left-radius: 8px;
}
.upload-cell .required-tip { position: absolute; left: 0; bottom: 0; right: 0; text-align: center; font-size: 10px; color: var(--danger); background: rgba(255, 255, 255, .9); padding: 1px 0; }
.upload-cell .loading { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; z-index: 2; }

/* ---------- 订单卡片 ---------- */
.order-card { background: #fff; border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.order-card .o-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.order-card .o-body { display: flex; gap: 10px; padding: 10px 0; }
.order-card .o-body img { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #F5F6F8; }
.order-card .o-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- 地址卡片 ---------- */
.addr-card { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 10px; display: flex; gap: 10px; align-items: flex-start; }
.addr-card .info { flex: 1; min-width: 0; }
.addr-card .name-row { font-size: 15px; font-weight: 600; }
.addr-card .name-row .phone { margin-left: 8px; font-weight: 400; color: var(--text-2); }
.addr-card .detail { color: var(--text-2); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.addr-card .actions { display: flex; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--text-3); }

/* ---------- 状态筛选 Tab ---------- */
.tab-scroll { display: flex; background: #fff; overflow-x: auto; border-bottom: 1px solid var(--line); position: sticky; top: var(--header-h); z-index: 50; }
.tab-scroll::-webkit-scrollbar { display: none; }
.tab-scroll .t {
    flex: 1; min-width: 64px; text-align: center; padding: 12px 8px; font-size: 14px;
    color: var(--text-2); position: relative; white-space: nowrap;
}
.tab-scroll .t.active { color: var(--primary); font-weight: 600; }
.tab-scroll .t.active::after {
    content: ''; position: absolute; left: 50%; transform: translateX(-50%); bottom: 4px;
    width: 20px; height: 3px; border-radius: 2px; background: var(--primary);
}

/* ---------- 轮播 ---------- */
.swiper { position: relative; overflow: hidden; width: 100%; }
.swiper-track { display: flex; transition: transform .3s ease; will-change: transform; }
.swiper-slide { flex: 0 0 100%; }
.swiper-slide img { width: 100%; display: block; }
.swiper-dots { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; justify-content: center; gap: 5px; }
.swiper-dots .dot { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .5); transition: width .2s; }
.swiper-dots .dot.active { background: #fff; width: 14px; }

/* ---------- 商品详情底部悬浮栏 ---------- */
.detail-bar { display: flex; align-items: center; gap: 10px; width: 100%; }
.detail-bar .kf-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 56px; height: 46px; color: var(--text-2); font-size: 11px; gap: 2px; flex-shrink: 0;
}
.detail-bar .kf-btn svg { width: 20px; height: 20px; fill: var(--text-2); }
.detail-bar .buy-btn { flex: 1; }
