/* CSS 变量定义 */
:root {
  /* 主色调 */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  
  /* 成功/错误色 */
  --success: #10b981;
  --success-light: #34d399;
  --error: #ef4444;
  --error-light: #f87171;
  
  /* 警告色 */
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  
  /* 中性色 */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* 背景色 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-accent: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  
  /* 阴影 */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* 边框半径 */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  /* 过渡动画 */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 应用主容器 */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航 */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.logo i {
  font-size: 1.5rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gray-600);
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-400);
  transition: var(--transition);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* 主内容区域 */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* 面板通用样式 */
.control-panel,
.results-panel,
.alerts-panel {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
  overflow: hidden;
  transition: var(--transition);
}

.control-panel:hover,
.results-panel:hover,
.alerts-panel:hover {
  box-shadow: var(--shadow-xl);
}

.panel-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--gray-100);
  background: var(--bg-accent);
  color: white;
}

.panel-header h1,
.panel-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-header p {
  opacity: 0.9;
  font-size: 0.925rem;
}

/* 表单样式 */
.alert-form {
  padding: 2rem;
}

.form-grid {
  display: grid;
  gap: 1.5rem;
}

.symbol-group {
  grid-column: 1 / -1;
}

.price-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.direction-group {
  grid-column: 1 / -1;
}

.form-group.submit-group {
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  .price-row {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--gray-700);
  font-size: 0.875rem;
}

.form-input {
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1.25rem;
  font-weight: 500;
  transition: var(--transition);
  background: var(--bg-primary);
  min-height: 60px;
}

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

.form-input::placeholder {
  color: var(--gray-400);
}

/* 币种选择器 */
.symbol-selector {
  position: relative;
  min-height: 60px;
}

.symbol-selector input {
  min-height: 60px;
}

.dropdown-arrow {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
  transition: var(--transition);
  font-size: 1.125rem;
}

.symbol-selector:focus-within .dropdown-arrow {
  color: var(--primary);
  transform: translateY(-50%) rotate(180deg);
}

.symbol-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  max-height: 300px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: var(--transition);
}

.symbol-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gray-500);
}

.symbol-list {
  max-height: 250px;
  overflow-y: auto;
}

.symbol-item {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--gray-50);
}

.symbol-item:hover {
  background: var(--gray-50);
}

.symbol-item.selected {
  background: var(--primary);
  color: white;
}

.symbol-info {
  display: flex;
  flex-direction: column;
}

.symbol-name {
  font-weight: 600;
  font-size: 1rem;
}

.symbol-price {
  font-size: 0.875rem;
  color: var(--gray-500);
}

.symbol-change {
  font-size: 0.875rem;
  font-weight: 500;
}

.symbol-change.positive {
  color: var(--success);
}

.symbol-change.negative {
  color: var(--error);
}

/* 价格输入组 */
.price-input-group {
  position: relative;
  min-height: 60px;
}

.price-input-group input {
  padding-right: 4rem;
}

/* 当前价格显示 */
.current-price-display {
  position: relative;
  min-height: 60px;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  display: flex;
  align-items: center;
}

.current-price-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.current-price-value.loading {
  color: var(--gray-500);
  font-style: italic;
}

.current-price-value.positive {
  color: var(--success);
}

.current-price-value.negative {
  color: var(--error);
}

.currency-suffix {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 1.125rem;
  pointer-events: none;
}

/* 方向按钮 */
.direction-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.direction-buttons input[type="radio"] {
  display: none;
}

.direction-btn {
  padding: 1.25rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  background: var(--bg-primary);
  min-height: 60px;
  justify-content: center;
}

.direction-btn:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
}

.direction-btn i {
  font-size: 1.25rem;
}

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

.short-btn {
  color: var(--error);
}

input[type="radio"]:checked + .long-btn {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

input[type="radio"]:checked + .short-btn {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* 提交按钮 */
.submit-group {
  margin-top: 0.5rem;
}

.submit-btn {
  width: 100%;
  padding: 1rem 2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.submit-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 结果面板 - 隐藏不显示 */
.results-panel {
  display: none !important;
}

.result-card {
  background: var(--gray-50);
  padding: 1.5rem;
  border-radius: var(--radius);
  text-align: center;
  transition: var(--transition);
}

.result-card:hover {
  background: var(--gray-100);
  transform: translateY(-2px);
}

.result-label {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

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

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

/* 警报列表 */
.alerts-container {
  padding: 2rem;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.alert-card {
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
  position: relative;
}

.alert-card:hover {
  border-color: var(--gray-300);
  background: var(--bg-primary);
  box-shadow: var(--shadow);
}

.alert-card.triggered {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.alert-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.alert-symbol {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
}

.alert-direction {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.alert-direction.long {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.alert-direction.short {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.alert-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.alert-detail {
  text-align: center;
}

.alert-detail-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-detail-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.alert-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.alert-action-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--gray-700);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.alert-action-btn:hover {
  background: var(--gray-50);
}

.alert-action-btn.delete {
  border-color: var(--error);
  color: var(--error);
}

.alert-action-btn.delete:hover {
  background: var(--error);
  color: white;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray-500);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--gray-400);
}

.empty-state p {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.empty-state span {
  font-size: 0.875rem;
}

/* 刷新按钮 */
.refresh-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-700);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.refresh-btn:hover {
  background: var(--gray-50);
}

/* 底部 */
.footer {
  background: var(--gray-800);
  color: var(--gray-300);
  padding: 2rem 1.5rem;
  margin-top: auto;
}

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

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

/* 通知系统 */
.notification-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.notification {
  background: var(--bg-primary);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  transform: translateX(100%);
  opacity: 0;
  transition: var(--transition);
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.success {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.notification.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.05);
}

.notification.warning {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.05);
}

/* 加载动画 - 完全隐藏 */
.loading-overlay {
  display: none !important;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

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

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

/* 动画 */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .main {
    padding: 1rem;
  }
  
  .header-content {
    padding: 1rem;
  }
  
  .form-grid {
    gap: 1rem;
  }
  
  .panel-header {
    padding: 1rem 1.5rem;
  }
  
  .alert-form,
  .alerts-container {
    padding: 1.5rem;
  }
  
  .direction-buttons {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .footer-links {
    justify-content: center;
  }
  
  .notification {
    min-width: auto;
    max-width: calc(100vw - 2rem);
  }
  
  .notification-container {
    right: 1rem;
    left: 1rem;
  }
}

@media (max-width: 480px) {
  .panel-header h1,
  .panel-header h2 {
    font-size: 1.25rem;
  }
  
  .alert-details {
    grid-template-columns: 1fr;
  }
  
  .alert-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
}
