/* ===========================================================
   PC 端第三批补丁（desktop.z03）
   全部规则限定在 @media (min-width:900px)，移动端零影响。
   依赖 js/pc.z01.js 打的三个标：.page-foot / .ins-grid / .jc-detail
   =========================================================== */

@media (min-width: 900px) {

  /* ---------------------------------------------------------
     A. 短页面：把页脚压到视口底部
     原来内容不足一屏时（二级菜单页、短指南、短药品），
     页脚紧贴内容下方，下面留出半屏空白，看着像页面断了。
     --------------------------------------------------------- */
  #view {
    display: flex;
    flex-direction: column;
  }

  #view > * {
    /* 只关掉收缩：flex item 默认 flex-shrink:1，长内容会被压扁。
       不要写成 flex:0 0 auto —— 那会连带清掉 flex-grow，
       AI 助手那类靠 flex:1 撑满的聊天区会塌成固定高度。 */
    flex-shrink: 0;
  }

  /* 页脚容器自带 style="margin-top:22px" 内联样式，普通规则压不住，必须 !important。
     原 22px 间距改用 padding-top 保留。 */
  #view > div.page-foot {
    margin-top: auto !important;
    padding-top: 34px;
  }

  /* ---------------------------------------------------------
     A2. 列表两列：阈值从 1400 下调到 1200
     1366 是笔记本最常见宽度，原来要 1400 才分两列，
     药品 500 条、医疗文书 310 条在这个宽度下仍是单列长龙，
     每项 1266px 宽却只写两行字。
     --------------------------------------------------------- */
  @media (min-width: 1200px) {
    .list {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px 14px;
      align-items: stretch;
    }
  }

  /* 列表里的「加载更多」/ 空态 / 提示条不是条目，要横跨整行。
     药品 2183 条 → 500 条一批，按钮原本只占左边一列 626px，
     像个浅蓝空输入框，很容易被当成「列表到头了」。 */
  .list > .btn-more,
  .list > .empty,
  .list > .yb-note {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .list > .btn-more {
    margin: 4px 0 2px;
    padding: 14px;
    font-weight: 500;
    letter-spacing: .3px;
    transition: background .12s ease, border-color .12s ease;
  }

  .list > .btn-more:hover {
    background: #dcecfb;
    border-color: #8dbdea;
  }

  html[data-theme="dark"] .list > .btn-more:hover {
    background: #1d3348;
    border-color: #2f5372;
  }

  /* ---------------------------------------------------------
     A3. 医保目录搜索框吸顶
     4856 条目录滚到第 50 条想换个药名搜，搜索框早就滚没了。
     --------------------------------------------------------- */
  #view > .search-box {
    position: sticky;
    /* 上移 22px = #view 的 padding-top，让吸顶时把上方那条 padding 也盖住，
       否则滚动内容会从缝里透出来 */
    top: -22px;
    z-index: 6;
    /* 必须不透明：半透明会把下方卡片透出来，看着脏。
       色值取自 #app 实际背景 rgb(238,242,246) */
    background: #eef2f6;
    padding: 8px 0 10px;
  }

  html[data-theme="dark"] #view > .search-box {
    background: #0b1017;
  }

  /* ---------------------------------------------------------
     B. 国家医保目录：单列 → 两列
     一行只有「甲乙 + 药名 + 剂型 + 分类码」，单列 1126px 时
     右侧空出 900 多 px，一屏只看 9 条。两列后一屏 18 条。
     --------------------------------------------------------- */
  .list.ins-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    align-items: stretch;
  }

  .list.ins-grid > .ins-empty {
    grid-column: 1 / -1;
  }

  .list.ins-grid > .ins-row {
    min-width: 0;
    transition: background .12s ease, box-shadow .12s ease;
  }

  .list.ins-grid > .ins-row:hover {
    background: #f7fafd;
    box-shadow: 0 2px 10px rgba(15, 45, 75, .07);
  }

  .list.ins-grid .ins-name,
  .list.ins-grid .ins-sub,
  .list.ins-grid .ins-cat {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 超宽屏三列 */
  @media (min-width: 1500px) {
    .list.ins-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  /* ---------------------------------------------------------
     C. 集采药品详情：裸结构 → 卡片 + 两栏
     这页没有 .detail-card 包裹，#view 直接是 h2 / .kv，
     因此 z01 里 `.detail-card .kv` 的两栏规则完全没吃到，
     结果是 13px 灰色标签压一行、14px 值另起一行，字小且散。
     --------------------------------------------------------- */
  .jc-detail > h2,
  .jc-detail > .lead,
  .jc-detail > .kv,
  .jc-detail > .sec-title,
  .jc-detail > .note,
  .jc-detail > .btn-primary {
    width: 100%;
    max-width: 940px;
    align-self: center;
    box-sizing: border-box;
  }

  .jc-detail > h2 {
    margin: 0;
    padding: 24px 24px 4px;
    background: #fff;
    border-radius: 14px 14px 0 0;
    font-size: calc(21px * var(--fs, 1));
    line-height: 1.4;
    letter-spacing: .2px;
  }

  .jc-detail > .lead {
    margin: 0;
    padding: 0 24px 16px;
    background: #fff;
    border-bottom: 1px solid #eef2f6;
    font-size: calc(13.5px * var(--fs, 1));
    color: #5a6b7b;
    line-height: 1.6;
  }

  .jc-detail > .sec-title {
    margin: 0;
    padding: 16px 24px 4px;
    background: #fff;
    font-size: calc(13px * var(--fs, 1));
    font-weight: 600;
    color: #79879a;
    letter-spacing: .5px;
  }

  .jc-detail > .kv {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    column-gap: 18px;
    margin: 0;
    padding: 11px 24px;
    background: #fff;
    border-bottom: 1px dashed #e8eef4;
    font-size: calc(15px * var(--fs, 1));
    line-height: 1.7;
  }

  .jc-detail > .kv:last-of-type {
    border-bottom: 0;
  }

  .jc-detail > .kv .k {
    margin: 0;
    font-size: calc(13.5px * var(--fs, 1));
    font-weight: 500;
    color: #7d8b9c;
    line-height: 1.9;
  }

  .jc-detail > .kv .v {
    min-width: 0;
    font-size: calc(15px * var(--fs, 1));
    color: #1f2d3d;
    line-height: 1.7;
    word-break: break-word;
  }

  .jc-detail > .note {
    margin: 0;
    padding: 14px 24px;
    background: #fff;
    border-radius: 0 0 14px 14px;
    font-size: calc(13px * var(--fs, 1));
    line-height: 1.7;
    color: #6b7a8c;
    box-shadow: 0 8px 24px rgba(15, 45, 75, .05);
  }

  .jc-detail > .btn-primary {
    margin: 18px 0 0;
    text-align: center;
    font-size: calc(15px * var(--fs, 1));
  }

  /* 集采详情没有 .note 时，最后一条 .kv 自己收下圆角 */
  .jc-detail > .kv:last-child {
    border-radius: 0 0 14px 14px;
    box-shadow: 0 8px 24px rgba(15, 45, 75, .05);
  }

  /* ---------------------------------------------------------
     D. 顺手：药品详情 132px 标签列容不下「孕乳及哺乳期妇女用药」
     这类 11 字标签，会折成两行。给到 148px 后单行放下。
     --------------------------------------------------------- */
  .detail-card .kv {
    grid-template-columns: 148px minmax(0, 1fr);
  }

  /* ---------------------------------------------------------
     暗色配套
     --------------------------------------------------------- */
  html[data-theme="dark"] .list.ins-grid > .ins-row:hover {
    background: rgba(255, 255, 255, .05);
    box-shadow: none;
  }

  html[data-theme="dark"] .jc-detail > h2,
  html[data-theme="dark"] .jc-detail > .lead,
  html[data-theme="dark"] .jc-detail > .sec-title,
  html[data-theme="dark"] .jc-detail > .kv,
  html[data-theme="dark"] .jc-detail > .note {
    background: #121820;
  }

  html[data-theme="dark"] .jc-detail > h2 {
    color: #e8eef5;
  }

  html[data-theme="dark"] .jc-detail > .lead {
    color: #90a0b3;
    border-bottom-color: rgba(255, 255, 255, .07);
  }

  html[data-theme="dark"] .jc-detail > .sec-title {
    color: #7d8d9f;
  }

  html[data-theme="dark"] .jc-detail > .kv {
    border-bottom-color: rgba(255, 255, 255, .06);
  }

  html[data-theme="dark"] .jc-detail > .kv .k {
    color: #8b9aac;
  }

  html[data-theme="dark"] .jc-detail > .kv .v {
    color: #dbe4ee;
  }

  html[data-theme="dark"] .jc-detail > .note {
    color: #8b9aac;
    box-shadow: none;
  }

  html[data-theme="dark"] .jc-detail > .kv:last-child {
    box-shadow: none;
  }
}
