/* 基础样式 */
:root {
  /* 默认主题 - 跟随系统 */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --border-color: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);

  /* 涨跌颜色 - 默认绿涨红跌 */
  --color-up: #26a69a;
  --color-down: #ef5350;
  --color-up-bg: rgba(38, 166, 154, 0.1);
  --color-down-bg: rgba(239, 83, 80, 0.1);

  /* 主题标识 */
  --theme-icon: 🌙;
}

/* 深色主题 */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1f2937;
  --text-primary: #e5e5e5;
  --text-secondary: #a0a0a0;
  --border-color: #374151;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* 浅色主题 */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --border-color: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 传统A股颜色：红涨绿跌 */
[data-color-scheme="red-green"] {
  --color-up: #ef5350;
  --color-down: #26a69a;
  --color-up-bg: rgba(239, 83, 80, 0.1);
  --color-down-bg: rgba(38, 166, 154, 0.1);
}

/* 色盲模式1：蓝/橙 */
[data-colorblind="1"] {
  --color-up: #0077bb;
  --color-down: #ee7733;
  --color-up-bg: rgba(0, 119, 187, 0.1);
  --color-down-bg: rgba(238, 119, 51, 0.1);
}

/* 色盲模式2：蓝绿/橙粉 */
[data-colorblind="2"] {
  --color-up: #009988;
  --color-down: #cc3311;
  --color-up-bg: rgba(0, 153, 136, 0.1);
  --color-down-bg: rgba(204, 51, 17, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

/* 头部导航 */
.header {
  background-color: var(--bg-card);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-up);
  background-color: var(--color-up-bg);
}

/* 主题切换按钮 */
.theme-toggle {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* 主内容区 */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  min-height: calc(100vh - 200px);
}

/* 首页 */
.hero {
  text-align: center;
  padding: 3rem 0;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

/* 功能卡片 */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--text-secondary);
}

/* 介绍部分 */
.intro {
  margin-top: 4rem;
}

.intro h2 {
  text-align: center;
  margin-bottom: 2rem;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.intro-item {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 8px;
}

.intro-item h4 {
  margin-bottom: 0.5rem;
}

.intro-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 页面标题 */
.page-title {
  text-align: center;
  margin-bottom: 2rem;
}

/* 计算器样式 */
.calculator-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.calculator-section h2 {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-up);
}

.btn {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: var(--color-up);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.9;
}

.result-box {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  color: var(--text-secondary);
}

.result-value {
  font-weight: bold;
  font-size: 1.1rem;
}

.result-value.positive {
  color: var(--color-up);
}

.result-value.negative {
  color: var(--color-down);
}

/* 图表容器 */
.chart-container {
  margin-top: 1.5rem;
  height: 300px;
}

/* 搜索框 */
.search-box {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.search-results.show {
  display: block;
}

.search-result-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

.search-result-item:hover {
  background: var(--bg-secondary);
}

.search-result-item:last-child {
  border-bottom: none;
}

/* 回测结果 */
.backtest-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

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

.summary-card .label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.summary-card .value {
  font-size: 1.5rem;
  font-weight: bold;
  margin-top: 0.5rem;
}

/* 设置页面 */
.settings-section {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.settings-section h2 {
  margin-bottom: 1.5rem;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-label {
  font-weight: 500;
}

.settings-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* 单选按钮组 */
.radio-group {
  display: flex;
  gap: 1rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.3s;
}

.radio-label:hover {
  border-color: var(--color-up);
}

.radio-label input {
  display: none;
}

.radio-label input:checked + span {
  color: var(--color-up);
}

.radio-label.selected {
  border-color: var(--color-up);
  background: var(--color-up-bg);
}

/* 关于页面 */
.about-content {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.about-content h2 {
  margin-bottom: 1rem;
}

.about-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.about-content ul {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.about-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* 页脚 */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-primary);
}

/* 响应式 */
@media (max-width: 768px) {
  .nav {
    flex-direction: column;
    gap: 1rem;
    position: relative;
  }

  .mobile-menu-btn {
    display: block;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
  }

  .nav-links {
    display: none;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
  }

  .nav-links.show {
    display: flex;
  }

  .nav-links li {
    margin: 0.25rem;
  }

  .nav-links a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

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

  .main {
    padding: 1rem;
  }

  .calculator-section,
  .settings-section,
  .about-content {
    padding: 1rem;
  }

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

  .settings-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .radio-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .radio-label {
    flex: 1;
    min-width: 80px;
    justify-content: center;
  }
}

/* Loading 状态 */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

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

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