/* ==========================================================================
   h5/assets/styles/tokens.css —— 设计令牌与通用组件
   --------------------------------------------------------------------------
   与小程序 styles/tokens.wxss + theme-user.wxss 一一对应。
   唯一的换算：小程序用 rpx（750 设计稿），H5 用 px（375 设计稿），**数值折半**。
   例：28rpx → 14px，88rpx → 44px，32rpx → 16px。

   主题机制也一致：
     · 这里给出的是一套「白底黑字」的默认值（等价 theme-user.wxss）
     · 商户主题色由 core.js 的 applyTheme() 以 CSS 变量覆盖 :root
     · 主题色只作为**强调色**（按钮 / 价格 / 选中态），不翻转底色
   ========================================================================== */

:root {
  /* ---------- 尺度 ---------- */
  --ee-radius-sm: 4px;
  --ee-radius-md: 8px;
  --ee-radius-lg: 12px;
  --ee-radius-full: 999px;

  /* ---------- 主色阶梯 ---------- */
  --ee-primary-50: #ecfeff;
  --ee-primary-100: #cffafe;
  --ee-primary-200: #a5f3fc;
  --ee-primary-300: #67e8f9;
  --ee-primary-400: #22d3ee;
  --ee-primary-500: #06b6d4;
  --ee-primary-600: #0891b2;
  --ee-primary-700: #0e7490;
  --ee-primary-800: #155e75;
  --ee-primary-900: #164e63;

  /* ---------- 中性阶梯 ---------- */
  --ee-neutral-0: #ffffff;
  --ee-neutral-50: #f8fafc;
  --ee-neutral-100: #f1f5f9;
  --ee-neutral-200: #e2e8f0;
  --ee-neutral-300: #cbd5e1;
  --ee-neutral-400: #94a3b8;
  --ee-neutral-500: #64748b;
  --ee-neutral-600: #475569;
  --ee-neutral-700: #334155;
  --ee-neutral-800: #1e293b;
  --ee-neutral-900: #0f172a;

  /* ---------- 状态色 ---------- */
  --ee-state-success: #22c55e;
  --ee-state-warning: #f59e0b;
  --ee-state-error: #ef4444;
  --ee-state-info: #3b82f6;
  --ee-state-success-bg: rgba(34, 197, 94, 0.12);
  --ee-state-warning-bg: rgba(245, 158, 11, 0.12);
  --ee-state-error-bg: rgba(239, 68, 68, 0.12);
  --ee-state-info-bg: rgba(59, 130, 246, 0.12);

  /* ---------- 价格色：全站唯一的红 ---------- */
  --ee-price: #dc2626;

  /* ---------- 营销色（HOT 角标）：墨黑实心块 ---------- */
  --ee-hot-from: #111827;
  --ee-hot-to: #111827;

  /* ---------- 叠在实色底上的前景 ---------- */
  --ee-state-error-foreground: #ffffff;
  --ee-hot-foreground: #ffffff;

  /* ---------- 弹层遮罩 / 播报胶囊 ---------- */
  --ee-overlay: rgba(2, 6, 23, 0.72);
  --ee-feed-bg: rgba(2, 6, 23, 0.72);
  --ee-feed-foreground: #ffffff;
  --ee-feed-avatar-bg: rgba(255, 255, 255, 0.22);
  --ee-feed-ago: rgba(255, 255, 255, 0.6);

  --ee-shadow-knob: 0 1px 4px rgba(2, 6, 23, 0.22);
  --ee-shadow-floating: 0 12px 32px rgba(17, 24, 39, 0.12);

  /* ---------- 字体 ---------- */
  --ee-font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  /* ---------- 字号（rpx / 2） ---------- */
  --fs-xs: 11px;    /* 22rpx */
  --fs-sm: 12px;    /* 24rpx */
  --fs-sub: 13px;   /* 26rpx */
  --fs-base: 14px;  /* 28rpx */
  --fs-md: 15px;    /* 30rpx */
  --fs-lg: 16px;    /* 32rpx */
  --fs-xl: 17px;    /* 34rpx */
  --fs-2xl: 20px;   /* 40rpx */
  --fs-3xl: 24px;   /* 48rpx */

  /* ---------- 布局 ---------- */
  --ee-app-max: 480px;
  --ee-tabbar-h: 50px;
  --ee-head-h: 48px;   /* 96rpx */
  --ee-ctrl-h: 44px;   /* 88rpx */

  /* ---------- 默认外观（白底黑字） ---------- */
  --ee-background: #ffffff;
  --ee-foreground: #111827;
  --ee-card: #ffffff;
  --ee-card-foreground: #111827;
  --ee-popover: #ffffff;
  --ee-popover-foreground: #111827;

  --ee-primary: #0891b2;
  --ee-primary-foreground: #ffffff;
  --ee-primary-bg: rgba(8, 145, 178, 0.10);

  --ee-muted: #f6f7f9;
  --ee-muted-foreground: #6b7280;
  --ee-border: #e5e7eb;
  --ee-input: #f6f7f9;
  --ee-ring: #0891b2;

  --ee-surface-1: #ffffff;
  --ee-surface-2: #f1f3f7;
  --ee-surface-3: #e6e9ef;
  --ee-skeleton-shine: rgba(17, 24, 39, 0.05);

  /* tabBar：恒白底黑字，只有选中态跟随主题（与 navChrome 同口径） */
  --ee-tab-text: #6b7280;
  --ee-tab-selected: #111827;
  --ee-tab-bg: #ffffff;
  --ee-tab-border: #e5e7eb;
}

