/* ===== 全局基础 ===== */
* { 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; }
.card-actions { display: flex; gap: 6px; margin-top: 6px; }
.card-action {
    flex: 1; display: block; text-align: center; padding: 7px; border-radius: 8px;
    font-size: 13px; cursor: pointer; user-select: none;
}
.card-action.detail-btn { background: var(--primary); color: #fff; }
.card-action.buy-btn { background: linear-gradient(135deg, #ff7a45, #ff3d3d); color: #fff; font-weight: 600; }
.buy-now {
    display: block; text-align: center; padding: 13px; font-size: 16px; font-weight: 700;
    margin-top: 16px; text-decoration: none; border-radius: 12px; color: #fff;
    background: linear-gradient(135deg, #ff7a45, #ff3d3d);
    box-shadow: 0 4px 14px rgba(255, 61, 61, .25);
    letter-spacing: 1px;
    transition: transform .15s, box-shadow .15s, filter .15s;
}
.buy-now:hover { filter: brightness(1.06); box-shadow: 0 6px 18px rgba(255, 61, 61, .35); }
.buy-now:active { transform: scale(.98); }
.empty-tip { color: var(--muted); text-align: center; padding: 40px 0; }

/* ===== 桌面端（>768px）：商品卡片缩小为多列小卡片 ===== */
@media (min-width: 769px) {
    .product-col { padding: 16px; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
    .product-card { border-radius: 10px; }
    .product-card .thumb { aspect-ratio: 1/1; }
    .product-card .info { padding: 8px 10px; }
    .product-card .name { font-size: 13px; line-height: 1.4; height: 2.8em; }
    .product-card .price { font-size: 13px; margin: 4px 0 2px; }
    .card-action { padding: 6px; font-size: 12px; }
}

/* ===== 顶部导航（电脑端） ===== */
.top-nav {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border-bottom: 1px solid #e6e6e6;
    padding: 0 16px; height: 56px;
    position: sticky; top: 0; z-index: 50;
}
.top-nav .tn-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 800; font-size: 17px; color: #222; text-decoration: none;
}
.top-nav .tn-logo .mark {
    width: 28px; height: 28px; border-radius: 8px;
    background: linear-gradient(135deg, #2e75b6, #6d8dff); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.top-nav .tn-links { display: flex; gap: 6px; }
.top-nav .tn-links a {
    padding: 7px 14px; border-radius: 8px; font-size: 14px;
    color: #555; text-decoration: none; transition: .2s;
}
.top-nav .tn-links a:hover { background: #f0f4fa; color: #2e75b6; }
.top-nav .tn-links a.active {
    background: linear-gradient(135deg, #2e75b6, #6d8dff); color: #fff; font-weight: 600;
}
@media (max-width: 900px) { .top-nav { display: none; } }
@media (min-width: 901px) { .front-top { display: none; } }

/* ===== 底部版权与备案条 ===== */
.site-foot {
    text-align: center; font-size: 11.5px; color: #9aa3b2;
    padding: 14px 12px 6px; line-height: 1.8;
}
.site-foot a { color: inherit; }
.site-foot span + span { margin-left: 8px; }

/* ===== 底部菜单 ===== */
.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; }
.bottom-menu a.buy-tab { color: #fff; background: linear-gradient(135deg, #ff7a45, #ff3d3d); }
.bottom-menu a.buy-tab.active { color: #fff; }
.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-side a .nb { float: right; background: #ff3d3d; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.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; max-height: 500px; overflow-y: auto; 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; cursor: grab; }
.img-cell:active { cursor: grabbing; }
.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; }
.img-cell.dragging { opacity: 0.4; }
.img-cell.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(46,117,182,.35); }

/* 左右移动按钮（左下/右下角，透明） */
.img-cell .move-l,
.img-cell .move-r {
    position: absolute; bottom: 2px;
    background: rgba(0,0,0,.25); border: none;
    border-radius: 4px; width: 24px; height: 24px; cursor: pointer;
    font-size: 11px; line-height: 24px; text-align: center; color: rgba(255,255,255,.85);
    opacity: 0; transition: opacity .2s; z-index: 2; user-select: none;
}
.img-cell:hover .move-l,
.img-cell:hover .move-r { opacity: 1; }
.img-cell .move-l { left: 2px; }
.img-cell .move-r { right: 2px; }
.img-cell .move-l:active,
.img-cell .move-r:active { background: rgba(46,117,182,.5); }

/* 上传区域 */
.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; }

/* 浮动保存按钮 */
.floating-actions {
    position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 90;
    display: flex; flex-direction: column; gap: 8px; opacity: .65; transition: opacity .2s;
}
.floating-actions:hover { opacity: 1; }
.floating-actions .btn { padding: 10px 14px; box-shadow: 0 2px 12px rgba(0,0,0,.18); border-radius: 8px; font-size: 13px; }

/* ===== 响应式：手机端后台 ===== */
@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; }
    /* 前台手机端：一级菜单 4 列网格 */
    .primary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px; overflow-x: visible; }
    .primary-card { padding: 7px 4px; border-radius: 8px; font-size: 12px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    /* 前台手机端：左侧分类微调 */
    .secondary-col { width: 30%; max-width: 110px; min-width: 90px; height: calc(100vh - 96px); top: 96px; }
    .secondary-item { padding: 10px 8px; font-size: 12px; }
    .product-grid { gap: 8px; }
    .product-card .name { font-size: 12px; }
    .product-card .price { font-size: 13px; }
}

/* 可点击放大的图片容器 */
.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; }

