/**
 * HMC 数据平台 - 公共样式
 * public/styles/main.css
 */

/* ============================================
   CSS 变量
   ============================================ */
:root {
  /* 背景色 */
  --bg-primary: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f3;
  
  /* 文字颜色 */
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  
  /* 边框 */
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  
  /* 状态颜色 */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08);
  
  /* 圆角 */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* 过渡 */
  --transition: 0.2s ease;
}

/* ============================================
   基础重置
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================
   导航栏
   ============================================ */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

/* Logo 区域 */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.nav-brand-icon {
  width: 20px;
  height: 20px;
  color: var(--success);
  flex-shrink: 0;
}

.nav-brand-text {
  white-space: nowrap;
}

/* 菜单区域 */
.nav-menu {
  display: flex;
  list-style: none;
  gap: 4px;
  margin: 0;
  padding: 0;
}

/* 菜单项链接 */
.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

/* 菜单图标 - 固定 16px，与文字协调 */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-link:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--success);
  color: white;
}

.nav-link.active .nav-icon {
  color: white;
}

/* 菜单文字 */
.nav-text {
  line-height: 1;
}

/* 响应式 - 平板 */
@media (max-width: 1024px) {
  .nav-brand-text {
    display: none;
  }
  
  .nav-link {
    padding: 6px 10px;
  }
  
  .nav-text {
    display: none;
  }
}

/* 响应式 - 手机 */
@media (max-width: 768px) {
  .navbar {
    padding: 0 12px;
    gap: 12px;
    overflow-x: auto;
  }
  
  .nav-brand {
    padding-right: 12px;
  }
  
  .nav-menu {
    gap: 2px;
  }
  
  .nav-link {
    padding: 6px 8px;
  }
}

/* ============================================
   页面容器
   ============================================ */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ============================================
   卡片
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.card-label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 500;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  letter-spacing: -0.5px;
}

.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.danger { color: var(--danger); }

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 汇总卡片网格 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* ============================================
   区块
   ============================================ */
.section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
}

.section-badge {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--bg-primary);
  border-radius: 20px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================
   表格
   ============================================ */
.table-wrapper {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-primary);
}

.table td {
  font-size: 14px;
  color: var(--text-primary);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--bg-primary);
}

.table .money {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-weight: 500;
}

/* 数字右对齐 */
.table th.text-right,
.table td.text-right {
  text-align: right;
}

/* ============================================
   标签
   ============================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag.success {
  background: var(--success-bg);
  color: var(--success);
}

.tag.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.tag.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.tag.info {
  background: var(--info-bg);
  color: var(--info);
}

.tag.skin {
  background: #eff6ff;
  color: #3b82f6;
}

.tag.injection {
  background: #ecfdf5;
  color: #10b981;
}

.tag.surgery {
  background: #f5f3ff;
  color: #8b5cf6;
}

/* ============================================
   按钮
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--success);
  color: white;
}

.btn-primary:hover {
  background: #0ea472;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================
   表单
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--success);
}

/* ============================================
   进度条
   ============================================ */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  max-width: 200px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ============================================
   加载状态
   ============================================ */
.loading {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--success);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============================================
   工具类
   ============================================ */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

.font-mono { font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; }
.font-bold { font-weight: 600; }

.flex { display: flex; }
.flex-center { align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ============================================
   动画
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}