/* ==========================================================================
   基础
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--ee-font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ee-foreground);
  background: var(--ee-background);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

img {
  display: block;
  border: 0;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  outline: none;
  border: 0;
  background: none;
  color: inherit;
}

/* 搜索框去掉浏览器自带的清除按钮与放大镜，外观与小程序一致 */
input[type='search'] {
  appearance: none;
  -webkit-appearance: none;
}

input[type='search']::-webkit-search-decoration,
input[type='search']::-webkit-search-cancel-button {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* 页面容器：手机上铺满；宽屏上居中成一列「手机宽度」 */
.app-shell {
  position: relative;
  width: 100%;
  max-width: var(--ee-app-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ee-background);
  color: var(--ee-foreground);
}

@media (min-width: 520px) {
  body {
    background: #eef1f5;
  }
  .app-shell {
    box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.05), 0 18px 48px rgba(17, 24, 39, 0.08);
  }
}

/* 页面淡入：换页时不闪白 */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ee-background);
  animation: ee-page-in 0.16s ease-out;
}

@keyframes ee-page-in {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* ==========================================================================
   布局
   ========================================================================== */
.ee-main {
  flex: 1;
  padding: 0 16px;
}

.ee-main-with-tabbar {
  padding-bottom: calc(var(--ee-tabbar-h) + 30px + env(safe-area-inset-bottom));
}

/* 内页顶部导航（返回键 + 标题） */
.ee-page-head {
  height: var(--ee-head-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ee-background);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--ee-border);
}

.ee-page-head-back {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ee-radius-md);
  background: var(--ee-surface-2);
  border: 1px solid var(--ee-border);
  flex: 0 0 auto;
  margin: -6px 0 -6px -6px;
  position: relative;
  cursor: pointer;
}

/* 触控热区：由覆盖层撑到 44px（负外边距不能扩大热区） */
.ee-page-head-back::after,
.ee-tap-safe::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  min-width: 100%;
  min-height: 100%;
}

.ee-tap-safe {
  position: relative;
}

.ee-page-head-aside {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  margin: -6px -6px -6px 0;
}

