/* ===== 梧桐病历夹 - 样式 ===== */
:root {
  --primary: #1B7FEB;
  --primary-light: #E8F2FF;
  --primary-dark: #0D5EBD;
  --bg: #F0F4F9;
  --card: #FFFFFF;
  --text: #1F2937;
  --text2: #6B7280;
  --text3: #9CA3AF;
  --border: #E5E7EB;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --green: #10B981;
  --red: #EF4444;
  --orange: #F59E0B;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 800px; margin: 0 auto; padding: 0 16px; }

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, #1B7FEB 0%, #0D5EBD 100%);
  padding: 36px 0 28px;
  text-align: center;
}
.header-sm { padding: 16px 0 12px; }
.header-inner { max-width: 800px; margin: 0 auto; padding: 0 16px; }
.header-row { display: flex; align-items: center; gap: 12px; }
.header-back {
  color: rgba(255,255,255,0.9);
  font-size: 22px;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.header-back:active { background: rgba(255,255,255,0.15); }

.logo { font-size: 28px; color: #fff; font-weight: 700; letter-spacing: 1px; }
.logo-sm { font-size: 20px; }
.subtitle { font-size: 14px; color: rgba(255,255,255,0.8); margin-top: 4px; }

/* ===== Main ===== */
.main { padding: 20px 0 40px; }

/* ===== Category Cards ===== */
.category-grid { display: flex; gap: 16px; margin-bottom: 24px; }
.category-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.category-card:active { transform: scale(0.98); }
.category-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.category-icon { font-size: 40px; }
.category-info { flex: 1; }
.category-title { font-size: 20px; font-weight: 700; }
.category-desc { font-size: 13px; color: var(--text2); margin-top: 2px; }
.category-count {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
  min-width: 48px;
  text-align: center;
}

/* ===== Section Header ===== */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-title { font-size: 18px; font-weight: 600; }
.section-actions { display: flex; gap: 8px; }

/* ===== Patient Card ===== */
.patient-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.patient-card:active { background: #F8FAFC; transform: scale(0.99); }
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-size: 17px; font-weight: 600; }
.patient-meta { font-size: 13px; color: var(--text2); margin-top: 2px; }
.patient-diagnosis { font-size: 14px; color: var(--text3); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archived-date { font-size: 12px; color: #999; font-weight: normal; margin-left: 6px; }

/* 录音按钮状态 */
#voiceBtn.recording { background: #ff4444 !important; color: #fff !important; animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }

/* 录音红点动画 */
.rec-dot { display: inline-block; width: 8px; height: 8px; background: #ff4444; border-radius: 50%; margin-right: 6px; animation: blink 0.6s ease-in-out infinite; vertical-align: middle; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.voice-status { font-size: 12px; color: #e53935; margin-top: 4px; padding: 4px 8px; border-radius: 6px; background: #fff5f5; text-align: center; }
.voice-proc { color: #1565c0; background: #e3f2fd; }
.patient-arrow { font-size: 24px; color: var(--text3); padding-left: 12px; }

/* ===== Patient Profile ===== */
.patient-profile {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.avatar-circle {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #1B7FEB, #0D5EBD);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-status { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.status-active { background: #D1FAE5; color: #065F46; }
.status-archived { background: #FEF3C7; color: #92400E; }
.profile-meta { font-size: 14px; color: var(--text2); margin-top: 4px; }
.profile-diag { font-size: 14px; color: var(--text); margin-top: 6px; background: var(--bg); padding: 8px 12px; border-radius: 8px; }
.profile-actions { display: flex; gap: 6px; align-items: flex-start; }

/* ===== Record Types ===== */
.record-types { margin-top: 8px; }

/* ===== Record Item ===== */
.record-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}
.record-header {
  display: flex; align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.record-header:active { background: #F8FAFC; }
.record-type-badge {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-admission { background: #E8F2FF; color: #1B7FEB; }
.badge-first_progress { background: #FEF3C7; color: #92400E; }
.badge-progress { background: #F0FDF4; color: #065F46; }
.badge-daily_progress { background: #F5F3FF; color: #5B21B6; }
.badge-preop_discussion { background: #FFF1F2; color: #9F1239; }
.badge-preop_summary { background: #FFF7ED; color: #9A3412; }
.badge-postop_summary { background: #FCE7F3; color: #9D174D; }
.badge-discharge { background: #ECFDF5; color: #065F46; }
.record-time { font-size: 12px; color: var(--text3); margin-left: auto; margin-right: 12px; white-space: nowrap; }
.record-toggle { font-size: 12px; color: var(--text3); transition: transform 0.2s; }
.record-body { padding: 0 16px 16px; }
.record-content {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'PingFang SC', 'Microsoft YaHei', monospace;
  max-height: 500px;
  overflow-y: auto;
}
.record-content strong { color: var(--primary); }
.record-foot { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Modal ===== */
.modal-mask {
  position: fixed; top:0; left:0; width:100%; height:100%;
  background: rgba(0,0,0,0.4); z-index: 100; animation: fadeIn 0.2s;
}
.modal {
  position: fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  background: var(--card); border-radius: var(--radius);
  z-index: 101; padding: 24px; width: calc(100% - 32px); max-width: 500px;
  max-height: 85vh; overflow-y: auto;
  animation: modalIn 0.25s ease;
}
.modal-wide { max-width: 600px; }
@keyframes fadeIn { from {opacity:0} to {opacity:1} }
@keyframes modalIn { from { opacity:0; transform:translate(-50%,-50%) scale(0.9) } to { opacity:1; transform:translate(-50%,-50%) scale(1) } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text3); padding: 4px 8px; cursor: pointer; }
.modal-body { }
.modal-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; margin-top: 12px; color: var(--text2); }
.modal-label:first-child { margin-top: 0; }

/* ===== Form ===== */
.ipt {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; outline: none; transition: border-color 0.2s;
  font-family: inherit; margin-bottom: 10px;
  background: var(--card);
}
.ipt:focus { border-color: var(--primary); }
.ipt-row { display: flex; gap: 10px; }
.ipt-half { flex: 1; }
.ipt-area { min-height: 140px; resize: vertical; }
select.ipt { appearance: auto; }

/* 带操作按钮的输入框 */
.ipt-with-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: stretch;
}
.ipt-flex { flex: 1; margin-bottom: 0; }
.ipt-btn {
  width: 48px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 22px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.ipt-btn:active { background: var(--primary-light); border-color: var(--primary); }
.ipt-btn.recording { background: #FEE2E2; border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

.ipt-area-wrap { align-items: flex-start; }
.ipt-side-btns { display: flex; flex-direction: column; gap: 8px; }
.ipt-side-btns .ipt-btn { width: 44px; height: 44px; }

.voice-status {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #FEF3C7;
  color: #92400E;
  text-align: center;
}

.btn-primary {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, #1B7FEB, #0D5EBD);
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.15s; margin-top: 8px;
}
.btn-primary:active { transform: scale(0.98); }

.btn-sm {
  padding: 6px 14px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-sm:active { background: var(--bg); }
.btn-danger { color: var(--red); border-color: #FECACA; }
.btn-danger:active { background: #FEF2F2; }

/* ===== Type Grid Small ===== */
.type-grid-sm {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;
}
.type-sm {
  padding: 10px 8px; text-align: center; font-size: 13px;
  background: var(--bg); border: 2px solid transparent; border-radius: 8px;
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.type-sm:active { transform: scale(0.97); }
.type-sm.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== Loading ===== */
.loading-inline { text-align: center; padding: 12px 0; color: var(--text2); font-size: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  background: rgba(0,0,0,0.78); color:#fff; padding:14px 28px;
  border-radius:10px; font-size:15px; z-index:999;
  animation: toastIn 0.25s ease; pointer-events:none;
}
@keyframes toastIn { from{opacity:0;transform:translate(-50%,-50%) scale(0.9)} to{opacity:1;transform:translate(-50%,-50%) scale(1)} }
.toast-out { animation: toastOut 0.25s ease forwards; }
@keyframes toastOut { to{opacity:0;transform:translate(-50%,-50%) scale(0.9)} }

/* ===== Footer ===== */
.footer { text-align: center; padding: 20px 0 32px; font-size: 12px; color: var(--text3); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .category-card { padding: 20px; }
  .category-icon { font-size: 32px; }
  .category-title { font-size: 18px; }
  .patient-profile { flex-direction: column; }
  .profile-actions { width: 100%; justify-content: flex-end; }
  .type-grid-sm { grid-template-columns: 1fr 1fr; }
  .modal { padding: 20px; }
}
