/**
 * 手机端适配覆盖层（商城前台 React 打包样式之后加载，用同优先级覆盖）。
 * 只处理移动端的列表密度、顶部大图、iPhone 安全区与输入框缩放，不影响桌面端布局。
 */

/* 商品列表（手机端）：价目表形态 —— 左小图标 / 名称左、价格右对齐 / 行间分隔线（显示种类最多） */
@media (max-width: 680px) {
  .product-grid {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 0;
    border-top: 1px solid var(--line);
  }
  .product-card.ui-card {
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  .product-card:hover {
    border-color: var(--line);
    box-shadow: none;
    transform: none;
  }
  .product-card .product-main {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-height: 0;
    padding: 10px 2px;
  }
  .product-card .product-card-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    align-self: center;
    aspect-ratio: auto;
    border-radius: 9px;
  }
  .product-card .product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  .product-card .product-card-image svg {
    width: 20px;
    height: 20px;
  }
  /* 名称占满左侧、价格固定右对齐，四行价格在同一竖线上，便于比价 */
  .product-card .product-card-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name price";
    align-items: baseline;
    column-gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 0;
  }
  .product-card .product-card-info h3 {
    grid-area: name;
    display: block;
    min-width: 0;
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: unset;
  }
  .product-card .product-card-info strong {
    grid-area: price;
    justify-self: end;
    margin: 0;
    font-size: 13.5px;
    line-height: 1.4;
    white-space: nowrap;
  }
  /* 不显示分类 / 商品介绍 */
  .product-card .product-card-category {
    display: none;
  }
  .product-card .product-recommend {
    display: none;
  }
  /* 点按反馈 */
  .product-card:active {
    background: #f4f6f8;
  }
}

/* iPhone 底部横条安全区：底部导航与页面留白 */
.bottom-nav {
  height: calc(62px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mall-main {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}
.site-header {
  padding-top: env(safe-area-inset-top, 0px);
}

/* 顶部大图：图片按完整比例显示，避免小方图被拉伸裁切成大字 */
.hero-image {
  object-fit: contain;
  background: #172233;
}

/* iOS 聚焦输入框时页面不自动放大 */
@media (max-width: 680px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

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

/* 个人中心 / 充值页：费率卡片已隐藏，指标网格只剩「账户余额 / 累计充值」两张，
   仍按 3 列排会留一个空列，手机上每张只有 111px 宽、文字被挤断行。改为自动铺满。 */
.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
}

@media (max-width: 680px) {
  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
  }
  .metric-grid > * {
    padding: 14px 12px !important;
  }
  .metric-grid span,
  .metric-grid small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .metric-grid strong {
    white-space: nowrap;
    font-size: 19px;
  }
}

/* ===== 个人中心 =====
   左卡片原本跟右侧内容同高（.profile-layout 默认拉伸），右侧一长就留出几百像素空白；
   窄屏下同一张卡片又占掉 280 多像素，余额要往下翻才看得到。
   桌面端让卡片贴合内容，窄屏改成「头像左、姓名账号右、两个按钮并排」的紧凑横向卡片。 */
.profile-layout {
  align-items: start;
}

/* 0 条记录时的空状态不需要 190px 高 */
.recharge-history .empty-state {
  min-height: 148px;
  padding: 18px;
}

@media (max-width: 760px) {
  /* 760px 以下一律单列，避免中间宽度下内容列被压到 370px 左右 */
  .profile-layout {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .profile-summary {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    row-gap: 10px;
    padding: 14px;
    text-align: left;
  }
  /* 头像跨两行、姓名与账号固定放右列，隐藏的等级块不参与排版 */
  .profile-summary .avatar {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 52px;
    height: 52px;
    margin: 0;
    border-radius: 14px;
  }
  .profile-summary .avatar svg {
    width: 24px;
  }
  .profile-summary h2 {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    margin: 0;
    font-size: 16px;
  }
  .profile-summary p {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    margin: 0;
  }
  .profile-summary .profile-level {
    grid-column: 1 / -1;
  }
  .profile-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 2px;
  }
  .profile-actions .ui-button {
    min-height: 38px;
  }

  /* 小屏上卡片内的栏目名和空状态再收一点 */
  .profile-layout .eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
  }
  .recharge-history .empty-state {
    min-height: 120px;
    padding: 14px;
  }
  .recharge-history .empty-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 10px;
  }
  /* 下级账号那一行的小字（账号 · 时间）过长时省略，不要把行撑成两行 */
  .subuser-row small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .profile-layout .ui-button,
  .profile-layout .subuser-row,
  .profile-layout .recharge-row {
    -webkit-tap-highlight-color: transparent;
  }
}

/* ===== 个人中心：宽屏布局 =====
   金额两张卡已由上面的 auto-fit 铺满整行；这里把下方「邀请中心 / 资金明细」在宽屏并排，
   避免右侧内容一路竖向堆叠、页面过长。1180px 以下保持单列（内容列不会被压窄）。 */
@media (min-width: 1180px) {
  .profile-content {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  .profile-content > .metric-grid {
    grid-column: 1 / -1;
  }
  /* 右侧滚动看列表时，左侧账号信息始终可见 */
  .profile-summary {
    position: sticky;
    top: 84px;
  }
}

/* 长列表限高 + 内部滚动：下级再多、资金明细再长，也不会把整页拉长 */
.subuser-list,
.recharge-list {
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* 打包样式给指标卡和资金明细都单独设了 padding，唯独漏了邀请卡，
   导致「邀请中心」的内容一直贴着卡片边。这里补齐，与资金明细对齐。 */
.profile-content .invite-panel {
  padding: 20px;
}

@media (max-width: 680px) {
  .profile-content .invite-panel {
    padding: 16px;
  }
}

/* 长账号省略；金额用等宽数字，纵向对齐更好比 */
.profile-summary p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.metric-grid strong,
.recharge-list,
.subuser-list {
  font-variant-numeric: tabular-nums;
}
