/* chart.css */
/* ========================================
   Chart Page — 独立图表分析页面样式
   配色继承主站 + ui-ux-pro-max 设计系统
   ======================================== */

/* 覆盖主站 body 的居中卡片布局，图表页需要全屏铺满 */
body {
  display: block;
  justify-content: initial;
  align-items: initial;
  padding: 0;
  overflow: hidden;
}

/* 首屏遮罩（认证检查前）*/
body.app-loading::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg-primary, #0d1117);
}

/* 整体布局 */
.chart-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, sans-serif;
}

/* --- 顶栏 --- */
.chart-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 12px;
}

.chart-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-return-glass {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #F59E0B;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.btn-return-glass:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.btn-return-glass svg {
  transition: transform 0.2s;
}

.btn-return-glass:hover svg {
  transform: translateX(-3px);
}

.chart-topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: #F59E0B;
  letter-spacing: 0.5px;
}

/* 合约选择器 */
.symbol-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.symbol-btn {
  padding: 5px 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Roboto Mono', monospace;
  cursor: pointer;
  transition: all 0.2s;
}

.symbol-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

.symbol-btn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: #F59E0B;
  color: #F59E0B;
}

/* 全屏/主题切换按钮通用 */
.fullscreen-btn,
.chart-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.fullscreen-btn:hover,
.chart-theme-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* --- 图表模式 Tab --- */
.chart-mode-tabs {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 2px;
}

.mode-tab {
  padding: 5px 16px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-tab:hover {
  color: var(--text-primary);
}

.mode-tab.active {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
}

/* 图表类型切换（蜡烛/折线） */
.chart-type-group {
  display: flex;
  gap: 4px;
}

.chart-type-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.chart-type-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.25);
}

.chart-type-btn.active {
  color: #38BDF8;
  border-color: #38BDF8;
  background: rgba(56, 189, 248, 0.1);
}

/* --- 工具栏 --- */
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 12px;
}

.tf-group {
  display: flex;
  gap: 4px;
}

.tf-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s;
}

.tf-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.tf-btn.active {
  color: #F59E0B;
  background: rgba(245, 158, 11, 0.12);
}

.layer-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.layer-check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.layer-check input {
  accent-color: #F59E0B;
}

.layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* --- 图表容器 --- */
.chart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-pane {
  flex: 4;
  position: relative;
  min-height: 0;
}

.candle-timer {
  position: absolute;
  right: 70px;
  bottom: 40px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #F59E0B;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.candle-timer.visible {
  opacity: 1;
}

#basisChartContainer {
  width: 100%;
  height: 100%;
}

/* 面板标签 */
.pane-label {
  position: absolute;
  top: 6px;
  left: 12px;
  z-index: 10;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  opacity: 0.6;
  pointer-events: none;
}

/* --- 底部数值大屏 --- */
.basis-dashboard {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 1% 24px;
  background: rgba(13, 17, 23, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(139, 92, 246, 0.2);
  position: relative;
  overflow: hidden;
  transition: flex 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s, opacity 0.3s;
}

.basis-dashboard.collapsed {
  flex: 0 0 0px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-top: none !important;
  opacity: 0;
  pointer-events: none;
}

.dashboard-toggle-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  z-index: 999;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s;
}

