/**
 * Theme Styles - 主题配色方案
 * 支持 5 种主题：dark（默认）、light、eye-care、dark-blue、arcade（街機）
 */

/* ==================== Dark Theme (默认) ==================== */
:root,
:root[data-theme="dark"] {
  /* 背景色 */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: rgba(110, 118, 129, 0.1);
  
  /* 文字颜色 */
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  
  /* 边框颜色 */
  --border-color: #30363d;
  --border-color-light: #21262d;
  
  /* 主题色 */
  --primary-color: #1890ff;
  --brand-primary: #58a6ff;
  --accent-primary: #58a6ff;
  --success-color: #52c41a;
  --error-color: #ff4d4f;
  --warning-color: #faad14;
  
  /* 阴影 */
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-strong: rgba(0, 0, 0, 0.5);
}

/* ==================== Light Theme ==================== */
:root[data-theme="light"] {
  --bg-primary: #F5F0E8;
  --bg-secondary: #E0DAD0;
  --bg-tertiary: #EDE8DF;
  --bg-hover: rgba(0, 0, 0, 0.05);

  --text-primary: #2D2620;
  --text-secondary: #2D2620;
  --text-muted: #5C534A;

  --border-color: #D5CFBF;
  --border-color-light: #e0dbd4;

  --primary-color: #4a9eff;
  --brand-primary: #4a9eff;
  --accent-primary: #4a9eff;
  --success-color: #22c55e;
  --error-color: #ef4444;
  --warning-color: #f59e0b;

  --shadow: rgba(0, 0, 0, 0.06);
  --shadow-strong: rgba(0, 0, 0, 0.12);
}

/* ==================== Eye-Care Theme (护眼) ==================== */
:root[data-theme="eye-care"] {
  /* 背景色 */
  --bg-primary: #f5f8f5;
  --bg-secondary: #e8f0e8;
  --bg-tertiary: #d4e5d4;
  --bg-hover: rgba(93, 155, 93, 0.1);
  
  /* 文字颜色 */
  --text-primary: #2d4a2d;
  --text-secondary: #4a6b4a;
  --text-muted: #6b8e6b;
  
  /* 边框颜色 */
  --border-color: #c0d8c0;
  --border-color-light: #d4e5d4;
  
  /* 主题色 */
  --primary-color: #5a9b5a;
  --brand-primary: #5a9b5a;
  --accent-primary: #5a9b5a;
  --success-color: #52c41a;
  --error-color: #ff4d4f;
  --warning-color: #faad14;
  
  /* 阴影 */
  --shadow: rgba(93, 155, 93, 0.1);
  --shadow-strong: rgba(93, 155, 93, 0.2);
}

/* ==================== Dark Blue Theme ==================== */
:root[data-theme="dark-blue"] {
  /* 背景色 */
  --bg-primary: #1a1d2e;
  --bg-secondary: #232640;
  --bg-tertiary: #2d3250;
  --bg-hover: rgba(107, 125, 184, 0.1);
  
  /* 文字颜色 */
  --text-primary: #e8e9f3;
  --text-secondary: #c4c6d8;
  --text-muted: #8a8ca2;
  
  /* 边框颜色 */
  --border-color: #3a3f5c;
  --border-color-light: #4a4f6c;
  
  /* 主题色 */
  --primary-color: #6b7db8;
  --brand-primary: #6b7db8;
  --accent-primary: #6b7db8;
  --success-color: #52c41a;
  --error-color: #ff4d4f;
  --warning-color: #faad14;
  
  /* 阴影 */
  --shadow: rgba(26, 29, 46, 0.3);
  --shadow-strong: rgba(26, 29, 46, 0.5);
}

/* ==================== 主题过渡动画 ==================== */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* 避免图表过渡动画 */
#chart-app,
#chart-app *,
.chart-area,
.chart-area * {
  transition: none !important;
}

/* ==================== 主题指示器 ==================== */
.theme-indicator {
  position: fixed;
  top: 60px;
  right: 20px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.theme-indicator.show {
  opacity: 1;
}

/* ==================== 主题选择器模态框 ==================== */
.theme-selector-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.theme-selector-modal.show {
  display: flex;
}

.theme-selector-content {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: 0 8px 32px var(--shadow-strong);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--border-color);
}

