/* ============================================================
   CryptoAI - 样式表
   ============================================================ */
:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-card: #1e2530;
  --bg-hover: #252d3a;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border-color: #30363d;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-yellow: #d29922;
  --accent-purple: #a371f7;
  --accent-orange: #db6d28;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --radius: 12px;
  --radius-sm: 8px;
}

.light-theme {
  --bg-primary: #f6f8fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --text-primary: #24292f;
  --text-secondary: #57606a;
  --text-muted: #6e7781;
  --border-color: #d0d7de;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== 顶部导航 ===== */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1em;
  white-space: nowrap;
}

.logo-icon { font-size: 1.4em; }

#main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-blue); color: #fff; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.update-time {
  color: var(--text-muted);
  font-size: 0.8em;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover { background: var(--bg-hover); }

/* ===== 布局 ===== */
#layout {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}

/* ===== 侧边栏 ===== */
#sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  height: calc(100vh - 56px);
  position: fixed;
  left: 0;
  top: 56px;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s;
}

#sidebar.collapsed { transform: translateX(-260px); }

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

.sidebar-header h3 { font-size: 0.95em; }

.sidebar-nav {
  display: none;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-nav .nav-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 0.9em;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar-nav .nav-btn:hover { background: var(--bg-hover); }
.sidebar-nav .nav-btn.active { background: var(--bg-hover); border-left-color: var(--accent-blue); color: var(--accent-blue); }
.sidebar-divider { height: 1px; background: var(--border-color); margin: 0; }
.sidebar-section-title {
  padding: 12px 16px 8px;
  font-size: 0.8em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
@media (max-width: 768px) {
  .sidebar-nav { display: flex; }
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1em;
  padding: 4px;
}

.coin-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  gap: 10px;
}

.coin-item:hover { background: var(--bg-hover); }
.coin-item.active { background: var(--bg-hover); border-left-color: var(--accent-blue); }

.coin-icon { width: 28px; height: 28px; border-radius: 50%; }

.coin-info { flex: 1; }

.coin-name {
  font-weight: 600;
  font-size: 0.9em;
}

.coin-symbol {
  color: var(--text-muted);
  font-size: 0.8em;
}

.coin-price-info { text-align: right; }

.coin-price {
  font-weight: 600;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.coin-change {
  font-size: 0.8em;
  font-weight: 600;
}

.coin-change.up { color: var(--accent-green); }
.coin-change.down { color: var(--accent-red); }

/* ===== 主内容 ===== */
#main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px;
  transition: margin-left 0.3s;
}

#sidebar.collapsed + #main-content { margin-left: 0; }

.page { display: none; }
.page.active { display: block; }

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

.page-header h2 { font-size: 1.4em; font-weight: 700; }

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

select {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  cursor: pointer;
  outline: none;
}

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.2s;
}

.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.btn-primary:hover { background: #4393e6; }

/* ===== 价格卡片 ===== */
.price-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.price-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}

.price-card .card-label {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-bottom: 8px;
}

.price-card .card-value {
  font-size: 1.5em;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.price-card .card-change {
  margin-top: 8px;
  font-size: 0.9em;
  font-weight: 600;
}

.price-card .card-change.up { color: var(--accent-green); }
.price-card .card-change.down { color: var(--accent-red); }

/* ===== 图表 ===== */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

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

.chart-header h3 { font-size: 1.1em; }

.chart-controls { display: flex; gap: 4px; }

.chart-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.chart-btn:hover { background: var(--bg-hover); }
.chart-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

.chart-container canvas {
  max-height: 400px;
}

/* ===== 市场概览 ===== */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}

.overview-card h3 {
  font-size: 1em;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

/* ===== 技术分析 ===== */
.ta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}

.ta-card.full-width { grid-column: 1 / -1; }