.dashboard-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.basis-dashboard::before {
  content: '';
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 120%;
  background: radial-gradient(ellipse, rgba(139, 92, 246, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.basis-card {
  flex: 0 1 30%;
  height: 90%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 32px);
  padding: 0 clamp(12px, 2vw, 32px);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 1;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.basis-card.expand { border-color: rgba(239, 68, 68, 0.2); }
.basis-card.shrink { border-color: rgba(34, 197, 94, 0.2); }

.basis-card.active.expand {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.15), inset 0 0 20px rgba(239, 68, 68, 0.03);
}

.basis-card.active.shrink {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.15), inset 0 0 20px rgba(34, 197, 94, 0.03);
}

.basis-card-label {
  font-size: clamp(28px, 6vh, 64px);
  font-weight: 700;
  letter-spacing: 4px;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}

.basis-card.expand .basis-card-label { color: rgba(239, 68, 68, 0.7); }
.basis-card.shrink .basis-card-label { color: rgba(34, 197, 94, 0.7); }

.basis-card-value {
  font-size: clamp(48px, 10vh, 120px);
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Roboto Mono', monospace;
  line-height: 1;
  transition: color 0.2s, text-shadow 0.3s;
}

.basis-card.expand .basis-card-value {
  color: #EF4444;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.basis-card.shrink .basis-card-value {
  color: #22C55E;
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

@keyframes basisPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.basis-card.active .basis-card-value {
  animation: basisPulse 1.5s ease-in-out infinite;
}

.basis-card-delta {
  font-size: clamp(14px, 2.5vh, 28px);
  font-family: 'JetBrains Mono', monospace;
  opacity: 0.6;
  transition: opacity 0.3s;
}

.basis-card.active .basis-card-delta { opacity: 1; }

.chart-pane a[href*="tradingview"] { display: none !important; }

/* --- 状态栏 --- */
.chart-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  transition: background 0.3s;
}

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

/* 断线丝带 */
.reconnect-ribbon {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: linear-gradient(90deg, #f85149 0%, #da3633 100%);
  color: #fff;
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 500;
}

.reconnect-ribbon.show { display: block; }

/* ========================================
   亮色主题 (.chart-light)
   ======================================== */
.chart-light {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --text-primary: #1a1a2e;
  --text-muted: #6b7280;
  --border-color: rgba(0, 0, 0, 0.08);
  --green: #16a34a;
  --red: #dc2626;
}

.chart-light .symbol-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

.chart-light .chart-mode-tabs {
  background: rgba(0, 0, 0, 0.04);
}

.chart-light .tf-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chart-light .chart-type-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

.chart-light .fullscreen-btn:hover,
.chart-light .chart-theme-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

.chart-light .candle-timer {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chart-light .basis-dashboard {
  background: rgba(248, 249, 250, 0.85);
  border-top-color: rgba(139, 92, 246, 0.12);
}

.chart-light .basis-dashboard::before {
  background: radial-gradient(ellipse, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
}

.chart-light .basis-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}

.chart-light .dashboard-toggle-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

.chart-light .dashboard-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

.chart-light .basis-card.expand .basis-card-value {
  text-shadow: none;
}

.chart-light .basis-card.shrink .basis-card-value {
  text-shadow: none;
}

/* 响应式 */
@media (max-width: 768px) {
  .chart-topbar {
    padding: 8px 12px;
    flex-wrap: wrap;
  }

  .chart-toolbar {
    padding: 6px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .symbol-btn {
    padding: 4px 10px;
    font-size: 11px;
  }

  .chart-pane {
    flex: 1; /* 取消原本 flex: 4 的巨大权重，让出更多空间给底部 */
    min-height: 40vh;
  }

  .basis-dashboard {
    flex: 1 !important; /* 让它在手机端与K线平分秋色，获得充足高度 */
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
  }

  .basis-card {
    flex: 1; /* 让两个卡片自动平均撑满所属的面版空间，高度极其充裕 */
    width: 100%;
    height: auto;
    padding: 0 24px; /* 上下内边距设0，因卡片有 align-items: center 自然居中 */
    border-radius: 14px;
    gap: 12px;
  }

  .basis-card-label {
    font-size: 26px; /* 字体加大 */
    letter-spacing: 2px;
  }

  .basis-card-value {
    font-size: 52px; /* 核心数值更巨大 */
  }

  .basis-card-delta {
    font-size: 18px;
  }

  .chart-statusbar {
    padding: 4px 12px;
    font-size: 10px;
  }
}