.ee-page-head-title {
  font-size: var(--fs-xl);
  line-height: 1.35;
  font-weight: 700;
  color: var(--ee-foreground);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ee-page-head-title.lg { font-size: var(--fs-2xl); }
.ee-page-head-title.fill { flex: 1; }

/* ==========================================================================
   卡片 / 文本
   ========================================================================== */
.ee-card {
  background: var(--ee-card);
  border: 1px solid var(--ee-border);
  border-radius: var(--ee-radius-lg);
  padding: 16px;
}

.ee-card-flush {
  background: var(--ee-card);
  border: 1px solid var(--ee-border);
  border-radius: var(--ee-radius-lg);
  overflow: hidden;
}

.ee-title { font-size: var(--fs-lg); font-weight: 600; color: var(--ee-foreground); }
.ee-text { font-size: var(--fs-base); color: var(--ee-foreground); }
.ee-text-sm { font-size: var(--fs-sm); color: var(--ee-muted-foreground); }
.ee-text-xs { font-size: var(--fs-xs); color: var(--ee-muted-foreground); }
.ee-muted { color: var(--ee-muted-foreground); }
.ee-primary-text { color: var(--ee-primary); }

.ee-price { font-size: var(--fs-lg); font-weight: 700; color: var(--ee-price); }
.ee-price-origin {
  font-size: var(--fs-xs);
  color: var(--ee-muted-foreground);
  text-decoration: line-through;
}

/* ==========================================================================
   按钮
   ========================================================================== */
.ee-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--ee-ctrl-h);
  border-radius: var(--ee-radius-md);
  font-size: var(--fs-base);
  font-weight: 500;
  border: none;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.12s ease;
}

.ee-btn:active { opacity: 0.86; }

.ee-btn-primary {
  background: var(--ee-primary);
  color: var(--ee-primary-foreground);
}

.ee-btn-ghost {
  background: var(--ee-surface-2);
  color: var(--ee-foreground);
  border: 1px solid var(--ee-border);
}

.ee-btn-block { width: 100%; }

.ee-btn[disabled],
.ee-btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ==========================================================================
   表单
   ========================================================================== */
.ee-field { margin-bottom: 12px; }

.ee-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--ee-muted-foreground);
  margin-bottom: 6px;
}

.ee-input,
.ee-textarea,
.ee-picker {
  width: 100%;
  height: var(--ee-ctrl-h);
  padding: 0 12px;
  font-size: var(--fs-base);
  line-height: 1.4;
  background: var(--ee-surface-2);
  border: 1px solid var(--ee-border);
  border-radius: var(--ee-radius-md);
  color: var(--ee-foreground);
  box-sizing: border-box;
}

.ee-textarea {
  height: auto;
  min-height: var(--ee-ctrl-h);
  padding: 10px 12px;
  line-height: 1.6;
  resize: none;
  display: block;
}

.ee-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  /* 原生 select 覆盖在外层，这里只负责外观 */
  appearance: none;
  -webkit-appearance: none;
}

.ee-input::placeholder,
.ee-textarea::placeholder {
  color: var(--ee-muted-foreground);
  opacity: 1;
}

.ee-field-error {
  border-color: var(--ee-state-error) !important;
  background-color: var(--ee-state-error-bg) !important;
}

.ee-error-msg {
  display: flex;
  align-items: center;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--ee-state-error);
}

/* ==========================================================================
   徽章
   ========================================================================== */
.ee-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--ee-radius-full);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

.ee-badge-primary { color: var(--ee-primary); background: var(--ee-primary-bg); }
.ee-badge-success { color: var(--ee-state-success); background: var(--ee-state-success-bg); }
.ee-badge-warning { color: var(--ee-state-warning); background: var(--ee-state-warning-bg); }
.ee-badge-error { color: var(--ee-state-error); background: var(--ee-state-error-bg); }
.ee-badge-muted { color: var(--ee-muted-foreground); background: var(--ee-surface-2); }

/* ==========================================================================
   骨架屏
   ========================================================================== */
.ee-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--ee-surface-2);
  border-radius: var(--ee-radius-md);
}

.ee-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--ee-skeleton-shine), transparent);
  animation: ee-shimmer 1.4s infinite;
}

@keyframes ee-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==========================================================================
   空状态
   ========================================================================== */
.ee-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.ee-empty-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ee-radius-full);
  background: var(--ee-surface-2);
  color: var(--ee-muted-foreground);
  margin-bottom: 12px;
}

.ee-empty-title {
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--ee-foreground);
  margin-bottom: 6px;
}

.ee-empty-desc {
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--ee-muted-foreground);
  margin-bottom: 16px;
}

