/* ============================================================
   丽人梦想秀® · 手机版全栏目统一适配
   Mobile-First Comprehensive Fix
   ============================================================ */

/* ── 全局基础 ── */
@media (max-width: 768px) {
  /* 根字体 */
  html { font-size: 15px; -webkit-text-size-adjust: 100%; }

  /* 主内容区 */
  .main-content {
    margin-left: 0 !important;
    padding: 14px 10px 90px !important;
    max-width: 100vw !important;
    overflow-x: hidden;
  }
  #page-content { max-width: 100% !important; }

  /* Hero区域 */
  .hero-gradient,
  [style*="linear-gradient"][style*="border-radius:24px"],
  [style*="linear-gradient"][style*="border-radius:20px"] {
    padding: 20px 14px !important;
    border-radius: 16px !important;
  }
  [style*="linear-gradient"] h1,
  .page-title { font-size: 18px !important; }
  [style*="linear-gradient"] p { font-size: 11px !important; }

  /* 所有内联padding过大的修复 */
  [style*="padding:48px"],
  [style*="padding:44px"],
  [style*="padding:40px"],
  [style*="padding:36px"],
  [style*="padding:32px"] {
    padding: 20px 14px !important;
  }
  [style*="padding:28px"] { padding: 16px 12px !important; }

  /* ═══ 网格系统 ═══ */
  .row { margin-left: -4px; margin-right: -4px; }
  .row > [class*="col-"] { padding-left: 4px; padding-right: 4px; }
  .row.g-3, .row.g-4, .row.g-2, .row.g-1 { --bs-gutter-x: 6px; --bs-gutter-y: 6px; }

  /* 所有col-md强制全宽 */
  [class*="col-md-"] {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  /* col-6保留半宽用于2列统计 */
  .col-6 { width: 50% !important; flex: 0 0 50% !important; max-width: 50% !important; }

  /* grid布局也改单列 */
  [style*="grid-template-columns:repeat(2,1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  /* 1fr gap修正 */
  [style*="grid-template-columns: 1fr"] { gap: 6px !important; }
  [style*="grid-template-columns:1fr"] { gap: 6px !important; }

  /* ═══ 表格 ═══ */
  .table, table {
    font-size: 10px !important;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .table td, .table th, table td, table th {
    padding: 5px 6px !important;
    white-space: nowrap;
  }

  /* ═══ 卡片 ═══ */
  .card-stat, .card-glass, [class*="card"] {
    padding: 12px !important;
    border-radius: 12px !important;
  }
  .card-stat .value { font-size: 20px !important; }
  .card-stat .icon { font-size: 22px !important; }

  /* ═══ 按钮 ═══ */
    padding: 10px 16px !important;
    font-size: 13px !important;
    min-height: 40px;
    touch-action: manipulation;
  }
  .btn-primary, .btn-gold, .btn-outline, .btn-sm {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ═══ 输入框 ═══ */
  input:not([type="checkbox"]):not([type="radio"]),
  select, textarea, .form-control {
    font-size: 16px !important; /* 防止iOS缩放 */
    padding: 10px 12px !important;
    min-height: 42px;
  }

  /* ═══ 标题 ═══ */
  h1 { font-size: 20px !important; }
  h2 { font-size: 17px !important; }
  h3 { font-size: 14px !important; }
  h4, h5 { font-size: 13px !important; }
  h6 { font-size: 12px !important; }
  .page-title { font-size: 18px !important; }

  /* ═══ 字体 ═══ */
  body, p, li, span, div { font-size: inherit; }
  [style*="font-size:32px"] { font-size: 22px !important; }
  [style*="font-size:30px"] { font-size: 20px !important; }
  [style*="font-size:28px"] { font-size: 19px !important; }
  [style*="font-size:26px"] { font-size: 18px !important; }
  [style*="font-size:24px"] { font-size: 17px !important; }
  [style*="font-size:22px"] { font-size: 16px !important; }

  /* ═══ 统计数字卡片 ═══ */
  [style*="font-size:28px;color:#C9A25B"],
  [style*="font-size:30px;color:#C9A25B"],
  .stat-card-anim .stat-val {
    font-size: 20px !important;
  }

  /* ═══ Flex row强制换行 ═══ */
  [style*="display:flex"][style*="gap:"]:not(nav):not(.sidebar):not(.sidebar-footer) {
    flex-wrap: wrap !important;
  }

  /* ═══ 3D地图Canvas ═══ */
  #map3d-container, #map3d-canvas {
    height: 280px !important;
    border-radius: 14px !important;
  }
  #map3d-container canvas { height: 280px !important; }

  /* ═══ 联邦总览 ═══ */
  .fed-grid { grid-template-columns: 1fr !important; }
  .fed-hero { padding: 20px 14px !important; }
  .fed-hero-title { font-size: 20px !important; }
  .fed-hero-stats { flex-direction: column; gap: 8px; }
  .fed-stat-value { font-size: 24px !important; }
  .fed-detail-grid { grid-template-columns: 1fr !important; }

  /* ═══ 百花池 ═══ */
  .hf-brand-grid { grid-template-columns: 1fr !important; }
  .hf-hero { padding: 20px 14px !important; }
  .hf-hero-title { font-size: 20px !important; }
  .hf-carousel-slide { flex-direction: column !important; padding: 16px !important; }
  .hf-carousel-img { width: 80px !important; height: 80px !important; font-size: 32px !important; }

  /* ═══ 会员/贡献值/股权 ═══ */
  .membership-header { padding: 20px 14px !important; }
  .membership-header h3 { font-size: 18px !important; }

  /* ═══ 弹窗 ═══ */
  .modal-card { width: 95vw !important; max-height: 90vh !important; }
  .modal-header { padding: 14px !important; }
  .modal-body { padding: 14px !important; }
  .modal-overlay { padding: 8px !important; }

  /* ═══ Toast ═══ */
  .toast-container { top: 10px; right: 8px; left: 8px; }
  .toast { min-width: auto; max-width: 100%; font-size: 12px; }

  /* ═══ 市场版图区域卡片 ═══ */
  [onclick*="market-channels"] { cursor: pointer; }

  /* ═══ 问题：某些页面固定宽度div ═══ */
  [style*="max-width:1100px"],
  [style*="max-width: 1100px"],
  [style*="max-width:1200px"],
  [style*="max-width: 1200px"] {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* ═══ iframe/嵌入式内容 ═══ */
  iframe, embed, object { max-width: 100% !important; }

  /* ═══ 图片 ═══ */
  img { max-width: 100%; height: auto; }

  /* ═══ 操作按钮行 ═══ */
  [style*="display:flex;gap:"] button {
    margin-bottom: 4px;
  }
}

/* ── 极小屏 (< 400px) ── */
@media (max-width: 400px) {
  .main-content { padding: 10px 6px 90px !important; }
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  h1 { font-size: 18px !important; }
  .stat-card-anim .stat-val { font-size: 18px !important; }
  #map3d-container, #map3d-canvas { height: 220px !important; }
  #map3d-container canvas { height: 220px !important; }
}
