/* 用药建议工具 - 全局样式（深色蓝调主题） */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(180deg, #0b1220 0%, #0e1a2e 100%);
  min-height: 100vh;
  color: #d7e0ef;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- 头部 ---------- */
.page-header { text-align: center; margin-bottom: 24px; }
.page-header h1 {
  margin: 8px 0 6px;
  font-size: 30px;
  color: #7db4ff;
  letter-spacing: 1px;
  text-shadow: 0 0 24px rgba(59, 130, 246, 0.35);
}
.subtitle { margin: 0; color: #8fa3c0; font-size: 14px; }
.back-link {
  display: inline-block;
  margin-bottom: 10px;
  color: #7db4ff;
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { text-decoration: underline; color: #a5cbff; }
.back-row { display: flex; gap: 18px; justify-content: center; margin-bottom: 4px; }

/* ---------- 搜索区 ---------- */
.search-box {
  display: flex;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto 8px;
  background: #151f33;
  border: 1px solid #2a3a57;
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 4px 18px rgba(2, 8, 20, 0.55);
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0f1829;
  color: #d7e0ef;
}
.search-box input::placeholder { color: #5d6f8c; }
.search-box button {
  border: none;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 15px;
  padding: 10px 22px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease;
}
.search-box button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
}
.hint { text-align: center; color: #6e84a5; font-size: 13px; margin: 0 0 20px; }

/* ---------- 卡片 ---------- */
.card {
  background: #151f33;
  border: 1px solid #24334d;
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 18px rgba(2, 8, 20, 0.5);
}
.card-title {
  font-size: 17px;
  color: #7db4ff;
  margin: 0 0 14px;
  border-left: 4px solid #3b82f6;
  padding-left: 10px;
}
.table-section { margin-top: 24px; }

/* ---------- 基本信息网格 ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0 24px;
  margin: 0;
}
.info-item {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px dashed #24334d;
  align-items: flex-start;
}
.info-item dt {
  flex: 0 0 110px;
  color: #7d8fae;
  font-size: 13px;
  line-height: 1.6;
}
.info-item dd {
  margin: 0;
  flex: 1;
  font-size: 13.5px;
  line-height: 1.7;
  color: #d7e0ef;
  word-break: break-all;
}
.info-item dd.long { white-space: pre-line; }
/* 基本信息卡片：单列展示 */
#infoGrid { grid-template-columns: 1fr; }
/* 数据来源小字 */
.src-note {
  margin-top: 8px;
  font-size: 11.5px;
  color: #5f7395;
}

/* ---------- 表格区域 ---------- */
.badge {
  display: inline-block;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #1c2a45;
  color: #7db4ff;
  font-size: 13px;
  text-align: center;
}
.badge-child {
  background: rgba(52, 199, 89, 0.16);
  color: #4cd07d;
  font-weight: 600;
}
.badge-no {
  background: #1e283d;
  color: #6e84a5;
}
.btn-detail {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-detail:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(59, 130, 246, 0.45);
}
.text-center { text-align: center; }
.btn-modal {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  background: transparent;
  color: #7db4ff;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-modal:hover {
  background: #3b82f6;
  color: #fff;
}

/* ---------- 详情弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 22, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-box {
  width: 100%;
  max-width: 900px;
  max-height: 84vh;
  overflow-y: auto;
  background: #131c30;
  border: 1px solid #24334d;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(2, 8, 20, 0.8);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #24334d;
}
.modal-head h3 {
  margin: 0;
  color: #e8eef8;
  font-size: 15px;
}
.modal-close {
  border: none;
  background: transparent;
  color: #8fa3c0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 16px 20px 20px; }
.modal-body .info-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.link-name {
  color: #7db4ff;
  text-decoration: none;
  font-weight: 500;
}
.link-name:hover { text-decoration: underline; color: #a5cbff; }

/* ---------- DataTables 深色主题 ---------- */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: #8fa3c0; }
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: #0f1829;
  border: 1px solid #2a3a57;
  border-radius: 8px;
  padding: 4px 8px;
  color: #d7e0ef;
  outline: none;
}
.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus { border-color: #3b82f6; }
.dataTables_wrapper .dataTables_info { color: #8fa3c0; font-size: 13px; }
.dataTables_wrapper .dataTables_processing {
  background: #151f33 !important;
  color: #7db4ff !important;
  border: 1px solid #2a3a57;
  box-shadow: 0 4px 18px rgba(2, 8, 20, 0.5);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  border: 1px solid #2a3a57 !important;
  background: #151f33 !important;
  color: #7db4ff !important;
  margin-left: 4px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  border-color: #3b82f6 !important;
  color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #1c2a45 !important;
  border-color: #3b82f6 !important;
  color: #a5cbff !important;
}
table.display thead th {
  background: #182741;
  color: #9cc4ff;
  border-bottom: 2px solid #3b82f6 !important;
  font-weight: 600;
}
table.display tbody tr.odd { background-color: #131c30; }
table.display tbody tr.even { background-color: #151f33; }
table.display tbody tr:hover { background-color: #1a2740 !important; }
table.display td { border-color: #223250 !important; }

/* ==========================================================
   移动端响应式适配（桌面端布局保持不变，仅窄屏增强）
   ========================================================== */

/* ---------- DataTables 横向滚动容器 ---------- */
.dataTables_scrollBody {
  -webkit-overflow-scrolling: touch;   /* iOS 惯性滚动 */
}
.dataTables_scrollBody::-webkit-scrollbar { height: 8px; }
.dataTables_scrollBody::-webkit-scrollbar-track { background: transparent; }
.dataTables_scrollBody::-webkit-scrollbar-thumb { background: #2a3a57; border-radius: 4px; }
.dataTables_scrollBody::-webkit-scrollbar-thumb:hover { background: #3b82f6; }

/* ---------- 平板及以下（≤768px） ---------- */
@media (max-width: 768px) {
  .container { padding: 20px 14px 48px; }
  .page-header h1 { font-size: 24px; }

  .card { padding: 16px 16px; }
  .card-title { font-size: 15.5px; }

  /* 基本信息网格：窄屏强制单列，避免字段被压扁 */
  .info-grid,
  .modal-body .info-grid { grid-template-columns: 1fr; }

  /* 表格横向滑动提示（表格上方自动出现） */
  .table-section .dataTables_wrapper::before {
    content: '↔ 左右滑动表格查看完整字段';
    display: block;
    text-align: center;
    font-size: 12px;
    color: #5f7395;
    padding: 4px 0 10px;
  }

  /* 表格单元格：防止中文逐字折行把行高撑爆 */
  table.display td { white-space: nowrap; }
  /* 首页“适应症摘要”列：超长时省略号截断，避免横向滚动过长 */
  #drugTable td:nth-child(5) {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* DataTables 底部控件排布 */
  .dataTables_wrapper .dataTables_paginate { margin-top: 8px; }
  .dataTables_wrapper .dataTables_filter input { width: 130px; }
}

/* ---------- 手机（≤520px） ---------- */
@media (max-width: 520px) {
  .container { padding: 14px 12px 40px; }
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 21px; letter-spacing: 0.5px; }
  .subtitle { font-size: 13px; line-height: 1.6; }

  /* 搜索区：纵向堆叠，按钮全宽便于拇指点击 */
  .search-box {
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    align-items: stretch;      /* 子元素强制拉伸，防止旧内核 WebView 撑开溢出 */
  }
  .search-box input,
  .search-box button {
    width: 100%;
    max-width: 100%;           /* 兜底：任何情况都不允许超出容器 */
    min-width: 0;              /* 允许 flex 子项收缩，避免 min-width:auto 撑破 */
    flex: 1 0 auto;
    box-sizing: border-box;
  }
  .search-box input {
    font-size: 16px;           /* ≥16px 防止 iOS 聚焦自动放大 */
    padding: 12px 12px;
  }
  .search-box button {
    padding: 13px 16px;
    font-size: 16px;
  }
  .hint { font-size: 12px; line-height: 1.6; margin-bottom: 14px; }

  /* 基本信息：字号与标签宽度微调 */
  .info-item dt { flex-basis: 92px; font-size: 12.5px; }
  .info-item dd { font-size: 13px; }
  .src-note { font-size: 11px; }

  /* 触屏友好的按钮与徽标 */
  .badge { min-width: 30px; padding: 3px 8px; font-size: 12px; }
  .btn-detail { padding: 7px 14px; font-size: 13px; }
  .btn-modal { padding: 6px 12px; font-size: 13px; }
  .back-row { gap: 12px; flex-wrap: wrap; }
  .back-link { padding: 6px 2px; }

  /* DataTables 控件：全部居中、允许换行 */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    display: block;
    float: none;
    text-align: center;
    margin: 0 0 6px;
  }
  .dataTables_wrapper .dataTables_filter input { width: 150px; }
  .dataTables_wrapper .dataTables_info {
    display: block;
    float: none;
    text-align: center;
    font-size: 12px;
    padding-top: 6px;
  }
  .dataTables_wrapper .dataTables_paginate {
    float: none;
    text-align: center;
    margin-top: 4px;
  }
  .dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 9px !important;
    margin: 2px;
    font-size: 12px;
  }
  .dataTables_wrapper .dataTables_processing { font-size: 13px; }

  #drugTable td:nth-child(5) { max-width: 170px; }

  /* 详情弹窗：手机上更接近全屏，从底部展开 */
  .modal-mask { padding: 8px; align-items: flex-end; }
  .modal-box { max-height: 94vh; border-radius: 14px; }
  .modal-head { padding: 12px 14px; }
  .modal-head h3 { font-size: 14px; line-height: 1.4; }
  .modal-body { padding: 12px 14px 18px; }
  .modal-close { font-size: 26px; padding: 0 6px; }
}

/* ---------- 超小屏（≤360px） ---------- */
@media (max-width: 360px) {
  .info-item dt { flex-basis: 82px; }
  .dataTables_wrapper .dataTables_paginate .paginate_button { padding: 4px 7px !important; }
}
