/* ===== TK Store 前台样式（移动端优先） ===== */
:root {
  --primary: #ff4d4f;
  --primary-dark: #e63b3d;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a919f;
  --border: #eceff3;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

[dir="rtl"] body { direction: rtl; }

/* ===== 顶部 ===== */
.header { background: #fff; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.header-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 6px; margin-right: auto; font-weight: 700; font-size: 18px; }
.brand img { height: 32px; width: auto; }
.header-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  border: none; background: none; color: var(--text);
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.icon-btn:hover { background: #f2f3f5; }

.cart-btn { text-decoration: none; }
.badge {
  position: absolute; top: 2px; right: 0;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 17px; height: 17px; line-height: 17px; border-radius: 9px;
  padding: 0 4px; text-align: center;
}

.lang-box { display: flex; align-items: center; gap: 3px; color: var(--muted); }
.lang-box select {
  border: none; background: transparent; color: var(--text);
  font-size: 13px; outline: none; max-width: 90px; cursor: pointer;
}

.search-bar { border-top: 1px solid var(--border); padding: 8px 14px; background: #fff; }
.search-bar form { display: flex; gap: 8px; max-width: 600px; margin: 0 auto; }
.search-bar input {
  flex: 1; border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 16px; outline: none; background: #f7f8fa;
}
.search-bar input:focus { border-color: var(--primary); background: #fff; }

.nav {
  display: flex; gap: 2px; overflow-x: auto; padding: 0 10px 10px;
  max-width: 1200px; margin: 0 auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  white-space: nowrap; padding: 7px 12px; border-radius: 16px;
  font-size: 14px; color: #4a4f57;
}
.nav a:hover { background: #f2f3f5; color: var(--primary); }

/* ===== 分类抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 300px; max-width: 85vw;
  background: #fff; z-index: 100; transform: translateX(-100%);
  transition: transform .25s ease; display: flex; flex-direction: column;
}
[dir="rtl"] .drawer { left: auto; right: 0; transform: translateX(100%); }
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700;
}
.drawer-body { overflow-y: auto; padding: 8px 0 20px; flex: 1; }
.drawer-all { display: block; padding: 12px 16px; font-weight: 600; color: var(--primary); }
.drawer-cat-name {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  font-weight: 600; font-size: 15px;
}
.cat-icon { font-size: 18px; }
.drawer-cat-children { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.drawer-cat-children a {
  background: #f5f6f8; padding: 5px 12px; border-radius: 14px; font-size: 13px; color: #4a4f57;
}
.drawer-cat-children a:hover { color: var(--primary); }
.drawer-sub-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.drawer-grandchildren { display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-grandchildren a {
  background: transparent; border: 1px dashed #d8dbe1; padding: 3px 10px;
  border-radius: 12px; font-size: 12px; color: #6a707c;
}
.drawer-grandchildren a:hover { color: var(--primary); border-color: var(--primary); }

/* ===== 主体 ===== */
.main { max-width: 1200px; margin: 0 auto; padding: 14px; min-height: 60vh; }

.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 18px; font-weight: 700; }
.section-more { color: var(--muted); font-size: 13px; }

/* ===== 轮播 ===== */
.banner { position: relative; border-radius: var(--radius); overflow: hidden; touch-action: pan-y; }
.banner-slide { display: block; -webkit-user-drag: none; user-select: none; }
/* display:block 会覆盖 hidden 属性的默认 display:none，必须显式恢复，否则所有图竖排显示 */
.banner-slide[hidden] { display: none !important; }
/* 跟随图片自身比例完整显示（适配客户上传的任意尺寸），仅对极高的图封顶防撑满屏幕 */
.banner-slide img {
  display: block; width: 100%; height: auto;
  max-height: 66vh; object-fit: cover; object-position: center;
  user-select: none; -webkit-user-drag: none;
}
.banner-dots { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.banner-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.55); cursor: pointer; }
.banner-dot.active { background: #fff; width: 18px; border-radius: 4px; }

/* ===== 分类宫格 ===== */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cat-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 6px;
}
.cat-icon-big { font-size: 30px; }
.cat-name { font-size: 13px; color: #4a4f57; text-align: center; }
@media (min-width: 768px) { .cat-grid { grid-template-columns: repeat(6, 1fr); } }

/* ===== 商品网格 ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 768px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

.pcard { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: block; }
.pcard-img { position: relative; aspect-ratio: 1; overflow: hidden; background: #f2f3f5; }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.pcard:hover .pcard-img img { transform: scale(1.05); }
.pcard-new {
  position: absolute; top: 8px; left: 8px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
}
[dir="rtl"] .pcard-new { left: auto; right: 8px; }
.pcard-info { padding: 10px; }
.pcard-name {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 39px;
}
.pcard-cta { color: var(--primary); font-size: 13px; font-weight: 600; margin-top: 6px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 22px; padding: 10px 22px; font-size: 15px; font-weight: 600;
  transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn:disabled { background: #d5d8dd; color: #fff; cursor: not-allowed; }

/* ===== 页面头 ===== */
.page-head { margin-bottom: 12px; }
.page-head h1, .page-title { font-size: 20px; font-weight: 700; margin: 6px 0 10px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.subcats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: #fff; border: 1px solid var(--border); padding: 6px 14px; border-radius: 16px; font-size: 13px; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

.sortbar { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }
.sortbar a {
  white-space: nowrap; padding: 6px 14px; border-radius: 16px; font-size: 13px;
  color: #4a4f57; background: #fff;
}
.sortbar a.active { background: var(--primary); color: #fff; }

.pagination-box { display: flex; justify-content: center; margin: 18px 0; }
.pagination { display: flex; gap: 4px; list-style: none; flex-wrap: wrap; }
.pagination li a, .pagination li span {
  display: inline-block; min-width: 34px; height: 34px; line-height: 34px; text-align: center;
  background: #fff; border-radius: 8px; padding: 0 8px; font-size: 14px; color: #4a4f57;
}
.pagination li.active span { background: var(--primary); color: #fff; }
.pagination li.disabled span { color: #c3c8d0; }

/* ===== 详情 ===== */
.detail { display: flex; flex-direction: column; gap: 16px; }
.gallery { background: #fff; border-radius: var(--radius); overflow: hidden; }
.gallery-main { touch-action: pan-y; cursor: zoom-in; }
.gallery-main img { width: 100%; aspect-ratio: 1; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.gallery-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; }
.gallery-thumbs img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px;
  border: 2px solid transparent; cursor: pointer;
}
.gallery-thumbs img.active { border-color: var(--primary); }

/* ===== 主图放大查看 ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 190; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.lightbox[hidden] { display: none !important; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lightbox-close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px;
  border: none; border-radius: 50%; background: rgba(255, 255, 255, .18);
  color: #fff; font-size: 18px; line-height: 36px; text-align: center; cursor: pointer;
}

.detail-info { background: #fff; border-radius: var(--radius); padding: 16px; }
.detail-name { font-size: 18px; font-weight: 700; line-height: 1.4; }
.detail-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-top: 8px; }
.detail-meta a:hover { color: var(--primary); }

.detail-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.btn-wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #25d366; color: #fff; border: none; border-radius: 24px;
  padding: 14px 24px; font-size: 16px; font-weight: 600;
}
.btn-wa:hover { background: #1fb855; }

.detail-desc { background: #fff; border-radius: var(--radius); padding: 16px; }
.detail-desc h2 { font-size: 16px; margin-bottom: 10px; }
.detail-desc-text { color: #4a4f57; font-size: 14px; white-space: pre-wrap; }

/* ===== 购物车 ===== */
.cart-wrap { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) { .cart-wrap { flex-direction: row; align-items: flex-start; } .cart-list { flex: 1; } .cart-summary { width: 320px; } }
.cart-list { background: #fff; border-radius: var(--radius); padding: 14px; }
.cart-head { display: none; }
@media (min-width: 900px) {
  .cart-head { display: grid; grid-template-columns: 1fr 120px 120px 40px; padding: 0 10px 10px; color: var(--muted); font-size: 13px; }
}
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.cart-item-img img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 14px; font-weight: 500; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cart-item-price { color: var(--primary); font-weight: 700; margin: 6px 0 8px; }
.cart-item-subtotal { color: var(--primary); font-weight: 700; font-size: 15px; margin-top: 10px; }
.cart-item-remove { border: none; background: none; color: var(--muted); margin-top: 8px; }
.cart-item-remove:hover { color: var(--primary); }

.cart-summary { background: #fff; border-radius: var(--radius); padding: 16px; position: sticky; top: 70px; }
.summary-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: #4a4f57; }
.summary-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; font-weight: 800; font-size: 16px; color: var(--text); }
.summary-total span:last-child { color: var(--primary); font-size: 20px; }

/* ===== 结算 ===== */
.checkout-wrap { display: flex; flex-direction: column; gap: 14px; }
.checkout-side { position: sticky; bottom: 10px; background: #fff; border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
@media (min-width: 900px) {
  .checkout-wrap { flex-direction: row; align-items: flex-start; }
  .checkout-main { flex: 1; }
  .checkout-side { width: 320px; position: sticky; top: 80px; box-shadow: none; border: 1px solid var(--border); }
}
.secure-tip { text-align: center; margin-top: 10px; }

.panel { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }

.co-item { display: flex; gap: 10px; padding: 8px 0; align-items: center; }
.co-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.co-item-info { flex: 1; min-width: 0; }
.co-item-name { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.co-item-price { color: var(--muted); font-size: 12px; margin-top: 2px; }
.co-item-sub { font-weight: 700; font-size: 14px; }
.co-totals { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }

.pay-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; }
.pay-opt input { margin-top: 3px; accent-color: var(--primary); }
.pay-opt-body { display: flex; flex-direction: column; gap: 2px; }
.pay-opt-body small { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field span { font-size: 13px; color: #4a4f57; }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; background: #fafbfc;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); background: #fff; }
.form-field-full { grid-column: 1 / -1; }

.alert { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: #fff1f0; color: #d9363e; border: 1px solid #ffccc7; }

/* ===== 下单成功 / 订单查询 ===== */
.order-success { text-align: center; max-width: 640px; margin: 20px auto; }
.success-icon {
  width: 64px; height: 64px; border-radius: 50%; background: #e8f8f0; color: #2eb872;
  font-size: 32px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.order-no-box { background: #fff; border-radius: 10px; padding: 14px; margin: 14px 0; box-shadow: var(--shadow); }
.order-no-box strong { color: var(--primary); letter-spacing: 1px; }
.thanks { color: #4a4f57; margin-bottom: 14px; }
.pay-hint { background: #fff7e6; border: 1px solid #ffe0a8; border-radius: 10px; padding: 14px; margin-bottom: 14px; font-size: 14px; color: #8a5a00; text-align: left; }
.paypal-box { background: #fff; border-radius: 8px; padding: 10px; margin: 10px 0; color: var(--text); }
.order-success .panel { text-align: left; }
.success-actions { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }

.track-desc { color: var(--muted); margin-bottom: 14px; }
.track-form { background: #fff; border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; box-shadow: var(--shadow); }
.track-result .track-status { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: #f7f8fa; border-radius: 8px; margin-bottom: 10px; }
.track-status strong { color: var(--primary); font-size: 16px; }

/* ===== 空状态 ===== */
.empty-box { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 10px; }
.empty-box p { margin-bottom: 16px; }

/* ===== 页脚 ===== */
.footer { background: #fff; margin-top: 26px; padding: 20px 14px 26px; border-top: 1px solid var(--border); }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 700px) { .footer-inner { flex-direction: row; justify-content: space-between; } }
.footer-brand { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.footer-desc { color: var(--muted); font-size: 13px; }
.footer-col { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.footer-col a { color: #4a4f57; }
.footer-col a:hover { color: var(--primary); }
.footer-copy { max-width: 1200px; margin: 16px auto 0; color: var(--muted); font-size: 12px; text-align: center; }

/* ===== 客服挂件 ===== */
.chat-fab {
  position: fixed; bottom: 20px; right: 16px; z-index: 80;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(255, 77, 79, .45);
  display: flex; align-items: center; justify-content: center;
}
[dir="rtl"] .chat-fab { right: auto; left: 16px; }
.chat-fab-dot {
  position: absolute; top: 4px; right: 4px; width: 10px; height: 10px;
  background: #2eb872; border-radius: 50%; border: 2px solid #fff;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.chat-panel {
  position: fixed; bottom: 86px; right: 16px; z-index: 81;
  width: 340px; max-width: calc(100vw - 28px); height: 480px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.18);
  display: flex; flex-direction: column; overflow: hidden;
}
/* 关键：hidden 属性必须能隐藏面板（否则 display:flex 会覆盖 hidden） */
.chat-panel[hidden] { display: none !important; }
[dir="rtl"] .chat-panel { right: auto; left: 16px; }
.chat-head {
  background: var(--primary); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-title { font-weight: 700; font-size: 15px; }
.chat-close { color: #fff; }
.chat-sound {
  border: none; background: rgba(255,255,255,.18); color: #fff;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; margin-right: 2px;
}
.chat-sound:hover { background: rgba(255,255,255,.3); }
.chat-body { flex: 1; overflow-y: auto; padding: 12px; background: #f7f8fa; display: flex; flex-direction: column; gap: 8px; }

.chat-start-box { text-align: center; padding: 20px 8px; }
.chat-start-box input {
  display: block; width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; outline: none; font-size: 14px;
}
.chat-start-box .btn { width: 100%; }

.msg { max-width: 78%; padding: 9px 12px; border-radius: 14px; font-size: 14px; word-break: break-word; }
.msg .msg-time { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.msg-admin { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.msg-visitor { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-visitor .msg-time { color: rgba(255,255,255,.75); }

/* 聊天里的商品卡片消息 */
.msg-product {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none;
  background: #fff; border: 1px solid #eee; border-radius: 12px;
  padding: 8px; max-width: 220px; box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .15s;
}
.msg-product:hover { transform: translateY(-2px); }
.msg-product img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.msg-product-name { font-size: 13px; color: var(--text); font-weight: 500; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.msg-product-btn { font-size: 12px; color: var(--primary); font-weight: 600; }

.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1; border: 1px solid var(--border); border-radius: 18px; padding: 9px 14px; outline: none; background: #f7f8fa;
}
.chat-form button {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
}
.chat-wa {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px; border-top: 1px solid var(--border); color: #2eb872; font-size: 13px; font-weight: 600;
}
.chat-wa:hover { background: #f0faf5; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 9px 18px; border-radius: 20px;
  font-size: 14px; z-index: 200; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
