/* ============================================================
   responsive-tools.css  v1.2
   工具页 / 表单页 响应式基础层（保单检视、预约咨询、在线留言、
   快捷咨询、财务体检、保障缺口分析、家庭保单整理 等）
   设计原则：仅通过媒体查询在 ≤992px 生效，桌面端（>992px）完全不受影响；
   所有移动端强覆盖均带 !important，以压制页面内联 style 与既有媒体查询。
   ============================================================ */

/* ---------- 0. 全局安全：盒模型 + 横向溢出防护 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; max-width: 100%; overflow-x: hidden; }
body { max-width: 100%; overflow-x: hidden; }

/* 兜底：仅约束「自定义全幅区块」不得超出视口。
   注意：.container 的桌面端居中限宽由 Bootstrap 负责（max-width:1300px + margin:auto），
   此处绝不可对 .container 加全局 max-width:100% !important，否则会抵消 Bootstrap 的居中，
   导致 PC 端内容贴边、毫无边距。 */
.form-wrapper, .msg-body, .info-banner, .compliance-box, .hero-unified, .hero-banner { max-width: 100% !important; }
.hero-unified p, .hero-banner p, .info-banner, .compliance-box, .msg-body p, .form-wrapper > p, .policy-card p {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}

/* 移动端 / 平板：容器限宽到视口，抵消 Bootstrap 自定义 .container{min-width:992px!important}
   在 ≤991px 造成的横向溢出（桌面端 >992px 不生效，保留 Bootstrap 的居中限宽） */
@media (max-width: 991px) {
  .container { max-width: 100% !important; }
}

/* ---------- 1. 顶部信任栏：移动端换行 + 收缩，杜绝横向溢出 ---------- */
@media (max-width: 991px) {
  .trust-topbar { font-size: 11px; line-height: 1.5; padding: 4px 0; }
  .trust-topbar .container { flex-wrap: wrap !important; gap: 1px 10px; padding-left: 10px; padding-right: 10px; }
  .trust-topbar-item { flex: 0 1 auto !important; min-width: 0; font-size: 11px; }
  .trust-topbar-item > span { white-space: normal !important; }
  /* 移动端仅保留首项品牌标识，其余（执业证号/热线等）已由 d-none 控制，双保险隐藏避免拥挤 */
  .trust-topbar-item + .trust-topbar-item { display: none !important; }
}

/* ---------- 2. 主导航：移动端 logo 缩小 + 隐藏内联搜索框（仅保留搜索图标触发） ---------- */
@media (max-width: 991px) {
  .navbar .container { flex-wrap: nowrap !important; align-items: center; }
  .navbar-brand img { height: 40px !important; width: auto; }
  .nav-search-form { display: none !important; }
  .nav-search-toggle { display: inline-flex !important; }
  .navbar-toggler { margin-left: auto; }
}

/* ---------- 3. Hero 横幅：解除 nowrap 裁剪 + 响应式字号 + 收窄内边距 ---------- */
@media (max-width: 768px) {
  .hero-unified, .hero-banner { padding-top: 36px !important; padding-bottom: 36px !important; }
  .hero-unified .container, .hero-banner .container,
  .hero-unified > div[class="container"], .hero-banner > .container {
    padding-left: 14px !important; padding-right: 14px !important;
  }
  .hero-unified h1, .hero-banner h1, .msg-hero-title {
    white-space: normal !important;     /* 关键：解除内联 white-space:nowrap 导致的标题裁切 */
    font-size: 1.4rem !important;
    letter-spacing: 1px !important;
    line-height: 1.45 !important;
    word-break: break-word;
  }
  .msg-hero-sub, .hero-unified p, .hero-banner p {
    font-size: 0.85rem !important;
    line-height: 1.65 !important;
    padding: 0 4px;
  }
}
@media (max-width: 360px) {
  .hero-unified h1, .hero-banner h1, .msg-hero-title { font-size: 1.25rem !important; }
}

