/* ============================================================
 * 阶段8 美团严选（公域联盟）— 商品展示 + CPS跳转
 * 配套：portal-stage8.js（拉商品/跳转购买）
 * 版本：v=0904d5
 *
 * 设计原则（与 portal-stage4/stage7 一致 — 工具栏风格）：
 *   - 视觉退后（公域联盟非主项）
 *   - 浅灰底 + 细边框 + 小图标
 *   - 桌面 4 列 / 平板 2 列 / 手机 1 列
 *   - 微信 X5 兼容：触摸目标 ≥44px、最小字号 12px
 * ============================================================ */

/* 美团严选主容器 */
.stage8-mt {
  margin: 24px 0;
  padding: 0 16px;
}

.stage8-mt .stage8-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}

.stage8-mt .stage8-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage8-mt .stage8-section-sub {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
}

.stage8-mt .stage8-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 500;
}

.stage8-mt .stage8-section-refresh {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #6b7280);
  border: 0.5px solid #e5e7eb;
  cursor: pointer;
  min-height: 28px;
  transition: all .15s;
}

.stage8-mt .stage8-section-refresh:hover {
  color: var(--brand, #4f46e5);
  border-color: var(--brand, #4f46e5);
}

/* 商品列表 grid */
.stage8-mt-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stage8-mt-card {
  background: #f8fafc;
  border: 0.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all .2s;
  cursor: pointer;
  min-height: 168px;
  overflow: hidden;
}

.stage8-mt-card:hover {
  background: #fff;
  border-color: var(--brand, #4f46e5);
  box-shadow: 0 4px 12px rgba(79, 70, 229, .12);
  transform: translateY(-1px);
}

.stage8-mt-card-image {
  width: 100%;
  height: 96px;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 0.5px solid #f1f5f9;
}

.stage8-mt-card-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.stage8-mt-card-image-fallback {
  font-size: 28px;
  color: #cbd5e1;
}

.stage8-mt-card-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted, #6b7280);
}

.stage8-mt-card-brand img {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f1f5f9;
}

.stage8-mt-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1f2937);
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 34px;
}

.stage8-mt-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.stage8-mt-card-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand, #4f46e5);
}

.stage8-mt-card-price-original {
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  text-decoration: line-through;
  margin-left: 4px;
  font-weight: 400;
}

.stage8-mt-card-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--brand, #4f46e5);
  color: #fff;
  border: none;
  cursor: pointer;
  min-height: 28px;
  transition: opacity .15s;
}

.stage8-mt-card-btn:hover { opacity: .85; }
.stage8-mt-card-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.stage8-mt-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
}

.stage8-mt-card-commission {
  color: #f59e0b;
  font-weight: 500;
}

/* 加载中/空状态 */
.stage8-mt-loading,
.stage8-mt-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted, #6b7280);
  font-size: 13px;
}

.stage8-mt-loading::before {
  content: '🌀';
  display: block;
  font-size: 22px;
  margin-bottom: 6px;
  animation: stage8-spin 1.2s linear infinite;
}

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

/* 响应式 */
@media (max-width: 1024px) {
  .stage8-mt-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .stage8-mt-list { grid-template-columns: 1fr; }
  .stage8-mt-card { min-height: 152px; }
  .stage8-mt-card-image { height: 88px; }
}

/* 错误状态 */
.stage8-mt-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  text-align: center;
  grid-column: 1 / -1;
}

/* ============================================================================
 * 美团跳转提示弹窗（点击立即购买时显示）
 * ============================================================================ */
.stage8-mt-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
}

.stage8-mt-modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: stage8-pop .25s ease-out;
}

@keyframes stage8-pop {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.stage8-mt-modal h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #1f2937);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage8-mt-modal .desc {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  line-height: 1.6;
  margin-bottom: 16px;
}

.stage8-mt-modal .product-info {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-primary, #1f2937);
  line-height: 1.6;
}

.stage8-mt-modal .product-info strong {
  color: var(--brand, #4f46e5);
}

.stage8-mt-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.stage8-mt-modal-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  border: none;
  transition: opacity .15s;
}

.stage8-mt-modal-actions .go-btn {
  background: var(--brand, #4f46e5);
  color: #fff;
}

.stage8-mt-modal-actions .cancel-btn {
  background: #f1f5f9;
  color: var(--text-primary, #1f2937);
}

.stage8-mt-modal-actions button:hover { opacity: .85; }

/* ============================================================
 * 跳转 loading 提示层（修王总手机端空白页 bug 时加）
 * 显示"正在打开美团…" 半透明遮罩，覆盖全屏
 * ============================================================ */
.stage8-mt-loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: stage8-mt-fade-in 0.2s ease;
}

.stage8-mt-loading-box {
  background: #fff;
  border-radius: 12px;
  padding: 18px 28px;
  font-size: 15px;
  color: #1f2937;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  font-weight: 500;
  max-width: 88vw;
  text-align: center;
}

@keyframes stage8-mt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
