/* ========================================
   AION 价格监控系统 - 现代化样式
   ======================================== */

/* --- 主题变量 --- */
:root {
  /* 浅色主题 */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.75);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --border-color: rgba(148, 163, 184, 0.2);
  --border-accent: rgba(59, 130, 246, 0.3);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-bg: rgba(59, 130, 246, 0.1);
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
  --gradient-bg: linear-gradient(135deg, #e0f2fe 0%, #f0fdf4 50%, #fef3c7 100%);
  --chart-line: #3b82f6;
  --chart-fill: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] {
  /* 深色主题 */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --border-color: rgba(148, 163, 184, 0.15);
  --border-accent: rgba(96, 165, 250, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-light: #93c5fd;
  --accent-bg: rgba(96, 165, 250, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
  --gradient-bg: linear-gradient(135deg, #1e3a5f 0%, #1a2e35 50%, #2d1f1f 100%);
  --chart-line: #60a5fa;
  --chart-fill: rgba(96, 165, 250, 0.2);
}

/* --- 基础样式 --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "SF Pro Display", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.3s ease;
}

/* --- 容器 --- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* --- Header --- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  margin-bottom: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.hero:hover {
  box-shadow: var(--shadow-lg);
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--success));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  animation: pulse 3s ease-in-out infinite;
  color: #fff;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.hero h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* --- 主题切换按钮 --- */
.theme-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.theme-btn:hover {
  background: var(--accent-bg);
  border-color: var(--border-accent);
  transform: rotate(15deg);
  color: var(--accent);
}

.theme-btn .icon-sun {
  display: none;
}

.theme-btn .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-btn .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-btn .icon-moon {
  display: none;
}

/* --- 筛选面板 --- */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  flex: 1;
}

.filter-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

select,
input[type="date"] {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

select:hover,
input[type="date"]:hover {
  border-color: var(--border-accent);
}

select:focus,
input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* --- 按钮 --- */
.btn {
  height: 42px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.btn svg {
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-ghost {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--accent-bg);
  border-color: var(--border-accent);
}

/* --- 统计卡片 --- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.stat {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stat-icon-primary {
  background: var(--accent-bg);
  color: var(--accent);
}

.stat-icon-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat .k {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat .v {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* --- 图表区域 --- */
.chart {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-top: 20px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

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

.chart-title svg {
  color: var(--accent);
}

.chart-range {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--accent-bg);
  padding: 4px 12px;
  border-radius: 20px;
}

/* --- 时间范围控制 --- */
.time-range-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.time-range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.time-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.time-btn:hover {
  border-color: var(--border-accent);
  background: var(--accent-bg);
}

.time-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 内联自定义时间控件 */
.custom-range-inline {
  display: flex;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px;
  flex-wrap: nowrap !important;
  animation: fadeIn 0.2s ease;
}

.custom-range-inline input[type="datetime-local"] {
  width: 175px !important;
  height: 36px !important;
  padding: 0 8px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  flex-shrink: 0 !important;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
}

.custom-range-sep {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

.custom-range-inline .btn {
  flex-shrink: 0;
}

input[type="datetime-local"] {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

input[type="datetime-local"]:hover {
  border-color: var(--border-accent);
}

input[type="datetime-local"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* --- 缩放控制 --- */
.zoom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
}

.zoom-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.zoom-slider-wrap {
  flex: 1;
  min-width: 200px;
}

.zoom-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.range-slider-container {
  flex: 1;
  position: relative;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
}

.range-slider-track {
  position: absolute;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 3px;
  pointer-events: none;
}

input[type="range"] {
  position: absolute;
  width: 100%;
  height: 6px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  top: 0;
  left: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  pointer-events: auto;
}

/* --- 图表容器 --- */
.chart-box {
  width: 100%;
  height: 400px;
  position: relative;
  overflow: visible;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- Header 操作区 --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}


/* --- 模态框 --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  overflow: hidden;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

/* 模态框表格 */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-secondary);
}

th:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

th:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

td {
  color: var(--text-primary);
  line-height: 1.6;
}

td ul {
  padding-left: 20px;
  margin: 0;
}

td li {
  margin-bottom: 4px;
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  .wrap {
    padding: 16px;
  }

  .hero {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .hero-left {
    width: 100%;
    justify-content: space-between;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .stat .v {
    font-size: 24px;
  }

  .range-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .range-buttons {
    justify-content: center;
    flex-wrap: wrap;
  }

  .range-slider-wrap {
    width: 100%;
  }

  .range-value {
    text-align: center;
    width: 100%;
  }

  .chart-box {
    height: 300px;
  }
}

/* --- 动画 --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel,
.stat,
.chart {
  animation: fadeIn 0.4s ease-out;
}

.stat:nth-child(1) {
  animation-delay: 0.05s;
}

.stat:nth-child(2) {
  animation-delay: 0.1s;
}

.stat:nth-child(3) {
  animation-delay: 0.15s;
}