/* ============================================================
   components.css —— 聊天气泡 / 卡片 / 按钮 / 弹窗 / 表格 / 表单 / 标签 / Toast
   ============================================================ */

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--r-md); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; line-height: 1; transition: all .15s ease;
  background: var(--c-surface-2); color: var(--c-text); white-space: nowrap;
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-ghost { background: transparent; border-color: var(--c-border); }
.btn-ghost:hover { background: var(--c-surface-2); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #d8333f; }
.btn-mint { background: var(--c-mint); color: #04231a; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===== 卡片 ===== */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 18px;
}
.card-hover { transition: box-shadow .18s ease, transform .18s ease; }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-sub { color: var(--c-text-2); font-size: 13px; }

/* 网格 */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ===== 标签 / 徽章 ===== */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600;
  background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border);
}
.tag-primary { background: var(--c-primary-soft); color: var(--c-primary); border-color: transparent; }
.tag-mint { background: var(--c-mint-soft); color: #0E9F6E; border-color: transparent; }
.tag-warning { background: var(--c-warning-soft); color: #B9760B; border-color: transparent; }
.tag-danger { background: var(--c-danger-soft); color: var(--c-danger); border-color: transparent; }

/* 状态徽章 */
.badge-pending { background: var(--c-warning-soft); color: #B9760B; }
.badge-published { background: var(--c-mint-soft); color: #0E9F6E; }
.badge-rejected { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-draft { background: var(--c-surface-2); color: var(--c-text-2); }

/* ===== 表单 ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--c-text-2); }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--c-border);
  border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.select { cursor: pointer; height: 40px; }
.select:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); outline: none; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); outline: none;
}
.textarea { min-height: 92px; line-height: 1.5; }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .input { flex: 1; }
.input-affix { position: relative; }
.input-affix .affix-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; color: var(--c-text-3);
}

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0; background: #cfd6e4;
  border-radius: 999px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow-sm);
}
.switch input:checked + .slider { background: var(--c-primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--c-border); }
.switch-row:last-child { border-bottom: none; }
.switch-row .sr-label { font-size: 14px; }
.switch-row .sr-desc { font-size: 12px; color: var(--c-text-3); }

/* ===== 表格 ===== */
.table-wrap { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--c-border); }
table.tbl th { background: var(--c-surface-2); font-weight: 600; color: var(--c-text-2); font-size: 13px; white-space: nowrap; }
table.tbl tbody tr:hover { background: var(--c-surface-2); }
table.tbl tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12,18,34,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  animation: popIn .22s ease;
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--c-border); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--c-text-3); line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--c-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Toast ===== */
.toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 200px; max-width: 80vw;
  background: #1f2738; color: #fff; padding: 11px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); font-size: 14px; display: flex; align-items: center; gap: 8px;
  animation: riseIn .22s ease;
}
.toast.ok { background: #0E9F6E; }
.toast.err { background: var(--c-danger); }
.toast.warn { background: #B9760B; }
.toast.info { background: #1f2738; }

/* ===== 空状态 ===== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 20px; color: var(--c-text-3); text-align: center; gap: 10px;
}
.empty .e-ico { font-size: 46px; opacity: .6; }
.empty p { margin: 0; }

/* ===== 骨架屏 ===== */
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #e2e7f0 37%, #eef1f6 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ===== 聊天界面 ===== */
.chat {
  display: flex; flex-direction: column; height: 100%; background: var(--c-bg);
}
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
}
.chat-head .ch-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--c-mint-soft); display:flex; align-items:center; justify-content:center; font-size: 20px; }
.chat-head .ch-meta { flex: 1; min-width: 0; }
.chat-head .ch-name { font-weight: 600; }
.chat-head .ch-status { font-size: 12px; color: var(--c-text-3); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-foot {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--c-surface); border-top: 1px solid var(--c-border);
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-foot .textarea { min-height: 44px; max-height: 140px; flex: 1; }

/* 时间分隔 */
.time-sep { text-align: center; font-size: 12px; color: var(--c-text-3); margin: 4px 0; }

/* 气泡 */
.msg { display: flex; gap: 10px; max-width: 82%; animation: riseIn .25s ease; }
.msg .m-avatar { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px; display:flex; align-items:center; justify-content:center; font-size:16px; }
.msg .bubble {
  padding: 10px 14px; border-radius: 14px; line-height: 1.55; word-break: break-word;
  box-shadow: var(--shadow-sm); position: relative;
}
.msg .bubble p { margin: 0 0 6px; } .msg .bubble p:last-child { margin: 0; }
.msg .m-time { font-size: 11px; color: var(--c-text-3); margin-top: 4px; }

/* 患者（左） */
.msg.patient { align-self: flex-start; }
.msg.patient .m-avatar { background: var(--c-mint-soft); color: #0E9F6E; }
.msg.patient .bubble { background: var(--c-bubble-patient); color: var(--c-text); border-top-left-radius: 4px; }

/* 医生（右） */
.msg.doctor { align-self: flex-end; flex-direction: row-reverse; }
.msg.doctor .m-avatar { background: var(--c-primary-soft); color: var(--c-primary); }
.msg.doctor .bubble { background: var(--c-bubble-doctor); color: #fff; border-top-right-radius: 4px; }
.msg.doctor .m-time { text-align: right; }

/* 关键线索可点击标签 */
.clue-tag {
  display: inline; color: var(--c-primary); background: #fff;
  border: 1px solid var(--c-primary); border-radius: 6px; padding: 0 5px; margin: 0 1px;
  cursor: pointer; font-weight: 600; font-size: .92em; text-decoration: none;
}
.msg.doctor .clue-tag { color: #fff; background: rgba(255,255,255,.18); border-color: #fff; }
.clue-tag:hover { filter: brightness(.96); }

/* 正在输入动画 */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa6bd; animation: blink 1.2s infinite both; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{ opacity:.25; transform: translateY(0);} 40%{ opacity:1; transform: translateY(-3px);} }

/* ===== 抽屉（线索详情） ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(12,18,34,.4); z-index: 90; animation: fadeIn .2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 90vw;
  background: var(--c-surface); box-shadow: var(--shadow-lg); z-index: 91;
  display: flex; flex-direction: column; animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(100%);} to { transform: none; } }
.drawer-head { display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--c-border); }
.drawer-body { padding: 18px; overflow-y: auto; }

/* 统计卡片（数据总览） */
.stat {
  background: var(--c-surface); border:1px solid var(--c-border); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.stat .s-ico { width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:20px;background:var(--c-primary-soft);color:var(--c-primary);margin-bottom:10px; }
.stat .s-num { font-size: 28px; font-weight: 700; }
.stat .s-label { color: var(--c-text-2); font-size: 13px; margin-top: 2px; }

/* 诊断报告 */
.report { background: var(--c-surface); border:1px solid var(--c-border); border-radius: var(--r-lg); padding: 20px; }
.report h3 { margin-bottom: 12px; }
.report .r-row { display:flex; gap:10px; padding: 9px 0; border-bottom: 1px dashed var(--c-border); }
.report .r-row:last-child{ border-bottom:none; }
.report .r-key { flex:0 0 120px; color: var(--c-text-2); font-size: 13px; }
.report .r-val { flex:1; }

/* 进度条 */
.progress { height: 8px; background: var(--c-surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display:block; height:100%; background: var(--c-primary); border-radius:999px; transition: width .3s ease; }

/* 知识卡片（折叠） */
.knowledge details { border:1px solid var(--c-border); border-radius: var(--r-md); margin-bottom:8px; background:var(--c-surface); }
.knowledge summary { padding:10px 14px; cursor:pointer; font-weight:600; }
.knowledge .k-body { padding: 0 14px 12px; color:var(--c-text-2); font-size:13.5px; }

/* 题卡 */
.quiz-card { background: var(--c-surface); border:1px solid var(--c-border); border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; }
.quiz-stem { font-weight:600; margin-bottom: 12px; }
.quiz-opt { display:flex; gap:10px; align-items:flex-start; padding:10px 12px; border:1px solid var(--c-border); border-radius: var(--r-md); margin-bottom:8px; cursor:pointer; transition: all .15s; }
.quiz-opt:hover { border-color: var(--c-primary); }
.quiz-opt.sel { border-color: var(--c-primary); background: var(--c-primary-soft); }
.quiz-opt.correct { border-color: var(--c-mint); background: var(--c-mint-soft); }
.quiz-opt.wrong { border-color: var(--c-danger); background: var(--c-danger-soft); }
.quiz-opt .opt-key { font-weight:700; flex:0 0 20px; }
.quiz-explain { margin-top:10px; padding:12px; background:var(--c-surface-2); border-radius:var(--r-md); font-size:13.5px; }
.quiz-explain .qe-title { font-weight:600; color:var(--c-primary); margin-bottom:4px; }

/* 病例选择面板 */
.case-filter { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.case-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap:14px; }
.case-pick { border:1px solid var(--c-border); border-radius:var(--r-lg); padding:16px; background:var(--c-surface); cursor:pointer; transition: all .15s; }
.case-pick:hover { border-color:var(--c-primary); box-shadow:var(--shadow-md); transform:translateY(-2px); }
.case-pick .cp-title { font-weight:700; margin-bottom:6px; }
.case-pick .cp-meta { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }

/* 演示模式横幅 */
.demo-banner {
  background: var(--c-warning-soft); color: #9a6700; border:1px solid #f3d28a;
  padding: 8px 14px; border-radius: var(--r-md); font-size: 13px; display:flex; gap:8px; align-items:center;
}
.maintain-banner {
  background: var(--c-danger-soft); color: var(--c-danger); border:1px solid #f3b6bb;
  padding: 20px; border-radius: var(--r-lg); text-align:center; font-size:15px; margin:auto;
}
