/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 默认夜间模式 */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: #1a1d23;
  color: #e5e7eb;
  line-height: 1.6;
  padding: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* 白天模式 - 应用到 html 元素以便更早生效 */
html.light-mode body {
  background: #F7F5F1;
  color: #1E2227;
}

html.light-mode .container {
  color: #1E2227;
}

html.light-mode .header h1 {
  color: #1E2227;
}

html.light-mode .header-note {
  color: #6B7077;
}

html.light-mode .stat-card {
  background: #FFFFFF;
  border-color: #E7E3DA;
}

html.light-mode .stat-label {
  color: #6B7077;
}

html.light-mode .stat-value {
  color: #1E2227;
}

html.light-mode .models h2 {
  color: #1E2227;
}

html.light-mode .model-card {
  background: #FFFFFF;
  border-color: #E7E3DA;
}

html.light-mode .model-card:hover {
  border-color: #3C5A78;
}

html.light-mode .model-name {
  color: #1E2227;
}

html.light-mode .model-stat-label {
  color: #6B7077;
}

html.light-mode .model-stat-value {
  color: #1E2227;
}

html.light-mode .model-history {
  background: #F7F5F1;
}

html.light-mode .history-bar.empty {
  background: #E7E3DA;
}

html.light-mode .footer {
  color: #6B7077;
}

/* 主题切换按钮 */
.theme-toggle-wrapper {
  position: absolute;
  right: 0;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(37, 41, 48, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(53, 57, 67, 0.8);
  border-radius: 24px;
  color: #e5e7eb;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15),
              0 2px 4px rgba(0, 0, 0, 0.1);
}

.theme-toggle-btn:hover {
  background: rgba(45, 49, 57, 0.98);
  border-color: rgba(60, 90, 120, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25),
              0 4px 8px rgba(0, 0, 0, 0.15);
}

.theme-toggle-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

html.light-mode .theme-toggle-btn {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-color: rgba(231, 227, 218, 0.8);
  color: #1E2227;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08),
              0 2px 4px rgba(0, 0, 0, 0.04);
}

html.light-mode .theme-toggle-btn:hover {
  background: rgba(247, 245, 241, 0.98);
  border-color: rgba(60, 90, 120, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
              0 4px 8px rgba(0, 0, 0, 0.06);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* 顶部区域 */
.header {
  text-align: center;
  margin-bottom: 40px;
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 20px;
}

.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.header-note {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #6b7280;
}

/* 横幅状态 */
.banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.banner-icon {
  font-size: 1.5rem;
}

.banner-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 2px solid rgba(16, 185, 129, 0.3);
}

.banner-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 2px solid rgba(245, 158, 11, 0.3);
}

.banner-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 2px solid rgba(239, 68, 68, 0.3);
}

.banner-loading {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 2px solid rgba(107, 114, 128, 0.3);
}

/* 统计卡片区域 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: #252930;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #353943;
  text-align: center;
}

.stat-label {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: #ffffff;
}

.stat-success {
  color: #10b981;
}

.stat-error {
  color: #ef4444;
}

/* 模型列表区域 */
.models {
  margin-bottom: 40px;
}

.models h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 24px;
}

.models-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 模型卡片 - 横向布局 */
.model-card {
  background: #252930;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #353943;
  transition: all 0.3s ease;
}

.model-card:hover {
  border-color: #3C5A78;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.model-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.model-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.model-name {
  font-weight: 600;
  font-size: 1rem;
  color: #ffffff;
}

.model-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.85rem;
  color: #9ca3af;
}

.model-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.model-stat-label {
  font-size: 0.75rem;
  color: #6b7280;
}

.model-stat-value {
  font-size: 0.9rem;
  color: #e5e7eb;
  font-weight: 500;
}

/* 历史请求可视化 */
.model-history {
  display: flex;
  gap: 2px;
  height: 40px;
  margin-top: 12px;
  background: #1a1d23;
  padding: 4px;
  border-radius: 6px;
}

.history-bar {
  flex: 1;
  border-radius: 3px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.history-bar:hover {
  transform: scaleY(1.15);
  filter: brightness(1.2);
  z-index: 10;
}

/* Tooltip 样式 - 玻璃态设计 */
.history-bar::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.98) 100%);
  backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 1000;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  /* 字体渲染优化 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1;
}

/* 小三角箭头 */
.history-bar::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(30, 41, 59, 0.98);
  pointer-events: none;
  opacity: 0;
  z-index: 1001;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.history-bar:hover::before,
.history-bar:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.history-bar.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.history-bar.error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.history-bar.empty {
  background: #353943;
}

/* 成功状态特殊高亮 */
.history-bar.success:hover {
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.history-bar.error:hover {
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

/* 响应式优化 - 移动端降低动画 */
@media (max-width: 768px) {
  .history-bar:hover {
    transform: scaleY(1.1);
  }

  .history-bar::before {
    font-size: 0.7rem;
    padding: 8px 12px;
  }
}

/* 减弱动画偏好设置 */
@media (prefers-reduced-motion: reduce) {
  .history-bar,
  .history-bar::before,
  .history-bar::after {
    transition: none;
  }

  .history-bar:hover {
    transform: none;
  }
}

/* 可用率指示器 */
.availability-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.availability-high {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.availability-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.availability-low {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* 错误信息 */
.model-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #fca5a5;
}

/* 页脚 */
.footer {
  text-align: center;
  padding: 20px;
  color: #6b7280;
  font-size: 0.9rem;
}

.footer p {
  margin: 4px 0;
}

.footer-note {
  font-size: 0.85rem;
  color: #4b5563;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    gap: 16px;
  }

  .theme-toggle-wrapper {
    position: static;
  }

  .theme-toggle-btn {
    padding: 10px 16px;
    font-size: 0.8125rem;
    border-radius: 20px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .banner {
    padding: 12px 24px;
    font-size: 1rem;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .model-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .model-stats {
    width: 100%;
    justify-content: space-between;
    margin-top: 8px;
  }
}