/* ---------- 4. 表单系统：触控友好 + 网格折叠 + 容器内边距收敛 ---------- */
@media (max-width: 768px) {
  .form-wrapper {
    margin: -18px 12px 36px !important;
    padding: 22px 16px !important;
    border-radius: 14px !important;
  }
  .form-group { margin-bottom: 16px !important; }
  .form-group label { font-size: 13px !important; margin-bottom: 6px !important; }
  .form-control-custom {
    width: 100% !important;
    min-height: 46px !important;       /* 触控目标 ≥44px */
    font-size: 16px !important;        /* 防止 iOS 聚焦自动缩放 */
    padding: 12px 14px !important;
    line-height: 1.4 !important;
  }
  textarea.form-control-custom { min-height: 88px !important; }
  /* 双列网格在手机上堆叠 */
  .row-2 { grid-template-columns: 1fr !important; gap: 0 !important; }
  .row-2 .form-group { margin-bottom: 16px !important; }
  /* 提交 / 新增 按钮：满宽 + 触控高度 */
  .btn-submit { font-size: 15px !important; padding: 14px !important; min-height: 50px; border-radius: 12px !important; }
  .btn-add-policy {
    width: 100% !important; justify-content: center;
    min-height: 44px !important; font-size: 14px !important;
  }
  .privacy-check { padding: 12px 14px !important; gap: 8px; }
  .privacy-check label { font-size: 12.5px !important; }
  .compliance-box { font-size: 11.5px !important; padding: 12px 14px !important; }
  .info-banner { font-size: 12.5px !important; padding: 14px !important; }
  /* 政策卡片内两列也堆叠 */
  .policy-card .row-2 { grid-template-columns: 1fr !important; }
  .policy-card .remove-btn { font-size: 12px !important; padding: 3px 10px !important; }
}

/* 成功 / 通用居中弹窗：移动端收敛，避免超出屏幕 */
@media (max-width: 768px) {
  .success-mask { padding: 16px; }
  .success-card { width: 100% !important; max-width: 92% !important; padding: 34px 20px !important; border-radius: 16px !important; }
  .success-card i { font-size: 48px !important; }
  .success-card h3 { font-size: 1.15rem !important; }
  .success-card p { font-size: 13px !important; }
}

/* ---------- 5. 悬浮主题切换按钮：移动端隐藏（抽屉菜单内已有切换入口，避免遮挡表单） ---------- */
@media (max-width: 767px) {
  .theme-toggle-float { display: none !important; }
}

/* ---------- 6. 固定底部移动导航：安全区 + 防止遮挡正文 ---------- */
@media (max-width: 575px) {
  body { padding-bottom: 60px !important; }   /* 让出底部固定栏高度 */
  .fixed-bottom-mobile {
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.18) !important;
    z-index: 1040 !important;
  }
  .fixed-bottom-mobile a { font-size: 12px !important; padding: 8px 2px !important; }
  .fixed-bottom-mobile a i { font-size: 18px !important; }
}

/* ---------- 7. 表格：长表横向滚动，不撑破布局 ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { max-width: 100%; }
@media (max-width: 768px) {
  table { font-size: 12.5px !important; }
  th, td { padding: 8px 10px !important; white-space: normal !important; }
}

/* ---------- 8. 工具页通用：工具栏 / 筛选行 换行 + 子项收缩 ---------- */
@media (max-width: 768px) {
  .toolbar, .filter-row { flex-wrap: wrap !important; gap: 8px !important; }
  .toolbar > *, .filter-row > * { flex: 1 1 140px !important; min-width: 0 !important; }
  .toolbar input[type="text"], .filter-row select { width: 100% !important; min-width: 0 !important; }
  /* KPI / 图表 / 分析网格折叠为单列或双列 */
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
  .charts-row, .analysis-section, .main-grid { grid-template-columns: 1fr !important; }
  .kpi-row .kpi-card, .charts-row > *, .analysis-section > * { min-width: 0 !important; }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
}
