/* print.css - 处方笺打印专用样式 */
/* 处方开具页面的三栏布局样式（屏幕显示） */
.rx-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px minmax(230px, 0.34fr);
  height: calc(100vh - 92px);
}
.rx-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.rx-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.rx-divider {
  cursor: col-resize;
  align-self: stretch;
  border-radius: 4px;
  background: transparent;
  position: relative;
}
.rx-divider:hover { background: var(--primary-light); }
.rx-divider::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}

/* ============ 三栏布局·窄窗口自适应（修复：中间区底部横向滑块、右侧信息列被挤出/隐藏） ============
   原则：中间工作区自适应填满剩余宽度且不产生左右横向滚动；表格在中间区内换行/压缩显示全部信息；
   右侧信息列固定宽度（可拖）并始终可见。 */
.rx-layout { min-width: 0; max-width: 100%; }
.rx-layout > * { min-width: 0; }
.rx-main { min-width: 0; overflow-x: hidden; }
.rx-right { min-width: 0; }
/* 诊疗单据标签条：单行不换行；放不下由 fitExamDocTabs 缩小字号，overflow hidden 仅作防溢出兜底 */
#exam-doc-tabs { flex-wrap: nowrap; }
#exam-doc-tabs .pet-tab { overflow: hidden; }

/* 处方开具页各区块 */
.rx-section { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.rx-section-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text); }

/* 前记信息网格 */
.rx-preamble { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px; }
.rx-field { display: flex; flex-direction: column; }
.rx-field .lbl { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }

/* 药品条目卡片 */
.rx-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafbfd;
}
.rx-item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rx-item-name { font-weight: 600; font-size: 14px; }
.rx-item-spec { font-size: 12px; color: var(--text-secondary); }
.rx-item-body { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-secondary); }
.rx-item-body .kv b { color: var(--text); font-weight: 500; }

/* 动物信息卡片（简化显示） */
.rx-animal-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfd;
}
.rx-animal-info { flex: 1; }
.rx-animal-name { font-size: 16px; font-weight: 700; }
.rx-animal-meta { font-size: 13px; color: var(--text-secondary); }
.rx-animal-owner { text-align: center; min-width: 90px; }
.rx-animal-date { min-width: 140px; }
.rx-animal-label { font-size: 12px; color: var(--text-muted); }
.rx-animal-value { font-size: 14px; font-weight: 500; }

/* 处方工作区：动物信息一行 */
.rx-animal-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 12px;
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.al-item { display: flex; align-items: baseline; gap: 4px; font-size: 13px; }
.al-item .al-label { font-size: 12px; color: var(--text-muted); }
.al-item b { color: var(--text); }
.rx-diag-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.rx-diag-row .al-label { font-size: 13px; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }

/* 检查页右侧诊断结论区（窄面板下 label 在上、输入在下） */
.rx-right .rx-diag-row { flex-direction: column; align-items: stretch; gap: 4px; }
.rx-right .rx-diag-row .al-label { margin-bottom: 2px; }

/* 处方药品明细表 */
.rx-item-table { font-size: 13px; }
.rx-item-table input { text-align: center; }
.rx-item-table .exam-inline-name { text-align: left; }
.rx-item-table .exam-inline-price { width: 64px; }

