/* ============ 基础重置 & 变量 ============ */
:root {
  --primary: #e65c00;
  --primary-light: #ff7a1a;
  --primary-dark: #cc5200;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-light: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --wechat-green: #07c160;
  --transition: .25s ease;
  --slot-gap: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 80px;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, textarea { font: inherit; outline: none; }

/* ============ 头部 ============ */
.header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(230,92,0,.3);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
}
.header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.header-badge {
  font-size: .7rem;
  background: rgba(255,255,255,.2);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ============ 容器 ============ */
.container { max-width: 480px; margin: 0 auto; padding: 12px 16px; }

/* ============ 铲车卡片 ============ */
.product-list { display: flex; flex-direction: column; gap: 16px; }

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.product-card:active { transform: scale(.98); }

.product-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #f0f0f0;
}
.product-image-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: .9rem;
}

.product-info { padding: 14px 16px 16px; }

.product-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.product-price {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.product-price::before { content: "¥"; font-size: .9rem; }
.product-desc {
  font-size: .85rem;
  color: var(--text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-tags {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.product-tag {
  font-size: .75rem;
  background: #fff3e6;
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.product-tag.new { background: #e8f5e9; color: #2e7d32; }
.product-tag.hot { background: #fce4ec; color: #c62828; }

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ============ 浮动微信按钮 ============ */
.wechat-float {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--wechat-green);
  color: #fff;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 16px rgba(7,193,96,.4);
  font-size: .95rem;
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition);
}
.wechat-float:active { transform: scale(.95); }
.wechat-float .icon { font-size: 1.4rem; }
.wechat-float .badge {
  font-size: .65rem;
  background: rgba(255,255,255,.25);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 400;
}

/* ============ 底部 ============ */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: .75rem;
}

/* ============ 弹窗 ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.modal-content h3 { font-size: 1.1rem; margin-bottom: 12px; }
.modal-content .qrcode {
  width: 200px; height: 200px;
  margin: 0 auto 12px;
  background: #f0f0f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: #999;
}
.modal-content .wechat-id {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--wechat-green);
  margin-bottom: 8px;
}
.modal-content .tip { font-size: .8rem; color: var(--text-light); }
.modal-close {
  margin-top: 16px;
  padding: 8px 24px;
  background: var(--bg);
  border-radius: 20px;
  font-size: .9rem;
  color: var(--text-light);
}

/* ============ Toast 提示 ============ */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.78);
  color: #fff;
  padding: 14px 28px;
  border-radius: 10px;
  font-size: .9rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
  text-align: center;
  max-width: 80vw;
}
.toast.show { opacity: 1; }

/* ============ 管理入口 ============ */
.admin-enter {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 998;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,.15);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  opacity: .5;
  transition: opacity var(--transition);
}
.admin-enter:active { opacity: 1; }

/* ============================================ */
/* 管理后台 ADMIN */
/* ============================================ */

.admin-header {
  background: #2d2d2d;
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: 0 auto;
}
.admin-header h1 { font-size: 1rem; font-weight: 600; }
.admin-back {
  font-size: .85rem;
  color: rgba(255,255,255,.7);
  padding: 4px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.1);
}

/* ============ 拖拽上传区 ============ */
.drop-zone {
  border: 2px dashed #d0d0d0;
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  background: #fafafa;
  touch-action: none;
}
.drop-zone.dragover {
  border-color: var(--primary);
  background: #fff8f3;
}
.drop-zone .icon { font-size: 2.5rem; color: #ccc; margin-bottom: 8px; }
.drop-zone .text { font-size: .9rem; color: var(--text-muted); }
.drop-zone .sub { font-size: .75rem; color: #bbb; margin-top: 4px; }
.drop-zone input[type="file"] {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============ 上传预览 ============ */
.upload-preview {
  display: none;
  margin-top: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.upload-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
}
.upload-preview .remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============ 表单 ============ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:active { background: var(--primary-dark); }
.btn-success {
  background: var(--wechat-green);
  color: #fff;
}
.btn-success:active { background: #06ad56; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:active { background: #f5f5f5; }
.btn-danger {
  background: #e53935;
  color: #fff;
}
.btn-danger:active { background: #c62828; }
.btn-sm {
  padding: 8px 16px;
  font-size: .85rem;
  border-radius: 8px;
}

/* ============ 产品管理列表 ============ */
.admin-product-list { display: flex; flex-direction: column; gap: 12px; }

.admin-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.admin-product-item .thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f0f0;
  flex-shrink: 0;
}
.admin-product-item .info { flex: 1; min-width: 0; }
.admin-product-item .name {
  font-size: .9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-product-item .price {
  font-size: .85rem;
  color: var(--primary);
  font-weight: 600;
}
.admin-product-item .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.admin-product-item .actions button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
}
.btn-edit { background: #e3f2fd; color: #1565c0; }
.btn-del { background: #fce4ec; color: #c62828; }

/* ============ 设置区域 ============ */
.settings-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.settings-section h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ============ 管理首页统计卡片 ============ */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-card .label {
  font-size: .8rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* ============ 响应式 ============ */
@media (min-width: 481px) {
  .container { max-width: 600px; }
  .product-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}
@media (min-width: 769px) {
  .container { max-width: 800px; }
  .product-list { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============ 页面过渡 ============ */
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 隐藏滚动条 (管理页面干净) ============ */
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ============ 删改确认弹窗 ============ */
.confirm-dialog {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-dialog.show { display: flex; }
.confirm-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 300px;
  width: 100%;
  text-align: center;
}
.confirm-box p { font-size: .95rem; margin-bottom: 16px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* ============ 九宫格上传 (3×3 图片网格) ============ */

.grid-9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--slot-gap, 8px);
}

.grid-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: var(--bg, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1.5px solid var(--border, #e8e8e8);
  transition: border-color var(--transition, .25s ease);
}

.grid-slot.add {
  border: 2px dashed var(--border, #d0d0d0);
  background: #fafafa;
  color: var(--text-muted, #999);
  font-size: 2rem;
  transition: border-color var(--transition, .25s ease), background var(--transition, .25s ease);
}
.grid-slot.add:active {
  border-color: var(--primary, #e65c00);
  background: #fff8f3;
}

.grid-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.grid-slot .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition, .25s ease);
  z-index: 2;
}
.grid-slot:hover .remove-btn,
.grid-slot:active .remove-btn {
  opacity: 1;
}

.grid-9-hint {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted, #999);
  margin-top: 8px;
}

/* ============ 画廊灯箱 ============ */

.gallery-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.92);
  z-index: 3000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gallery-overlay.show { display: flex; }

.gallery-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px 80px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.gallery-grid .gallery-item {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition, .25s ease);
}
.gallery-grid .gallery-item.active {
  border-color: var(--primary, #e65c00);
}
.gallery-grid .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-grid .gallery-item.empty {
  visibility: hidden;
}

.gallery-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background var(--transition, .25s ease);
}
.gallery-close:active { background: rgba(255,255,255,.3); }

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background var(--transition, .25s ease);
}
.gallery-nav:active { background: rgba(255,255,255,.3); }
.gallery-nav.prev { left: 8px; }
.gallery-nav.next { right: 8px; }

.gallery-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .5px;
  z-index: 10;
}

/* ============ 九宫格桌面响应 ============ */

@media (min-width: 481px) {
  .grid-9 {
    grid-template-columns: repeat(3, 130px);
    justify-content: center;
  }
}