.ta-card h3 {
  font-size: 1em;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.ta-card canvas { max-height: 200px; }

.ta-value {
  text-align: center;
  font-size: 1.3em;
  font-weight: 700;
  margin-top: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ta-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.ta-indicator {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.ta-indicator .label {
  color: var(--text-muted);
  font-size: 0.8em;
  margin-bottom: 4px;
}

.ta-indicator .value {
  font-weight: 700;
  font-size: 1.1em;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ta-indicator .signal {
  font-size: 0.75em;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.signal-buy { background: rgba(63,185,80,0.2); color: var(--accent-green); }
.signal-sell { background: rgba(248,81,73,0.2); color: var(--accent-red); }
.signal-neutral { background: rgba(139,148,158,0.2); color: var(--text-secondary); }

/* ===== 支撑阻力 ===== */
.sr-levels { display: flex; flex-direction: column; gap: 8px; }

.sr-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.sr-item.resistance { border-left: 3px solid var(--accent-red); }
.sr-item.support { border-left: 3px solid var(--accent-green); }
.sr-item.pivot { border-left: 3px solid var(--accent-yellow); }

.sr-label { font-weight: 600; font-size: 0.9em; }
.sr-price { font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 600; }

/* ===== 恐惧贪婪指数 ===== */
.fear-greed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.fear-greed-card h3 { margin-bottom: 16px; }

.fear-gauge { max-width: 600px; margin: 0 auto; }

.gauge-bar {
  height: 20px;
  background: linear-gradient(to right, #ea3943, #ea8c00, #f5d100, #93d900, #16c784);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

.gauge-fill {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  transition: width 0.5s;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.85em;
}

.gauge-value {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== 新闻 ===== */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 16px;
}

.news-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
}

.news-card:hover { border-color: var(--accent-blue); }

.news-source {
  color: var(--accent-blue);
  font-size: 0.8em;
  font-weight: 600;
  margin-bottom: 8px;
}

.news-title {
  font-weight: 600;
  font-size: 0.95em;
  margin-bottom: 8px;
  line-height: 1.4;
}

.news-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.news-title a:hover { color: var(--accent-blue); }

.news-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.8em;
}

.news-sentiment {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 600;
}

.sentiment-positive { background: rgba(63,185,80,0.2); color: var(--accent-green); }
.sentiment-negative { background: rgba(248,81,73,0.2); color: var(--accent-red); }
.sentiment-neutral { background: rgba(139,148,158,0.2); color: var(--text-secondary); }

/* ===== AI 报告 ===== */
.signal-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.signal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.signal-card .signal-period {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-bottom: 8px;
}

.signal-card .signal-direction {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 8px;
}

.signal-card .signal-direction.bullish { color: var(--accent-green); }
.signal-card .signal-direction.bearish { color: var(--accent-red); }
.signal-card .signal-direction.neutral { color: var(--accent-yellow); }

.signal-card .signal-confidence {
  color: var(--text-secondary);
  font-size: 0.85em;
}

.signal-card .signal-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.signal-card .signal-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

.ai-report-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
}

.ai-report-content {
  line-height: 1.8;
  font-size: 0.95em;
}

.ai-report-content h3 {
  color: var(--accent-blue);
  margin: 20px 0 12px;
  font-size: 1.1em;
}

.ai-report-content h3:first-child { margin-top: 0; }

.ai-report-content p { margin-bottom: 12px; }

.ai-report-content ul, .ai-report-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.ai-report-content li { margin-bottom: 6px; }

.ai-report-content strong { color: var(--accent-blue); }

.ai-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.ai-placeholder p { margin-bottom: 8px; }

/* ===== 加载 ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.hidden { display: none; }

.loading-spinner {
  text-align: center;
  color: var(--text-primary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-260px); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0 !important; }
  .ta-grid { grid-template-columns: 1fr; }
  .signal-cards { grid-template-columns: 1fr; }
  .news-grid { grid-template-columns: 1fr; }
  #main-nav { display: none; }
  .mobile-menu-btn { display: inline-flex !important; }
}
.mobile-menu-btn { display: none; }

/* 移动端侧边栏打开时禁止背景滚动 */
#sidebar.open ~ #main-content { pointer-events: none; }
@media (max-width: 768px) {
  #sidebar.open { pointer-events: auto; }
  #sidebar.open ~ #main-content { pointer-events: none; }
  body.sidebar-open { overflow: hidden; }
}

/* ===== 打字机效果 ===== */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-blue);
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
