/* ==========================================================================
   纯 HTML 版 —— 独立布局修正层
   --------------------------------------------------------------------------
   为什么要这一层：
   原 React 版的 .page-shell 由框架 flex 驱动，转成静态 HTML 后
   sidebar / content 的排布需要显式声明；同时 .page-shell 早期规则
   有 min-width:1180px，在小屏会造成横向溢出。
   ========================================================================== */

/* ---- 1. 基础：侧栏 + 内容两栏布局 ---- */
.page-shell {
  display: flex !important;
  min-width: 0 !important;
  align-items: flex-start;
  background: transparent;
}

.dashboard-content {
  flex: 1 1 auto;
  min-width: 0;            /* 关键：允许子元素收缩，防溢出 */
  display: flex;
  flex-direction: column;
}

/* 当前版本用顶部导航，侧栏不显示 */
.dashboard-sidebar {
  display: none !important;
}

/* ---- 2. 顶部导航：还原原版「固定悬浮壳」行为 ----
   原版结构：.floating-shell 固定贴顶且自身透明（pointer-events:none），
   内部 topbar（白底毛玻璃）与 filter-bar（独立白卡）各自接收事件。
   下滑 → topbar 高度收拢并上移淡出，只留筛选卡贴顶；
   上滑 → topbar 召回。壳本身始终 fixed，因此筛选卡不会跳动。
   ---------------------------------------------------------------- */
.page-shell .floating-shell,
div.floating-shell {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 100 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: none;
  flex: 0 0 auto;
}

.page-shell .floating-shell .topbar,
.page-shell .floating-shell .filter-bar {
  pointer-events: auto;
}

.page-shell .floating-shell .topbar,
div.floating-shell .topbar {
  position: relative !important;
  top: auto !important;
  max-height: 72px !important;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
  background: rgba(255, 255, 255, .90) !important;
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid #ebebeb !important;
  transition: max-height .24s ease, opacity .18s ease, transform .24s ease, border-color .24s ease;
}

/* 导航收起态：与原版一致，高度收拢 + 上移淡出 */
.page-shell.nav-hidden .floating-shell .topbar,
div.page-shell.nav-hidden .floating-shell .topbar {
  max-height: 0 !important;
  min-height: 0 !important;
  height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0 !important;
  transform: translateY(-72px) !important;
  overflow: hidden !important;
  border-bottom-color: transparent !important;
  pointer-events: none;
}

/* 收起态彻底隐藏导航行：去掉边框残留的 1px，避免顶部出现细线 */
.page-shell.nav-hidden .floating-shell .topbar,
div.page-shell.nav-hidden .floating-shell .topbar {
  border-width: 0 !important;
}

/* 收起后筛选卡贴顶，仅保留下方圆角，阴影加深 */
.page-shell.nav-hidden .floating-shell .filter-bar {
  margin-top: 10px !important;
  box-shadow: 0 8px 22px rgba(26, 32, 44, .10) !important;
}

/* 原版为固定壳预留的首屏空间。
   --shell-offset 由 app.js 实测壳高度写入，避免不同断点下写死数值造成遮挡或空档。 */
.page-shell .dashboard-content main,
.dashboard-content main {
  padding-top: var(--shell-offset, 184px) !important;
}

/* ---- 3. 顶部导航内部排版 ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
  padding: 0 40px;
  box-sizing: border-box;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.topbar nav button,
.topbar nav a {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  color: #646464;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s, background .2s;
}

.topbar nav button:hover,
.topbar nav a:hover {
  color: #28b894;
  background: rgba(40, 184, 148, .08);
}

.topbar nav button.active {
  color: #007a60;
  background: #f2fcfa;
  box-shadow: inset 0 0 0 1px rgba(40, 184, 148, .22);
  font-weight: 600;
}

/* 跨页入口用品牌色做「可点击」提示，但不加底色，避免与选中态混淆 */
.nav-index-link,
.nav-back-link {
  color: #007a60 !important;
  font-weight: 600;
}

.topbar nav a.nav-cross-link {
  background: transparent !important;
  box-shadow: none !important;
}

.topbar nav a.nav-cross-link:hover {
  background: rgba(40, 184, 148, .08) !important;
}

/* 真正的当前页入口才给胶囊底色 */
.topbar nav a.active {
  color: #007a60 !important;
  background: #f2fcfa !important;
  box-shadow: inset 0 0 0 1px rgba(40, 184, 148, .22) !important;
  font-weight: 600;
}

.topbar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #646464;
  font-size: 13px;
  white-space: nowrap;
}

.topbar-context b {
  color: #bfbfbf;
  font-weight: 400;
}

.topbar-context strong {
  color: #1a1a1a;
  font-weight: 600;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #28b894, #00c29a);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.mobile-menu-toggle {
  display: none;
}

/* 筛选条：靠右居中，与内容同宽 */
.floating-shell .filter-bar {
  box-sizing: border-box;
  width: min(1480px, calc(100% - 80px));
  margin: 10px auto 12px;
}

/* ---- 4. 主内容版心 ---- */
.dashboard-content main {
  box-sizing: border-box;
  width: min(1480px, calc(100% - 80px));
  margin-inline: auto;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
  flex: 1 1 auto;
}