.ee-empty-action {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  border-radius: var(--ee-radius-full);
  font-size: var(--fs-sub);
  font-weight: 500;
  background: var(--ee-primary);
  color: var(--ee-primary-foreground);
  cursor: pointer;
}

/* ==========================================================================
   两列网格
   ★ 用 flex-basis 而不是 width:calc()：卡片自带 1px 边框，
     width 会额外多出 2px，两列就排不下（与小程序踩过的坑同源）。
   ========================================================================== */
.ee-grid-2 {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ee-grid-2 > .ee-grid-item {
  flex: 0 0 calc(50% - 6px);
  max-width: calc(50% - 6px);
  min-width: 0;
}

/* ==========================================================================
   其它通用件
   ========================================================================== */
.ee-divider {
  height: 1px;
  background: var(--ee-border);
  margin: 12px 0;
}

.ee-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-base);
}

.ee-row-label { color: var(--ee-muted-foreground); }
.ee-row-value { color: var(--ee-foreground); }

/* 吸底操作栏 */
.ee-actionbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--ee-app-max);
  z-index: 50;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--ee-card);
  border-top: 1px solid var(--ee-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   底部 tabBar（H5 自绘，图标用 SVG 跟随主题）
   ========================================================================== */
.ee-tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--ee-app-max);
  z-index: 60;
  height: calc(var(--ee-tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--ee-tab-bg);
  border-top: 1px solid var(--ee-tab-border);
}

.ee-tabbar[hidden] { display: none; }

.ee-tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--ee-tab-text);
  cursor: pointer;
  transition: color 0.12s ease;
}

.ee-tabbar-item.on {
  color: var(--ee-tab-selected);
}

.ee-tabbar-item svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* ==========================================================================
   轻提示
   ========================================================================== */
.ee-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3000;
  max-width: 76vw;
  padding: 12px 18px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.82);
  color: #ffffff;
  font-size: var(--fs-base);
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
  animation: ee-toast-in 0.16s ease-out;
}

.ee-toast[hidden] { display: none; }

@keyframes ee-toast-in {
  from { opacity: 0; transform: translate(-50%, -46%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ==========================================================================
   遮罩 / 对话框 / 底部弹层 / 图片预览
   ========================================================================== */
.ee-mask {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--ee-overlay);
  display: flex;
  animation: ee-fade 0.16s ease-out;
}

.ee-mask.center {
  align-items: center;
  justify-content: center;
  padding: 0 32px;
}

.ee-mask.bottom {
  align-items: flex-end;
}

@keyframes ee-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ee-dialog {
  width: 100%;
  max-width: calc(var(--ee-app-max) - 64px);
  background: var(--ee-popover);
  border-radius: var(--ee-radius-lg);
  overflow: hidden;
  box-shadow: var(--ee-shadow-floating);
  animation: ee-pop-in 0.18s ease-out;
}

@keyframes ee-pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.ee-dialog-title {
  padding: 20px 20px 6px;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ee-popover-foreground);
  text-align: center;
}

.ee-dialog-body {
  padding: 0 20px 18px;
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--ee-muted-foreground);
  text-align: center;
  white-space: pre-wrap;
  max-height: 50vh;
  overflow-y: auto;
}

.ee-dialog-actions {
  display: flex;
  border-top: 1px solid var(--ee-border);
}

.ee-dialog-btn {
  flex: 1;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-md);
  color: var(--ee-popover-foreground);
  cursor: pointer;
}

.ee-dialog-btn.primary {
  color: var(--ee-primary);
  font-weight: 600;
}

.ee-dialog-btn + .ee-dialog-btn {
  border-left: 1px solid var(--ee-border);
}

.ee-sheet {
  width: 100%;
  max-width: var(--ee-app-max);
  margin: 0 auto;
  padding: 20px 20px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  border-radius: var(--ee-radius-lg) var(--ee-radius-lg) 0 0;
  background: var(--ee-popover);
  animation: ee-sheet-up 0.22s ease-out;
}

@keyframes ee-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 图片预览 */
.ee-viewer {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ee-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ee-viewer-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}

.ee-viewer-count {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--fs-sm);
}
