/* =============================================
   麻醉战情看板 - 全局样式表
   设计理念：Mobile-first, 大按钮防误触, 玻璃拟态
============================================= */

:root {
  /* 基础颜色 */
  --bg-color: #121212;
  --bg-card: #1e1e1e;
  --text-main: #f0f0f0;
  --text-muted: #a0a0a0;
  --border-color: #333;
  --brand-color: #4a90e2;

  /* 状态颜色 (根据 PRD 设计) */
  --color-preparing: #455a64;  /* 蓝灰 */
  --color-induction: #f57c00;  /* 橙黄 */
  --color-surgery: #d32f2f;    /* 红色 */
  --color-recovery: #388e3c;   /* 绿色 */
  --color-discharged: #424242; /* 灰色 */

  /* 阴影与特效 */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.5);
  --glass-bg: rgba(30, 30, 30, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  --border-radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 20px;
}

/* =============================================
   顶部导航栏与统计
============================================= */
.header {
  background: var(--bg-card);
  padding: 15px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  transition: background 0.2s;
}

.btn-icon:active {
  background: rgba(255,255,255,0.1);
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stat-value {
  font-weight: 700;
  font-size: 1.1rem;
}

/* 状态颜色文本 */
.text-surgery { color: #ff8a80; }
.text-recovery { color: #b9f6ca; }

/* =============================================
   看板网格与卡片
============================================= */
.container {
  padding: 15px;
  max-width: 800px;
  margin: 0 auto;
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

@media (min-width: 600px) {
  .case-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.case-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  border-left: 6px solid var(--border-color); /* 默认边框，会被状态覆盖 */
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  animation: slideIn 0.3s ease-out forwards;
  opacity: 0;
  transform: translateY(10px);
}

.case-card:active {
  transform: scale(0.98);
}

.case-card.removing {
  animation: fadeOut 0.3s ease-in forwards;
}

/* 卡片状态颜色 */
.card-preparing  { border-left-color: var(--color-preparing); background: linear-gradient(90deg, rgba(69,90,100,0.1) 0%, rgba(30,30,30,0) 100%), var(--bg-card); }
.card-induction  { border-left-color: var(--color-induction); background: linear-gradient(90deg, rgba(245,124,0,0.1) 0%, rgba(30,30,30,0) 100%), var(--bg-card); }
.card-surgery    { border-left-color: var(--color-surgery);   background: linear-gradient(90deg, rgba(211,47,47,0.1) 0%, rgba(30,30,30,0) 100%), var(--bg-card); }
.card-recovery   { border-left-color: var(--color-recovery);  background: linear-gradient(90deg, rgba(56,142,60,0.1) 0%, rgba(30,30,30,0) 100%), var(--bg-card); }
.card-discharged { border-left-color: var(--color-discharged); opacity: 0.7; }

/* 状态变化闪烁 */
@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.case-card.pulse { animation: pulseGlow 1s ease-out; }

/* 卡片内部排版 */
.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}

.card-species {
  font-size: 1.2rem;
  background: rgba(255,255,255,0.1);
  padding: 4px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-patient {
  flex: 1;
  font-size: 1.1rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-asa {
  font-size: 0.75rem;
  background: #424242;
  padding: 2px 6px;
  border-radius: 4px;
  color: #e0e0e0;
}

.card-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.card-progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.card-progress-fill {
  height: 100%;
  background: currentColor; /* 继承父级颜色，若无则默认为文字色，可通过JS动态设置或使用CSS变量 */
  border-radius: 3px;
  transition: width 0.5s ease-out;
}
/* 进度条颜色对应状态 */
.card-preparing .card-progress-fill { background: var(--color-preparing); }
.card-induction .card-progress-fill { background: var(--color-induction); }
.card-surgery .card-progress-fill   { background: var(--color-surgery); }
.card-recovery .card-progress-fill  { background: var(--color-recovery); }
.card-discharged .card-progress-fill{ background: var(--color-discharged); }


.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  justify-content: space-between;
}

.card-procedure {
  flex-basis: 100%;
  background: rgba(255,255,255,0.05);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

/* =============================================
   空状态
============================================= */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state.visible {
  display: flex;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* =============================================
   弹窗 (Modal)
============================================= */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: flex-end; /* 底部弹出 */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--glass-bg);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-top: 1px solid var(--glass-border);
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brand-color);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
}

.modal-step {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
}

.modal-step.active {
  display: flex;
  animation: fadeIn 0.3s;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.btn-back {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* 进度节点大按钮 */
.node-grid, .staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding-bottom: 20px;
}

.node-btn, .staff-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

.node-btn:active, .staff-btn:active {
  transform: scale(0.95);
  background: rgba(255,255,255,0.1);
}

.node-icon { font-size: 1.8rem; }
.node-label { font-size: 1rem; font-weight: 600; }

.node-preparing  { border-bottom: 4px solid var(--color-preparing); }
.node-induction  { border-bottom: 4px solid var(--color-induction); }
.node-surgery    { border-bottom: 4px solid var(--color-surgery); }
.node-recovery   { border-bottom: 4px solid var(--color-recovery); }
.node-discharged { border-bottom: 4px solid var(--color-discharged); }

.staff-icon { font-size: 1.5rem; }
.staff-name { font-size: 1.1rem; font-weight: 600; }
.staff-role { font-size: 0.8rem; color: var(--text-muted); background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px;}

/* =============================================
   进度历史时间轴
============================================= */
.timeline-section {
  margin-bottom: 15px;
}

.timeline-section-title {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.timeline-history {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  padding: 6px 8px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border-left: 3px solid var(--brand-color);
  flex-wrap: wrap;
}

.timeline-time {
  font-weight: 700;
  color: var(--brand-color);
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}

.timeline-icon {
  font-size: 1rem;
}

.timeline-node {
  font-weight: 600;
  color: var(--text-main);
}

.timeline-memo {
  color: #90caf9;
  background: rgba(144,202,249,0.1);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.timeline-operator {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 0.8rem;
  white-space: nowrap;
}

.timeline-loading,
.timeline-empty,
.timeline-error {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px;
}

.timeline-error {
  color: #ff8a80;
}

/* 自定义滚动条样式 */
.timeline-history::-webkit-scrollbar {
  width: 4px;
}
.timeline-history::-webkit-scrollbar-track {
  background: transparent;
}
.timeline-history::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

/* =============================================
   备注输入框 (弹窗内)
============================================= */
.memo-group {
  margin-bottom: 15px;
}

.memo-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.memo-input:focus {
  outline: none;
  border-color: var(--brand-color);
  background: rgba(255,255,255,0.08);
}

.memo-input::placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* =============================================
   PIN 键盘
============================================= */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 20px 0 30px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  transition: all 0.2s;
}

.pin-dot.filled {
  background: var(--brand-color);
  border-color: var(--brand-color);
  transform: scale(1.2);
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  max-width: 300px;
  margin: 0 auto;
}

.num-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  aspect-ratio: 1; /* 正方形/圆形 */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.num-btn:active {
  background: rgba(255,255,255,0.2);
}

.num-btn.action-btn {
  background: transparent;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
}

.pin-info {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 20px;
}

/* =============================================
   全屏 Loading 遮罩
============================================= */
.submit-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18,18,18,0.8);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 20px 20px 0 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}

.submit-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--brand-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

/* =============================================
   Toast 提示
============================================= */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.95rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-left: 4px solid var(--color-recovery); }
.toast-error { border-left: 4px solid var(--color-surgery); }
.toast-info { border-left: 4px solid var(--brand-color); }

/* =============================================
   表单页面 (Admin)
============================================= */
.form-container {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 15px;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-color);
  background: rgba(255,255,255,0.08);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a0a0a0%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 15px top 50%;
  background-size: 12px auto;
}

.btn-primary {
  width: 100%;
  background: var(--brand-color);
  color: white;
  border: none;
  padding: 15px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.8;
}

.btn-primary:disabled {
  background: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-feedback {
  margin-top: 15px;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  display: none;
}

.form-feedback.visible { display: block; }
.feedback-success { background: rgba(56,142,60,0.2); color: #b9f6ca; }
.feedback-error { background: rgba(211,47,47,0.2); color: #ff8a80; }

/* =============================================
   动画
============================================= */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.9); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* =============================================
   Dropdown Menu
============================================= */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: var(--bg-card);
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  z-index: 1000;
  overflow: hidden;
}

.dropdown-content.show {
  display: block;
}

.dropdown-item {
  color: var(--text-main);
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: 1rem;
}

.dropdown-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
