/* ===== 全局基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #2e75b6;
    --primary-dark: #1f4f7d;
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #222;
    --muted: #888;
    --border: #e6e6e6;
    --danger: #e25555;
    --ok: #2fa36b;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}
body.lb-noscroll {
    position: fixed; left: 0; right: 0; top: 0;
    overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 12px; }

/* ===== 前台顶部 ===== */
.front-top {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 14px 16px;
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 10px;
}
.front-top .logo {
    width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px;
}
.front-top .title { font-size: 16px; font-weight: 600; }

/* ===== 一级类目横向滑动 ===== */
.primary-row {
    display: flex; gap: 10px; overflow-x: auto; padding: 12px;
    background: var(--card); border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.primary-row::-webkit-scrollbar { display: none; }
.primary-card {
    flex: 0 0 auto; padding: 10px 18px; border-radius: 22px; background: #eef3f8;
    color: var(--primary-dark); font-weight: 600; cursor: pointer; white-space: nowrap;
    border: 1px solid transparent; transition: .15s;
}
.primary-card.active { background: var(--primary); color: #fff; }

/* ===== 二级 + 商品 布局 ===== */
.front-body { display: flex; align-items: flex-start; }
.secondary-col {
    width: 38%; max-width: 160px; flex: 0 0 auto;
    background: var(--card); border-right: 1px solid var(--border);
    position: sticky; top: 118px; height: calc(100vh - 118px); overflow-y: auto;
}
.secondary-item {
    padding: 14px 12px; font-size: 14px; cursor: pointer; border-left: 3px solid transparent;
    border-bottom: 1px solid #f0f0f0;
}
.secondary-item.active { background: #eef3f8; border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.product-col { flex: 1; padding: 12px; min-width: 0; }

/* ===== 商品卡片（一行两个） ===== */
.product-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card {
    background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.05);
    display: flex; flex-direction: column;
}
.product-card .thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: #eee; }
.product-card .info { padding: 8px 10px; }
.product-card .name { font-size: 13px; line-height: 1.4; height: 2.8em; overflow: hidden; }
.product-card .price { color: var(--danger); font-weight: 700; font-size: 14px; margin: 4px 0; }
.product-card .copy-btn {
    display: block; text-align: center; background: var(--primary); color: #fff;
    padding: 7px; border-radius: 8px; font-size: 13px; margin-top: 4px;
}
.empty-tip { color: var(--muted); text-align: center; padding: 40px 0; }

/* ===== 底部菜单 ===== */
.bottom-menu {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-menu a {
    flex: 1; text-align: center; padding: 10px 0; color: var(--muted); font-size: 13px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottom-menu a.active { color: var(--primary); }
.bottom-menu .ic { font-size: 18px; }
.page-with-menu { padding-bottom: 64px; }

/* ===== 商品详情页 ===== */
.detail-section { background: var(--card); margin: 10px; border-radius: 12px; padding: 14px; }
.detail-section h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary-dark);
    border-left: 4px solid var(--primary); padding-left: 8px; }
.detail-images { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.img-hint {
    text-align: center; color: #b0b7c3; font-size: 11px; padding: 6px 0 0;
    letter-spacing: .5px; user-select: none;
}
.title-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.title-item .txt { flex: 1; font-size: 14px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip { background: #eef3f8; color: var(--primary-dark); padding: 4px 10px; border-radius: 14px; font-size: 13px; }
.price-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.price-item .p { color: var(--danger); font-weight: 700; }
.copy-btn, .download-btn {
    background: var(--primary); color: #fff; border: none; padding: 8px 14px;
    border-radius: 8px; cursor: pointer; font-size: 13px;
}
.download-btn { background: var(--ok); }
.qa-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
.qa-item .q { font-weight: 600; color: var(--primary-dark); }
.qa-item .a { margin: 6px 0; }
.channel-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.channel-block .ch-name { font-weight: 600; margin-bottom: 8px; }

/* ===== 客户答疑 iframe 页 ===== */
.qa-iframe-wrap { position: fixed; top: 56px; left: 0; right: 0; bottom: 56px; }
.qa-iframe-wrap iframe { width: 100%; height: 100%; border: none; }

/* ===== 后台布局 ===== */
.admin-body { display: flex; min-height: 100vh; }
.admin-side {
    width: 200px; flex: 0 0 auto; background: #1f2a37; color: #cbd5e1;
    display: flex; flex-direction: column;
}
.admin-side .brand { padding: 18px 16px; color: #fff; font-weight: 700; font-size: 15px; border-bottom: 1px solid #2c3a4d; }
.admin-side a { color: #cbd5e1; padding: 12px 18px; display: block; }
.admin-side a:hover, .admin-side a.active { background: #2c3a4d; color: #fff; }
.admin-main { flex: 1; min-width: 0; background: var(--bg); }
.admin-topbar { background: #fff; padding: 12px 18px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; }
.admin-content { padding: 18px; }
.panel { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.panel h2 { font-size: 16px; margin-bottom: 14px; }

/* ===== 表单 ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=number], .field input[type=password],
.field select, .field textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
.btn { display: inline-block; padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 14px; }
.btn.secondary { background: #6b7280; }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.table th { background: #fafafa; color: #555; font-weight: 600; }
.table tr:hover { background: #fafcff; }
.tag-check { display: inline-flex; align-items: center; gap: 4px; margin: 0 12px 8px 0; }

/* 富文本编辑器 */
.editor-toolbar { border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0;
    background: #fafafa; padding: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.editor-toolbar button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 13px; }
.editor-content { border: 1px solid var(--border); border-radius: 0 0 8px 8px; min-height: 140px; padding: 10px; outline: none; }
.editor-content:empty:before { content: attr(data-placeholder); color: #bbb; }

/* 图片网格 */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 8px; }
.img-cell { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.img-cell img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.img-cell .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff;
    border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }

/* 上传区域 */
.upload-box {
    border: 2px dashed var(--border); border-radius: 10px; padding: 12px; transition: .2s; position: relative;
    background: #fafbfc;
}
.upload-box:hover, .upload-box.drag-over {
    border-color: var(--primary); background: rgba(46,117,182,.04);
}
.upload-box.drag-over::after {
    content: '释放以上传图片'; position: absolute; inset: 0; display: flex;
    align-items: center; justify-content: center; background: rgba(46,117,182,.08);
    color: var(--primary); font-size: 15px; font-weight: 600; border-radius: 8px; z-index: 5;
}
.upload-box input[type=file] { display: block; width: 100%; cursor: pointer; }
.drop-hint { text-align: center; color: #b0b7c3; font-size: 13px; padding: 4px 0 8px; pointer-events: none; }
.drag-over { border: 2px dashed var(--primary) !important; }

/* 提示条 */
.toast { position: fixed; left: 50%; top: 20px; transform: translateX(-50%); background: rgba(0,0,0,.82);
    color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 999; font-size: 13px; opacity: 0; transition: .25s; }
.toast.show { opacity: 1; }

/* ===== 响应式：手机端后台 ===== */
@media (max-width: 768px) {
    .admin-side { position: fixed; bottom: 0; left: 0; right: 0; width: 100%; height: auto;
        flex-direction: row; z-index: 40; overflow-x: auto; }
    .admin-side .brand { display: none; }
    .admin-side a { padding: 12px 14px; white-space: nowrap; }
    .admin-body { flex-direction: column; }
    .admin-main { padding-bottom: 56px; }
    .front-body { flex-direction: column; }
    .secondary-col { width: 100%; max-width: none; height: auto; position: static;
        display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .secondary-item { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
    .secondary-item.active { border-bottom-color: var(--primary); }
    .product-col { width: 100%; }
}

/* 可点击放大的图片容器 */
.zoomable {
    cursor: pointer;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    border-radius: 6px; overflow: hidden;
    position: relative;
}
.zoomable img {
    width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block;
    pointer-events: none;  /* 微信内禁止图片响应触摸，走父容器点击 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== 图片灯箱（点击放大 / 滑动 / 长按保存） ===== */
#lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0, 0, 0, .92);
    display: none; flex-direction: column;
    -webkit-tap-highlight-color: transparent;
}
#lightbox.open { display: flex; }
.lb-close {
    position: absolute; top: 12px; right: 16px; z-index: 2;
    width: 36px; height: 36px; line-height: 34px; text-align: center;
    color: #fff; font-size: 30px; border-radius: 50%;
    background: rgba(255, 255, 255, .15); cursor: pointer;
}
.lb-stage {
    flex: 1; display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: 10px;
}
#lbImg {
    max-width: 100%; max-height: 100%; object-fit: contain;
    -webkit-user-select: none; user-select: none;
}
.lb-bar {
    color: #fff; text-align: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    font-size: 13px;
}
.lb-bar #lbCount { font-size: 13px; opacity: .85; }
.lb-hint { display: block; margin-top: 4px; color: #ffe08a; opacity: .85; font-size: 11px; letter-spacing: .5px; }