/* 药品选择表格（紧凑模式，一屏尽量多显示） */
.drug-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.drug-picker-table { font-size: 12px; line-height: 1.3; }
.drug-picker-table th,
.drug-picker-table td { padding: 3px 8px; white-space: nowrap; }
.drug-picker-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  font-size: 11px;
  padding: 4px 8px;
}
.drug-picker-row { cursor: pointer; }
.drug-picker-row:hover td { background: var(--primary-light); }
.drug-picker-row.selected td { background: #e0ecff; }
.drug-picker-table .btn { padding: 1px 8px; font-size: 12px; line-height: 1.4; }

/* 段落式药品详情 */
.drug-detail-card { font-size: 13px; line-height: 1.7; }
.dd-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.dd-para { margin-bottom: 6px; }
.dd-para-label {
  display: inline-block;
  min-width: 64px;
  color: var(--text-muted);
  font-weight: 600;
}
.dd-para-label::after { content: '：'; }

/* 就诊宠物表格 */
.pet-table { font-size: 13px; }
.pet-table th { white-space: nowrap; }
.pet-row { cursor: pointer; }
.pet-row:hover td { background: var(--primary-light); }
.pet-row.current td { background: #e0ecff; }
.pet-row.current td:first-child { border-left: 3px solid var(--primary); }

/* 首页记录表格（紧凑，对齐待诊/住院列表风格） */
.home-record-table { font-size: 12px; }
.home-record-table th,
.home-record-table td { padding: 5px 8px; white-space: nowrap; }
.home-record-table .btn { padding: 2px 8px; font-size: 12px; line-height: 1.5; }
.home-record-row:hover td { background: var(--primary-light); }

/* 药品/耗材库表格（紧凑） */
.lib-table { font-size: 12px; }
.lib-table th,
.lib-table td { padding: 4px 6px; white-space: nowrap; }
.lib-table .btn { padding: 1px 8px; font-size: 12px; line-height: 1.5; }
.lib-row { cursor: pointer; }
.lib-row:hover td { background: var(--primary-light); }
.lib-row.selected td { background: #e0ecff; }
.lib-row.selected td:first-child { border-left: 3px solid var(--primary); }
.lib-row.lib-low-stock td { background: #fff0f0; }
.lib-row.lib-low-stock:hover td { background: #ffe4e4; }
.lib-row.lib-low-stock.selected td { background: #ffe4e4; }
.lib-restock-cell,
.lib-manual-cell,
.lib-stock-cell { cursor: pointer; color: var(--primary); }
.lib-restock-cell:hover,
.lib-manual-cell:hover,
.lib-stock-cell:hover { text-decoration: underline; }

/* 供货商月度透视表（两行表头 + 前4列固定 + 月份色块） */
.sup-table { font-size: 12px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.sup-table th,
.sup-table td { padding: 3px 6px; white-space: nowrap; border-bottom: 1px solid var(--border); border-right: 1px solid #f0f0f0; overflow: hidden; }
.sup-table th { position: relative; }
.sup-table thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; }
.sup-table .sup-fixed { position: sticky; z-index: 2; background: #fff; border-right: 2px solid var(--border); }
.sup-table thead .sup-fixed { background: #f8fafc; z-index: 4; }
/* 固定列左右偏移由 JS 按列宽联动设置（.sup-col-N 仅作选择器标记） */
.sup-table .col-resizer { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; z-index: 6; }
.sup-table .col-resizer:hover { background: rgba(59,130,246,0.4); }
.sup-table .sup-edit-cell { cursor: text; }
.sup-table .sup-edit-cell:hover { background: #fff7e6; }
.sup-table tbody .sup-edit-cell:focus-within { background: #fffbe6; }
#sup-table-wrap { overflow: auto; max-height: calc(100vh - 300px); }
.sup-row { cursor: pointer; }
.sup-row:hover td { background: #f8fafc; }
.sup-row:hover .sup-fixed { background: #f8fafc; }
.sup-row.selected td { background: #e0ecff; }
.sup-row.selected .sup-fixed { background: #e0ecff; }
.sup-table input { padding: 1px 4px; font-size: 12px; }
.sup-btn { flex: 0 0 auto; }
/* 12 色月份底色 */
.sup-month-0 { background: #fde8e8; }
.sup-month-1 { background: #fdeee3; }
.sup-month-2 { background: #fdf6e0; }
.sup-month-3 { background: #eff9e3; }
.sup-month-4 { background: #e5f7ee; }
.sup-month-5 { background: #e0f4f7; }
.sup-month-6 { background: #e3eefc; }
.sup-month-7 { background: #eae8fb; }
.sup-month-8 { background: #f5e8f8; }
.sup-month-9 { background: #fbe7f0; }
.sup-month-10 { background: #f0f0f0; }
.sup-month-11 { background: #f7f4e8; }

/* 待诊/住院 Tab 切换（Edge 风格：整条标签条 + 激活页签顶部大圆角、下缘齐平） */
.pet-tabs,
#im-tabs,
#im-pet-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  background: #e7ecf4;                 /* 标签条底色 */
  border-radius: 12px 12px 0 0;        /* 整条标签条顶部圆角 */
  align-items: flex-end;
  margin-bottom: 0;
}
/* 5 页签（药品/耗材：药品库/本院药品目录/本院耗材目录/耗材库/药品库存）：
   ★ 2026-09-23（用户反馈「有的标签文字都没显示完全」）：不再用省略号裁切——
   按钮按内容自适应宽度（flex:0 0 auto），整条标签条不被压缩；一行放不下时整条/各按钮换行显示全文。 */
.pet-tabs.tabs5 { font-size: 12.5px; flex: 1 1 100%; flex-wrap: wrap; }
.pet-tabs.tabs5 .pet-tab {
  flex: 0 0 auto;
  overflow: visible;
  text-overflow: clip;
  padding: 6px 10px 8px;
  letter-spacing: 0;
  white-space: nowrap;
}
.pet-tab {
  flex: 1;
  position: relative;
  padding: 7px 12px 9px;
  border: none;
  background: rgba(255, 255, 255, 0.55);   /* 与标签条底纹略有区分（微弱底纹） */
  border-radius: 10px 10px 0 0;        /* 顶部大圆角，下缘齐平 */
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.pet-tab:hover { background: rgba(255, 255, 255, 0.85); color: var(--text); }
.pet-tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  z-index: 1;
}

/* 宠物列表 */
.pet-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.pet-list-item:hover { border-color: var(--primary); }
.pet-list-item.selected { border-color: var(--primary); background: var(--primary-light); }
.pet-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.pet-info { flex: 1; min-width: 0; }
.pet-name { font-weight: 600; font-size: 14px; }
.pet-sub { font-size: 12px; color: var(--text-muted); }

/* 药品详情 */
.drug-detail .dd-cat { margin-bottom: 12px; }
.drug-detail .dd-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin: 10px 0 4px; text-transform: uppercase; }
.drug-detail .dd-text { font-size: 13px; color: var(--text); }
.dosage-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dosage-table th, .dosage-table td { border: 1px solid var(--border); padding: 5px 7px; text-align: left; }
.dosage-table th { background: #f8fafc; color: var(--text-secondary); }

/* ============ 中间区表格自适应（置于文件末尾覆盖上方表格 nowrap 规则） ============
   目标：表格铺满中间工作区、内容允许换行；页面/中间区不出现横向滑块，右栏始终可见；
   超宽的工作区项目表仅在自身容器内兜底滚动（#exam-items），不撑开页面或隐藏右栏 */
.rx-item-table, .drug-picker-table { width: 100%; }
.rx-item-table th, .rx-item-table td,
.drug-picker-table th, .drug-picker-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}
.drug-picker-table th, .drug-picker-table td { padding: 3px 6px; }
.rx-item-table th, .rx-item-table td { min-width: 0 !important; padding: 3px 5px; }
.rx-item-table .exam-inline-name { min-width: 0; max-width: none; width: 100%; }
.rx-item-table input, .rx-item-table select { max-width: 100%; }
.rx-item-table select { width: 108px; min-width: 0; }
#exam-items { max-width: 100%; overflow-x: auto; }

/* ============ 全局后台任务顶部进度条（门户同步/批量刷新等待提示，固定顶部不遮内容） ============ */
#app-busy-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: none;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.12);
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary, #475569);
  align-items: center;
  gap: 8px;
}
#app-busy-bar.show { display: flex; }
#app-busy-bar .ab-bar {
  flex: 1; height: 3px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.15);
  overflow: hidden;
  position: relative;
}
#app-busy-bar .ab-bar i {
  position: absolute; top: 0; left: 0; height: 100%;
  width: 40%;
  border-radius: 3px;
  background: var(--primary, #4f46e5);
  animation: ab-slide 1.1s ease-in-out infinite;
}
@keyframes ab-slide {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* ============ 打印样式 ============ */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    display: block !important;
  }

  /* ===== 长文档流式打印（body.print-flow：费用明细 / 病历 / 护理记录 等会翻多页的文书）=====
     打印区回到正常流，其余兄弟节点 display:none；这样**每一页**都听 @page 的页边距，
     上一页末尾与下一页顶部都会留出空白（绝对定位时只有第一页按页边距定位，后续页贴边被切）。 */
  body.print-flow #print-area {
    position: static !important;
    left: auto;
    top: auto;
    width: auto;
  }
  body.print-flow > *:not(#print-area) { display: none !important; }
  body.print-flow .rx-print { padding: 0; }
  /* 行/小节不跨页拆开；表头每页重复 */
  body.print-flow tr { page-break-inside: avoid; break-inside: avoid; }
  body.print-flow thead { display: table-header-group; }
  body.print-flow tfoot { display: table-footer-group; }
  body.print-flow .mr-detail-box { max-height: none !important; overflow: visible !important; }
  body.print-flow img { max-width: 100%; }

  @page {
    size: 210mm 148mm landscape;
    margin: 8mm;
  }

  .rx-print {
    font-family: "SimSun", "宋体", serif;
    font-size: 10pt;
    line-height: 1.6;
    color: #000;
    padding: 4mm;
  }
  /* PDF 底图模板：整页铺满，不留内边距，分页与 PDF 原稿一致 */
  .rx-print.pdf-print { padding: 0; }  .rx-print.pdf-print .pdf-page { page-break-after: always; break-after: page; margin: 0; box-shadow: none; }
  .rx-print.pdf-print .pdf-page:last-child { page-break-after: auto; break-after: auto; }
  .rx-print.pdf-print .pdf-page > img { width: 100%; height: 100%; }
  .rx-print.pdf-print .pdf-fld {
    position: absolute; background: #fff; overflow: hidden; white-space: nowrap;
    display: flex; align-items: flex-end; line-height: 1.1; color: #000;
    font-family: "SimSun", "宋体", serif; padding: 0 1px; box-sizing: border-box;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  /* 预设签字 / 医院盖章：透明底图片按 mm 等比打印，别被浏览器省墨模式吃掉颜色 */
  .rx-print.pdf-print .pdf-fld-img { padding: 0; background: transparent; align-items: center; justify-content: center; }
  .doc-sign-img {
    display: inline-block; vertical-align: middle; height: auto; max-width: 100%;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .rx-print .header {
    text-align: center;
    font-size: 16pt;
    font-weight: bold;
    border-bottom: 2px solid #000;
    padding-bottom: 3mm;
    margin-bottom: 3mm;
    letter-spacing: 4px;
  }
  .rx-print .sub-header {
    text-align: center;
    font-size: 9pt;
    margin-bottom: 3mm;
  }
  .rx-print .preamble {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1mm 6mm;
    font-size: 9pt;
    margin-bottom: 3mm;
  }
  .rx-print .preamble span { white-space: nowrap; }
  .rx-print .diagnosis {
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 2mm 0;
    margin: 2mm 0;
    font-size: 10pt;
  }
  .rx-print .rp-title { font-weight: bold; margin-bottom: 1mm; }
  .rx-print .rp-items { min-height: 70mm; }
  .rx-print .rp-items .item {
    padding: 1mm 0;
    font-size: 9.5pt;
  }
  .rx-print .item-line1 { font-weight: bold; }
  .rx-print .item-line2 { font-size: 8.5pt; }
  .rx-print .blank-mark {
    text-align: center;
    border-top: 1px dashed #000;
    padding-top: 2mm;
    margin-top: 3mm;
    font-size: 9pt;
  }
  .rx-print .postscript {
    display: flex;
    justify-content: space-between;
    margin-top: 5mm;
    font-size: 10pt;
  }
  .rx-print .rx-print-price {
    display: flex;
    justify-content: flex-end;
    gap: 8mm;
    margin-top: 2mm;
    font-size: 10pt;
    border-top: 1px solid #000;
    padding-top: 2mm;
  }

  /* 排班表打印样式 */
  .schedule-print {
    font-family: "SimSun", "宋体", serif;
    color: #000;
  }
  .schedule-print .sp-header {
    text-align: center;
    font-size: 16pt;
    font-weight: bold;
    margin-bottom: 4mm;
    letter-spacing: 2px;
  }
  .schedule-print .sp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }
  .schedule-print .sp-table th,
  .schedule-print .sp-table td {
    border: 1px solid #000;
    padding: 1.5mm 2mm;
    text-align: center;
    white-space: nowrap;
  }
  .schedule-print .sp-table th { background: #f0f0f0; }
  .schedule-print .sp-footer { text-align: center; margin-top: 3mm; font-size: 9pt; }

  /* 检查处置单打印样式 */
  .exam-print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    margin-top: 3mm;
  }
  .exam-print-table th,
  .exam-print-table td {
    border: 1px solid #000;
    padding: 2mm 2mm;
    text-align: center;
  }
  .exam-print-table th { background: #f0f0f0; }
  .exam-print-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 4mm;
    font-size: 10pt;
    border-top: 1px solid #000;
    padding-top: 2mm;
  }
  .exam-print-diag { margin-top: 4mm; font-size: 10pt; }
  .exam-print-diag-detail { margin-top: 2mm; font-size: 10pt; min-height: 20mm; border-bottom: 1px dashed #000; }
}

/* 检查页费用面板（屏幕显示） */
.exam-price-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.exam-price-row:last-child { border-bottom: none; }
.exam-price-row .ep-label { color: var(--text-secondary); }

/* 检查单底部费用汇总行（一行显示） */
.exam-cost-bar {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  padding: 8px 12px;
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.exam-cost-bar b { color: var(--text); font-weight: 600; }

/* ===== 客户风险等级（高危红 / 异常天蓝 / 普通备注）===== */
.risk-row-high { background: #ffecec !important; }
.risk-row-high td, .risk-row-high td b, .risk-row-high td span { color: #c62828 !important; }
.risk-row-abn { background: #e8f6fe !important; }
.risk-row-abn td, .risk-row-abn td b, .risk-row-abn td span { color: #0e7cbd !important; }
.risk-badge {
  display: inline-block; margin-left: 5px; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 700; line-height: 1.6; vertical-align: middle; white-space: nowrap;
}
.risk-badge-high { background: #c62828; color: #fff; }
.risk-badge-abn { background: #0ea5e9; color: #fff; }
.risk-badge-note { background: #e2e8f0; color: #475569; font-weight: 600; }
/* 寄养(住院)笼位：占用动物高危红框 / 异常蓝框 */
.cage-cell.risk-cell-high { border-color: #c62828 !important; box-shadow: 0 0 0 1px #c62828 inset; }
.cage-cell.risk-cell-abn { border-color: #0ea5e9 !important; box-shadow: 0 0 0 1px #0ea5e9 inset; }

/* ===== Word(.docx)/网页 结构化模板：打印按原文档纸张/页边距输出（表格/字号/对齐/图片保留） ===== */
@media print {
  .rx-print .word-page { box-shadow: none; margin: 0; background: #fff; box-sizing: border-box; }
  .rx-print .word-doc { font-family: "SimSun", "宋体", serif; line-height: 1.5; color: #000; }
  .rx-print .word-doc p.w-p { margin: 0 0 2px 0; }
  .rx-print .word-doc p.w-h { font-weight: bold; }
  .rx-print .word-doc p.w-h1 { font-size: 1.25em; text-align: center; margin: 6px 0; }
  .rx-print .word-doc p.w-h2 { font-size: 1.12em; margin: 5px 0; }
  .rx-print .word-doc p.w-h3 { font-size: 1.06em; margin: 4px 0; }
  .rx-print .word-doc table.w-tbl { border-collapse: collapse; margin: 3px 0; max-width: 100%; }
  .rx-print .word-doc table.w-tbl td { padding: 2px 4px; vertical-align: top; }
  .rx-print .word-doc table.w-bordered td { border: 1px solid #000; }
  .rx-print .word-doc table.w-plain td { border: none; }
  .rx-print .word-doc img { max-width: 100%; height: auto; }
  .rx-print .word-doc .w-tab { display: inline-block; min-width: 2em; }
}