.theme-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.theme-selector-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.theme-option {
  padding: 16px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.theme-option:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.theme-option.active {
  border-color: var(--primary-color);
  background: var(--bg-tertiary);
}

.theme-option-preview {
  width: 100%;
  height: 60px;
  border-radius: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.theme-option[data-theme="dark"] .theme-option-preview {
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
  color: var(--text-primary, #c9d1d9);
}

.theme-option[data-theme="light"] .theme-option-preview {
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  color: #262626;
}

.theme-option[data-theme="eye-care"] .theme-option-preview {
  background: linear-gradient(135deg, #f5f8f5 0%, #e8f0e8 100%);
  color: #2d4a2d;
}

.theme-option[data-theme="dark-blue"] .theme-option-preview {
  background: linear-gradient(135deg, #1a1d2e 0%, #232640 100%);
  color: #e8e9f3;
}

.theme-option-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}


/* ==================== Arcade Theme (90年代街機霓虹風) ==================== */
:root[data-theme="arcade"] {
  /* 背景色 - 深黑底，帶微微掃描線感 */
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f0f1a;
  --bg-tertiary: #15151f;
  --bg-hover: rgba(255, 45, 120, 0.08);

  /* 文字顏色 - 霓虹白/青 */
  --text-primary: #e0e0ff;
  --text-secondary: #a0a0cc;
  --text-muted: #606088;

  /* 邊框 - 霓虹粉紫 */
  --border-color: #2a0a1f;
  --border-color-light: #1a0a15;

  /* 主題色 - 霓虹粉 */
  --primary-color: #FF2D78;
  --brand-primary: #FF2D78;
  --accent-primary: #FF2D78;
  --success-color: #00FF88;
  --error-color: #FF2D78;
  --warning-color: #FFD700;

  /* 陰影 - 霓虹光暈 */
  --shadow: rgba(255, 45, 120, 0.2);
  --shadow-strong: rgba(255, 45, 120, 0.4);

  /* 街機專屬變數 */
  --neon-pink: #FF2D78;
  --neon-cyan: #00FFFF;
  --neon-gold: #FFD700;
  --neon-green: #00FF88;
  --scanline-color: rgba(0, 0, 0, 0.15);
}

/* 街機主題 - 掃描線背景 */
:root[data-theme="arcade"] body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    var(--scanline-color) 0px,
    var(--scanline-color) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* 街機主題 - 邊框霓虹光 */
:root[data-theme="arcade"] .chart-sidebar,
:root[data-theme="arcade"] .bottom-panel,
:root[data-theme="arcade"] .order-form-container {
  border-color: var(--neon-pink) !important;
  box-shadow: 0 0 6px rgba(255, 45, 120, 0.3);
}

/* 街機主題 - 按鈕霓虹效果 */
:root[data-theme="arcade"] button:hover,
:root[data-theme="arcade"] .btn:hover {
  box-shadow: 0 0 8px var(--neon-pink), 0 0 16px rgba(255, 45, 120, 0.3);
}

/* 街機主題 - 漲（綠） */
:root[data-theme="arcade"] .price-up,
:root[data-theme="arcade"] .text-success {
  color: var(--neon-green) !important;
  text-shadow: 0 0 6px rgba(0, 255, 136, 0.5);
}

/* 街機主題 - 跌（紅/粉） */
:root[data-theme="arcade"] .price-down,
:root[data-theme="arcade"] .text-danger {
  color: var(--neon-pink) !important;
  text-shadow: 0 0 6px rgba(255, 45, 120, 0.5);
}

/* 選擇器預覽方塊 */
.theme-option[data-theme="arcade"] .theme-option-preview {
  background: linear-gradient(135deg, #0a0a0f 0%, #1a0a1f 100%);
  color: #FF2D78;
  text-shadow: 0 0 8px #FF2D78, 0 0 16px #FF2D78;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  border: 1px solid #FF2D78;
  box-shadow: 0 0 10px rgba(255, 45, 120, 0.4) inset;
}

/* ==================== Arcade Theme 強化（chart.html 專用元素）==================== */

/* Header / 頂部導航 */
:root[data-theme="arcade"] .chart-header,
:root[data-theme="arcade"] .nav-header,
:root[data-theme="arcade"] header {
  background: #0a0a0f !important;
  border-bottom: 2px solid var(--neon-pink) !important;
  box-shadow: 0 2px 12px rgba(255, 45, 120, 0.4) !important;
}

/* Sidebar */
:root[data-theme="arcade"] .chart-sidebar {
  background: #0f0f1a !important;
  border-right: 2px solid var(--neon-pink) !important;
  box-shadow: 2px 0 12px rgba(255, 45, 120, 0.2) !important;
}

/* Bottom Panel */
:root[data-theme="arcade"] .bottom-panel,
:root[data-theme="arcade"] .chart-bottom-panel {
  background: #0f0f1a !important;
  border-top: 2px solid var(--neon-pink) !important;
  box-shadow: 0 -2px 12px rgba(255, 45, 120, 0.2) !important;
}

/* Tab 選中狀態 */
:root[data-theme="arcade"] .tab-btn.active,
:root[data-theme="arcade"] .bottom-tab-btn.active,
:root[data-theme="arcade"] .filter-btn.active {
  color: var(--neon-cyan) !important;
  border-color: var(--neon-cyan) !important;
  background: rgba(0, 255, 255, 0.08) !important;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.3) !important;
}

/* 買單按鈕 */
:root[data-theme="arcade"] .btn-buy {
  background: rgba(0, 255, 136, 0.15) !important;
  border-color: #00FF88 !important;
  color: #00FF88 !important;
  text-shadow: 0 0 6px rgba(0, 255, 136, 0.6) !important;
}

/* 賣單按鈕 */
:root[data-theme="arcade"] .btn-sell {
  background: rgba(255, 45, 120, 0.15) !important;
  border-color: #FF2D78 !important;
  color: #FF2D78 !important;
  text-shadow: 0 0 6px rgba(255, 45, 120, 0.6) !important;
}

/* 輸入框 focus */
:root[data-theme="arcade"] input:focus,
:root[data-theme="arcade"] select:focus {
  border-color: var(--neon-cyan) !important;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4) !important;
  outline: none !important;
}

/* Modal */
:root[data-theme="arcade"] .modal-content,
:root[data-theme="arcade"] .panel-content {
  background: #0f0f1a !important;
  border: 2px solid var(--neon-pink) !important;
  box-shadow: 0 0 30px rgba(255, 45, 120, 0.3) !important;
}

/* 數字 - 漲價霓虹綠 */
:root[data-theme="arcade"] .text-success,
:root[data-theme="arcade"] .price-up,
:root[data-theme="arcade"] .positive {
  color: #00FF88 !important;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.6) !important;
}

/* 數字 - 跌價霓虹粉 */
:root[data-theme="arcade"] .text-danger,
:root[data-theme="arcade"] .price-down,
:root[data-theme="arcade"] .negative {
  color: #FF2D78 !important;
  text-shadow: 0 0 8px rgba(255, 45, 120, 0.6) !important;
}

/* 訂單簿 */
:root[data-theme="arcade"] .orderbook-bid-bar {
  background: rgba(0, 255, 136, 0.12) !important;
}
:root[data-theme="arcade"] .orderbook-ask-bar {
  background: rgba(255, 45, 120, 0.12) !important;
}

/* 主題指示器 */
:root[data-theme="arcade"] .theme-indicator {
  border-color: #FF2D78 !important;
  box-shadow: 0 0 10px rgba(255, 45, 120, 0.5) !important;
  color: #00FFFF !important;
  font-size: 10px !important;
}

/* ==================== Light Theme 價格顏色強化 ==================== */
:root[data-theme=light] .price,
:root[data-theme=light] .symbol-price .price {
  color: #1a1410 !important; /* 深棕黑，高對比 */
  font-weight: 600;
}

:root[data-theme=light] .symbol-name,
:root[data-theme=light] .symbol-base {
  color: #1a1410 !important;
  font-weight: 600;
}

:root[data-theme=light] .symbol-quote {
  color: #4a3f35 !important;
}
