/* ============ AI 病历总结页 — 新中式医疗风 ============ */

/* ---------- 页面头部 ---------- */
.page-records .page-header .subtitle {
  color: var(--text-soft);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- 生成面板 — 暖金渐变卡片 ---------- */
.summary-panel {
  background: linear-gradient(145deg, #fffdf7 0%, #faf6ed 40%, #f5edd8 100%);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 28px 30px;
  margin-bottom: 32px;
  box-shadow:
    0 2px 0 rgba(184, 145, 70, 0.15) inset,
    0 10px 40px rgba(184, 145, 70, 0.12),
    0 2px 8px rgba(26, 77, 74, 0.06);
  position: relative;
  overflow: hidden;
}
/* 装饰性纹理 */
.summary-panel::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(184,145,70,0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.summary-panel::after {
  content: '';
  position: absolute;
  bottom: -30px; left: 10%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(26,77,74,0.04) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}
.panel-icon { font-size: 24px; }
.panel-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px 20px;
  align-items: end;
  position: relative;
  z-index: 1;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.75;
}

/* 分段切换 */
.seg {
  display: inline-flex;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(184, 145, 70, 0.3);
  border-radius: 14px;
  padding: 4px;
  gap: 3px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
  width: fit-content;
  max-width: 100%;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  padding: 9px 20px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: all 0.25s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.seg-btn:hover { color: var(--ink); background: rgba(255,255,255,0.5); }
.seg-btn.active {
  background: linear-gradient(135deg, var(--ink), var(--ink-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(26, 77, 74, 0.35);
  transform: translateY(-1px);
}

/* 表单控件 */
.control {
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0 14px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a5a5a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184, 145, 70, 0.15);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.panel-hint { font-size: 13px; color: var(--red); font-weight: 500; }

/* 生成按钮 — 复用站点 btn-add 金色系 + 墨青变体 */
.gen-btn {
  background: linear-gradient(135deg, var(--ink), var(--ink-light)) !important;
  box-shadow: 0 4px 16px rgba(26, 77, 74, 0.35) !important;
  transition: all 0.25s cubic-bezier(.4,0,.2,1) !important;
}
.gen-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(26, 77, 74, 0.45) !important;
  background: linear-gradient(135deg, var(--ink-light), var(--ink)) !important;
}

/* ---------- 加载态 — 居中优雅动画 ---------- */
.gen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 52px 24px;
  background: linear-gradient(135deg, var(--paper-card), #f8f4e8);
  border: 1.5px dashed var(--gold);
  border-radius: 20px;
  margin-bottom: 32px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(184, 145, 70, 0.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 16px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.loading-time {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 历史总结区域 ---------- */
.summary-section { margin-top: 8px; }
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.list-count {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(26, 77, 74, 0.06);
  padding: 3px 12px;
  border-radius: 20px;
}

/* 双列网格 + 移动端单列 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
@media (max-width: 768px) {
  .summary-grid { grid-template-columns: 1fr; }
  .panel-grid { grid-template-columns: 1fr 1fr; }
  #yearField { grid-column: 1 / -1; }
  /* 分段切换在窄屏占满整行，两按钮均分宽度，文字不换行 */
  #typeSeg { width: 100%; }
  #typeSeg .seg { width: 100%; }
  #typeSeg .seg-btn { flex: 1 1 0; text-align: center; padding: 10px 8px; }
}
@media (max-width: 420px) {
  .panel-grid { grid-template-columns: 1fr; }
  #yearField { grid-column: auto; }
}

/* 总结卡片 — 精致玻璃态 */
.summary-card {
  background: linear-gradient(165deg, #fffdf7, #faf8f2);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 22px 24px;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(26, 77, 74, 0.05);
  transition: all 0.3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
/* 卡片顶部装饰线 */
.summary-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--ink-light), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.summary-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(26, 77, 74, 0.12);
  border-color: var(--gold-light);
}
.summary-card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: center; gap: 10px; }
.card-type {
  background: linear-gradient(135deg, var(--ink), var(--ink-light));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.card-period {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}
.card-preview {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.card-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.card-btns { display: flex; gap: 8px; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.icon-btn:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.icon-btn.danger { color: var(--red); border-color: rgba(192,57,43,0.25); }
.icon-btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin: 4px 0; font-size: 15px; }
.empty-sub { font-size: 13px !important; color: var(--text-muted); opacity: 0.7; }
.list-loading {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 详情弹层 — 全屏沉浸式 ---------- */
.viewer.hidden { display: none !important; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: backdropIn 0.2s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 56, 54, 0.6);
  backdrop-filter: blur(8px);
}
.viewer-panel {
  position: relative;
  background: linear-gradient(180deg, #fffdf7, #faf8f2);
  border-radius: 22px;
  max-width: 980px;
  width: 100%;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: 36px 36px 32px;
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(184, 145, 70, 0.2);
  animation: panelIn 0.35s cubic-bezier(.34,1.56,.64,1);
}
/* 内容区单独滚动，页脚按钮不随内容滑动 */
#detailContent {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* 滚动时隐藏滚动条 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#detailContent::-webkit-scrollbar { display: none; width: 0; height: 0; }
/* 底部操作条：关闭(占 5 份) + 分享(占 1 份，约 1/5 宽)
   桌面端面板内边距 36px / 底部 32px，用负边距抵消，使按钮铺满左右并贴住面板底 */
.viewer-actions {
  display: flex;
  flex-shrink: 0;
  margin-top: 20px;
  margin-left: -36px; margin-right: -36px;
  margin-bottom: -32px;
  border-radius: 0 0 22px 22px;
  overflow: hidden;
}
.viewer-close-bottom {
  display: flex;
  flex: 5 1 0;
  margin: 0;
  width: auto;
  /* 高度保持紧凑；墨青条贴住面板底左半 */
  padding: 13px 0;
  border: none;
  border-radius: 0 0 0 22px;
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.viewer-close-bottom:active { opacity: 0.85; }
/* 分享按钮：暗金色，宽度约为关闭按钮的 1/5 */
.viewer-share-bottom {
  display: flex;
  flex: 1 1 0;
  min-width: 76px;
  margin: 0;
  padding: 13px 0;
  border: none;
  border-radius: 0 0 22px 0;
  background: var(--gold);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.viewer-share-bottom:active { opacity: 0.85; }
.viewer-share-bottom.is-shared { background: var(--gold-light); }
@keyframes panelIn { from { transform: scale(0.92) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* 详情头部 */
.summary-detail .detail-head { margin-bottom: 24px; }
.detail-type {
  display: inline-block;
  background: linear-gradient(135deg, var(--ink), var(--ink-light));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.detail-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 14px;
  line-height: 1.35;
}
.detail-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.tag {
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 20px;
  font-weight: 500;
}
.tag-period { background: rgba(184, 145, 70, 0.15); color: #a07830; }

/* 趋势对比徽章行 */
.trend-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding: 20px;
  background: linear-gradient(135deg, #f0faf6, #f8f4ea);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}
.trend-label {
  width: 100%;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.trend-badge {
  flex: 1;
  min-width: 160px;
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  border-left: 4px solid var(--text-muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  transition: transform 0.2s;
}
.trend-badge:hover { transform: translateY(-2px); }
.trend-badge.up { border-left-color: var(--green); }
.trend-badge.down { border-left-color: var(--red); }
.trend-badge.flat { border-left-color: var(--text-muted); }
.trend-name { font-size: 12px; color: var(--text-soft); font-weight: 500; margin-bottom: 6px; }
.trend-val { font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.trend-badge.up .trend-val { color: var(--green); }
.trend-badge.down .trend-val { color: var(--red); }
.trend-rate { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* 详情正文 */
.detail-body {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}
.detail-body h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 26px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(184, 145, 70, 0.2);
}
.detail-body h2:first-child { margin-top: 0; }
.detail-body h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 20px 0 10px;
}
.detail-body h4 { font-size: 15px; color: var(--ink-light); font-weight: 600; margin: 16px 0 8px; }
.detail-body p { margin: 10px 0; }
.detail-body ul { margin: 10px 0; padding-left: 24px; }
.detail-body li { margin: 5px 0; line-height: 1.7; }
.detail-body strong { color: var(--ink); font-weight: 600; }

/* 详情元信息 — 精致页脚 */
.detail-meta {
  margin-top: 28px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(26, 77, 74, 0.04), rgba(184, 145, 70, 0.06));
  border: 1px solid rgba(184, 145, 70, 0.12);
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.detail-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.3px;
}
.detail-meta span::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #c9a050);
  opacity: 0.7;
}

/* 隐藏辅助类 */
.hidden { display: none !important; }

/* 响应式微调 */
@media (max-width: 600px) {
  .summary-panel { padding: 20px; border-radius: 16px; }
  /* 弹层避让刘海 / 状态栏 / 底部安全区 —— 移动端用绝对定位钉满，不依赖 flex 百分比高度 */
  .viewer { padding: 0; }
  .viewer-panel {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    bottom: 0;
    max-width: none;
    width: auto;
    height: auto;
    padding: 22px 18px 0;
    border-radius: 18px;
  }
  .viewer-actions {
    display: flex;
    flex-shrink: 0;
    margin-left: -18px; margin-right: -18px;
    width: calc(100% + 36px);
    /* 移动端面板底部内边距为 0，归零避免按钮溢出面板底 */
    margin-bottom: 0;
    border-radius: 0 0 18px 18px;
  }
  .viewer-close-bottom {
    display: flex;
    margin: 0;
    width: auto;
    border-radius: 0 0 0 18px;
  }
  .viewer-share-bottom { border-radius: 0 0 18px 0; }
  .detail-meta { gap: 14px; font-size: 11.5px; padding: 13px 15px; }
  /* 移动端内容区占满面板剩余高度并独立滚动 */
  #detailContent { flex: 1 1 auto; }
  .detail-title { font-size: 20px; }
  .trend-badge { min-width: 140px; padding: 10px 12px; }
  .trend-val { font-size: 18px; }
}
