/* DCA Buddy - 全局样式 */

:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 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-color);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部 */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary-color);
  text-decoration: none;
}

nav a {
  margin-left: 20px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.3s;
}

nav a:hover {
  color: var(--primary-color);
}

/* 按钮 */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 卡片 */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 16px;
}

/* 表单 */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  background: white;
  cursor: pointer;
}

/* 加载状态 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* Alert */
.alert {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Streak 徽章 */
.streak-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  border-radius: 20px;
  font-weight: bold;
  font-size: 20px;
}

.streak-icon {
  margin-right: 8px;
  font-size: 24px;
}

/* 计划列表 */
.plan-item {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s;
}

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

.plan-info h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.plan-details {
  display: flex;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.plan-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background: #d1fae5;
  color: #065f46;
}

.status-paused {
  background: #fef3c7;
  color: #92400e;
}

.status-missed {
  background: #fee2e2;
  color: #991b1b;
}

/* 执行页面 */
.quote-display {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 30px;
}

.quote-amount {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 8px;
}

.quote-label {
  font-size: 18px;
  opacity: 0.9;
}

.quote-details {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.quote-detail-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 16px;
  border-radius: 8px;
}

/* 页面特定样式 */
.hero {
  text-align: center;
  padding: 80px 0;
}

.hero h1 {
  font-size: 48px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
  margin: 60px 0;
}

.feature-item {
  text-align: center;
  padding: 30px;
}

.feature-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.feature-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 8px;
}

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

/* Footer */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 40px 0;
  margin-top: 80px;
  text-align: center;
  color: var(--text-secondary);
}

/* 响应式 */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 36px;
  }

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

  .plan-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .quote-amount {
    font-size: 36px;
  }
}

/* ============================================
   移动端优化样式 (P3-2)
   ============================================ */

/* 超小屏幕 (手机竖屏) */
@media (max-width: 480px) {
  /* 容器优化 */
  .container {
    padding: 0 16px;
  }

  /* 头部导航优化 */
  header {
    padding: 12px 0;
  }

  header .container {
    flex-wrap: wrap;
    gap: 12px;
  }

  nav {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  nav a {
    margin: 0;
    font-size: 14px;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 6px;
  }

  .logo {
    font-size: 20px;
  }

  /* 按钮优化 - 更大的触摸区域 */
  .btn {
    padding: 14px 20px;
    font-size: 16px;
    width: 100%;
    margin-bottom: 12px;
  }

  .btn-outline,
  .btn-primary,
  .btn-success {
    width: auto;
  }

  /* 表单优化 */
  .form-input,
  .form-select {
    padding: 14px;
    font-size: 16px; /* 防止 iOS 自动缩放 */
  }

  /* 统计卡片 - 单列布局 */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 28px;
  }

  /* 计划卡片优化 */
  .plan-item {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .plan-info h3 {
    font-size: 16px;
  }

  .plan-details {
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
  }

  /* Streak 徽章 */
  .streak-badge {
    font-size: 16px;
    padding: 6px 12px;
  }

  .streak-icon {
    font-size: 20px;
  }

  /* Hero 区域 */
  .hero {
    padding: 40px 0;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero p {
    font-size: 16px;
  }

  /* 执行页面 */
  .quote-display {
    padding: 24px 16px;
  }

  .quote-amount {
    font-size: 32px;
  }

  .quote-label {
    font-size: 16px;
  }

  .quote-details {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 卡片 */
  .card {
    padding: 16px;
    border-radius: 8px;
  }

  .card-title {
    font-size: 18px;
  }

  /* 功能网格 */
  .features {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .feature-item {
    padding: 20px;
  }

  /* 表格 - 水平滚动 */
  .execution-table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .execution-table th,
  .execution-table td {
    padding: 8px 12px;
  }

  /* 筛选器 */
  .filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }
}

/* 小屏幕 (手机横屏) */
@media (min-width: 481px) and (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 32px;
  }

  .plan-item {
    flex-direction: column;
    align-items: stretch;
  }
}

/* 平板设备 */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  /* 增大可点击区域 */
  .btn,
  button,
  a {
    min-height: 44px;
    min-width: 44px;
  }

  /* 优化按钮间距 */
  .btn {
    margin-bottom: 12px;
  }

  /* 表单元素优化 */
  input,
  select,
  textarea {
    min-height: 44px;
  }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
  header {
    padding: 8px 0;
  }

  .hero {
    padding: 20px 0;
  }

  .hero h1 {
    font-size: 24px;
  }
}

/* iOS Safari 特定优化 */
@supports (-webkit-touch-callout: none) {
  /* 防止 iOS 双击缩放 */
  .btn {
    touch-action: manipulation;
  }

  /* 优化输入框 */
  .form-input {
    font-size: 16px;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a202c;
    --card-bg: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --border-color: #4a5568;
  }

  .alert-success {
    background: #064e3b;
    color: #d1fae5;
    border-color: #059669;
  }

  .alert-error {
    background: #7f1d1d;
    color: #fee2e2;
    border-color: #dc2626;
  }
}

/* 减少动画（用户偏好设置） */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }

  .card {
    border: 2px solid var(--border-color);
  }
}
