/* ============================================
   三易智能科技平台 - 移动端样式
   Mobile First 设计
   ============================================ */

/* 变量 */
:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --secondary: #22c55e;
  --accent: #f97316;
  --danger: #ef4444;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --bg: #f8fafc;
  --bg-white: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

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

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

/* 顶部导航栏 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  border-bottom: 1px solid var(--border);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.navbar .back-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text);
  flex-shrink: 0;
}

.navbar .title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin-right: 32px;
}

.navbar.search-bar {
  background: var(--primary);
  height: 52px;
  border: none;
}

.search-input {
  flex: 1;
  height: 36px;
  background: white;
  border-radius: 18px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.search-input input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
}

/* Banner 轮播 */
.banner {
  margin: 12px 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 24px 20px;
  position: relative;
  min-height: 120px;
}

.banner h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.banner p {
  font-size: 13px;
  opacity: 0.9;
}

.banner-dots {
  position: absolute;
  bottom: 12px;
  right: 20px;
  display: flex;
  gap: 6px;
}

.banner-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
}

.banner-dots span.active {
  width: 16px;
  border-radius: 3px;
  background: white;
}

/* 分类宫格 */
.category-grid {
  background: white;
  margin: 0 16px 12px;
  border-radius: var(--radius);
  padding: 16px 8px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px 0;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
}

.category-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

/* 区块标题 */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.section-title h3 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title h3::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

.section-title .more {
  font-size: 12px;
  color: var(--text-muted);
}

/* 商品网格 */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 16px;
}

.product-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-image {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
}

.product-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.product-tag.new {
  background: var(--secondary);
}

.product-info {
  padding: 10px;
}

.product-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

.product-price {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.product-price .now {
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
}

.product-price .now::before {
  content: '¥';
  font-size: 12px;
}

.product-price .original {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.product-sales {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 底部导航栏 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  max-width: 750px;
  margin: 0 auto;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  position: relative;
}

.tab-item.active {
  color: var(--primary);
}

.tab-item .icon {
  font-size: 22px;
}

.tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(16px);
  background: var(--danger);
  color: white;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* 商品详情页 */
.product-detail-img {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 100px;
}

.product-detail-info {
  background: white;
  padding: 16px;
}

.product-detail-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.product-detail-price .now {
  font-size: 24px;
  font-weight: 700;
  color: var(--danger);
}

.product-detail-price .now::before {
  content: '¥';
  font-size: 14px;
}

.product-detail-price .original {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: line-through;
}

.product-detail-price .sales {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.product-detail-name {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.product-detail-tags {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-detail-tags span {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 4px;
}

/* 规格选择 */
.spec-section {
  background: white;
  margin-top: 10px;
  padding: 16px;
}

.spec-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.spec-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spec-option {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: white;
  min-width: 80px;
  text-align: center;
}

.spec-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
}

/* 底部操作栏 */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding-left: 12px;
  padding-right: 12px;
  z-index: 200;
  max-width: 750px;
  margin: 0 auto;
}

.action-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  color: var(--text-secondary);
  padding: 0 10px;
  gap: 2px;
}

.action-icon .icon {
  font-size: 20px;
}

.action-btn {
  flex: 1;
  height: 40px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn.cart {
  background: var(--accent);
  margin-right: 8px;
}

.action-btn.buy {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* 购物车页 */
.cart-list {
  padding: 12px 16px;
}

.cart-item {
  background: white;
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.cart-item-img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.cart-item-name {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item-sku {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
}

.cart-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--danger);
}

.cart-item-price::before {
  content: '¥';
  font-size: 11px;
}

.quantity-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.quantity-control button {
  width: 28px;
  height: 24px;
  font-size: 16px;
  color: var(--text-secondary);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quantity-control .num {
  width: 36px;
  text-align: center;
  font-size: 13px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* 结算栏 */
.checkout-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 200;
  max-width: 750px;
  margin: 0 auto;
}

.checkout-bar .total {
  flex: 1;
  font-size: 13px;
}

.checkout-bar .total .amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--danger);
}

.checkout-bar .total .amount::before {
  content: '¥';
  font-size: 12px;
}

.checkout-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  height: 40px;
  padding: 0 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.checkout-btn:disabled {
  opacity: 0.5;
}

/* 空状态 */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}

.empty-state .icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.empty-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 14px;
}

/* 订单确认页 */
.address-card {
  background: white;
  margin: 12px 16px;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.address-card .icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.address-info { flex: 1; }
.address-info .name-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.address-info .detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.order-products-section {
  background: white;
  margin: 0 16px 12px;
  border-radius: var(--radius);
  padding: 12px 16px;
}

.order-product-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.order-product-item:last-child {
  border-bottom: none;
}

.order-product-img {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.order-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.order-product-name {
  font-size: 13px;
  line-height: 1.4;
}

.order-product-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-product-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

.order-product-qty {
  font-size: 12px;
  color: var(--text-muted);
}

/* 金额明细 */
.amount-detail {
  background: white;
  margin: 0 16px 12px;
  border-radius: var(--radius);
  padding: 4px 16px;
}

.amount-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.amount-row:last-child {
  border-bottom: none;
  font-weight: 600;
}

.amount-row .label { color: var(--text-secondary); }
.amount-row .value { color: var(--text); }
.amount-row:last-child .value { color: var(--danger); font-size: 16px; }

/* 订单列表页 */
.order-status-bar {
  position: sticky;
  top: 48px;
  background: white;
  display: flex;
  border-bottom: 1px solid var(--border);
  z-index: 90;
}

.order-status-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
  position: relative;
}

.order-status-item.active {
  color: var(--primary);
  font-weight: 600;
}

.order-status-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.order-card {
  background: white;
  margin: 12px 16px;
  border-radius: var(--radius);
  overflow: hidden;
}

.order-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.order-no { color: var(--text-muted); }

.order-status {
  font-weight: 600;
  font-size: 13px;
}

.order-status.pending { color: var(--accent); }
.order-status.paid { color: var(--secondary); }
.order-status.shipped { color: var(--primary); }
.order-status.completed { color: var(--text-muted); }

.order-card-body {
  padding: 12px 16px;
}

.order-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-total {
  font-size: 13px;
}

.order-total .amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
}

.order-btns {
  display: flex;
  gap: 8px;
}

.btn-outline {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  background: white;
}

.btn-primary {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  color: white;
  background: var(--primary);
}

/* 适配查询工具 */
.adapter-tool {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  margin: 12px 16px;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.adapter-tool .icon { font-size: 28px; }
.adapter-tool .text { flex: 1; }
.adapter-tool .text h4 { font-size: 14px; margin-bottom: 2px; }
.adapter-tool .text p { font-size: 11px; color: #92400e; }
.adapter-tool .arrow { font-size: 18px; color: #92400e; }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* 加载状态 */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-mask.show {
  display: flex;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 750px;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  max-height: 70vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

/* 支付方式选择 */
.payment-methods {
  margin-bottom: 16px;
}

.payment-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.payment-method .icon {
  font-size: 28px;
}

.payment-method .info { flex: 1; }
.payment-method .info .name { font-size: 14px; font-weight: 500; }
.payment-method .info .desc { font-size: 11px; color: var(--text-muted); }

.payment-qr-section {
  text-align: center;
  padding: 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.payment-qr-section .qr-placeholder {
  width: 180px;
  height: 180px;
  margin: 0 auto 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.payment-qr-section .amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 4px;
}

.payment-qr-section .tip {
  font-size: 12px;
  color: var(--text-muted);
}

.confirm-btn {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 600;
}