.dashboard-content footer {
  box-sizing: border-box;
  width: min(1480px, calc(100% - 80px));
  margin: 46px auto 0;
}

/* 防止任何子元素撑破容器 */
.dashboard-content main * {
  max-width: 100%;
}

/* 表格类允许内部横向滚动，不撑破页面 */
.detail-table,
.semantic-table,
.source-question-list {
  overflow-x: auto;
}

/* ==========================================================================
   5. 平板 / 中屏（700–1100）：筛选栏横向滚动，避免文字被压成竖排
   ========================================================================== */
@media (max-width: 1100px) {
  .topbar {
    padding: 0 24px;
    gap: 14px;
  }

  .topbar-context {
    display: none;
  }

  .topbar nav button,
  .topbar nav a {
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .floating-shell .filter-bar,
  .dashboard-content main,
  .dashboard-content footer {
    width: calc(100% - 48px);
  }

  /* 筛选项禁换行，整体横向滚动 */
  .floating-shell .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 12px;
  }

  .floating-shell .filter-bar > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .floating-shell .filter-bar::-webkit-scrollbar {
    display: none;
  }

  /* 筛选栏内部文字不竖排 */
  .floating-shell .filter-bar label,
  .floating-shell .filter-bar .filter-title,
  .floating-shell .filter-bar span,
  .floating-shell .filter-bar small {
    white-space: nowrap;
    word-break: keep-all;
  }
}

/* ==========================================================================
   6. 手机
   ========================================================================== */
@media (max-width: 700px) {
  .topbar {
    height: 58px;
    padding: 0 14px;
    gap: 10px;
  }

  .topbar .brand {
    font-size: 20px;
    flex: 0 0 auto;
  }

  /* 移动端：导航文字平铺横滑，不折叠为汉堡（原版行为） */
  .mobile-menu-toggle {
    display: none !important;
  }

  .topbar nav,
  .topbar nav.mobile-open {
    position: static;
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    scrollbar-width: none;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .topbar nav::-webkit-scrollbar {
    display: none;
  }

  .topbar nav button,
  .topbar nav a {
    flex: 0 0 auto;
    text-align: center;
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .topbar-actions {
    display: none;
  }

  .floating-shell .filter-bar {
    width: calc(100% - 28px);
    margin: 8px auto 10px;
    padding: 9px 10px;
    border-radius: 10px;
    /* 单行横向滚动，不换行堆高 */
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .floating-shell .filter-bar > * {
    flex: 0 0 auto;
  }

  .floating-shell .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .dashboard-content main,
  .dashboard-content footer {
    width: calc(100% - 28px);
  }

  /* 首屏 Hero 缩小内边距 */
  .report-hero {
    padding: 22px 16px !important;
  }

  .report-hero h1 {
    font-size: 26px !important;
    line-height: 1.28 !important;
  }

  /* 高亮三连：手机上纵向堆叠，避免挤压 */
  .overview-highlight-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .overview-highlight-row > span {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .overview-highlight-row > span strong {
    font-size: 12px;
  }

  /* AI 指数页 */
  .ai-index-result-grid,
  .ai-index-lower {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }

  .ai-query-control {
    margin-top: 12px;
  }

  .heat-ball {
    width: 120px !important;
    height: 120px !important;
    font-size: 32px !important;
  }

  .platform-heat-row {
    grid-template-columns: 62px 1fr 78px !important;
    gap: 10px !important;
  }

  /* 页脚 */
  .dashboard-content footer {
    margin-top: 32px;
    padding: 26px 16px !important;
  }
}

/* ==========================================================================
   7. 触摸设备去掉悬停位移
   ========================================================================== */
@media (hover: none), (pointer: coarse) {
  .panel:hover,
  .volume-card:hover,
  .trend-card:hover,
  .rep-card:hover,
  .product-overview-item:hover,
  .word-section-panel:hover,
  .industry-word-cloud button:hover,
  .word-list-row:hover,
  .media-source-row:hover,
  .board-row:hover,
  .question-item:hover {
    transform: none !important;
  }
}

/* ==========================================================================
   8. 效果详情：TOP10 相关项已移除后的列数重排
   ========================================================================== */
/* 指标卡由 4 张变 3 张 */
.volume-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

@media (max-width: 900px) {
  .volume-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .volume-grid {
    grid-template-columns: 1fr !important;
  }
}

.detail-table .table-head.volume-table,
.detail-table .table-row.volume-table {
  grid-template-columns: .95fr 1.05fr 1.9fr .85fr .85fr .95fr 104px !important;
}

/* 问题词列允许换行，避免长问句撑破 */
.detail-table .table-row.volume-table > span:nth-child(3),
.detail-table .table-row.reputation-table > span:nth-child(2) {
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
}

/* 「查看」现在是链接，保持与原按钮完全一致的观感 */
a.dialog-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

/* 打印时不要给固定壳留白 */
@media print {
  .page-shell .dashboard-content main,
  .dashboard-content main {
    padding-top: 12px !important;
  }
  .floating-shell {
    display: none !important;
  }
}