/* ========================================
   店赢OS AI透视 - 深色主题样式
   ======================================== */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #141420;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222238;
  --bg-input: #0d0d14;
  
  --accent-primary: #5e6ad2;
  --accent-primary-glow: rgba(94, 106, 210, 0.3);
  --accent-secondary: #00b8cc;
  --accent-secondary-glow: rgba(0, 184, 204, 0.3);
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --text-primary: #f0f0f5;
  --text-secondary: #9090a0;
  --text-muted: #606070;
  
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(94, 106, 210, 0.4);
  
  --font-sans: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-glow: 0 0 40px rgba(94, 106, 210, 0.15);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ========================================
   基础重置
   ======================================== */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }

/* ========================================
   主容器布局
   ======================================== */

.ai-demo-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========================================
   左侧对话区域
   ======================================== */

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  max-width: 55%;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-title-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.chat-title-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.chat-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(90deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 角色切换器 */
.role-switcher {
  display: flex;
  gap: 6px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-md);
}

.role-btn {
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
  white-space: nowrap;
}

.role-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.role-btn.active {
  background: var(--accent-primary);
  color: white;
  font-weight: 500;
  box-shadow: 0 2px 12px var(--accent-primary-glow);
}

/* 对话区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

/* 欢迎消息 */
.welcome-card {
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.5s ease;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px var(--accent-primary-glow);
  animation: pulse 2s ease-in-out infinite;
}

.welcome-icon svg {
  width: 36px;
  height: 36px;
  color: white;
}

.welcome-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--text-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* 预设问题按钮 */
.preset-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.preset-btn {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.preset-btn svg {
  width: 16px;
  height: 16px;
  color: var(--accent-secondary);
}

/* 用户消息 */
.user-message {
  display: flex;
  justify-content: flex-end;
  animation: slideInRight 0.3s ease;
}

.user-message-bubble {
  max-width: 85%;
  background: linear-gradient(135deg, var(--accent-primary), #4a5ab8);
  color: white;
  padding: 14px 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
  font-size: 0.95rem;
  box-shadow: 0 4px 20px var(--accent-primary-glow);
}

/* AI消息 */
.ai-message {
  display: flex;
  gap: 12px;
  animation: slideInLeft 0.4s ease;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-avatar svg {
  width: 18px;
  height: 18px;
  color: white;
}

.ai-message-content {
  flex: 1;
  max-width: 85%;
}

.ai-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 6px;
  padding: 16px 20px;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* AI思考过程 */
.ai-thinking {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.thinking-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 6px 0;
  animation: fadeInUp 0.3s ease forwards;
  opacity: 0;
}

.thinking-step:nth-child(1) { animation-delay: 0s; }
.thinking-step:nth-child(2) { animation-delay: 0.3s; }
.thinking-step:nth-child(3) { animation-delay: 0.6s; }
.thinking-step:nth-child(4) { animation-delay: 0.9s; }

.thinking-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thinking-icon.searching {
  animation: spin 1s linear infinite;
}

.thinking-icon.analyzing {
  animation: bounce 0.6s ease infinite;
}

.thinking-icon.generating {
  animation: pulse 1s ease-in-out infinite;
}

.thinking-dots {
  display: flex;
  gap: 3px;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  background: var(--accent-secondary);
  border-radius: 50%;
  animation: dotBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

/* 分析卡片 */
.analysis-card {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.analysis-card-header {
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--bg-card), var(--bg-secondary));
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.9rem;
}

.analysis-card-header svg {
  width: 18px;
  height: 18px;
  color: var(--accent-primary);
}

.analysis-card-content {
  padding: 16px;
}

/* 数据表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: var(--bg-card);
}

.data-table .trend-up {
  color: var(--accent-success);
}

.data-table .trend-down {
  color: var(--accent-danger);
}

.data-table .highlight {
  background: rgba(94, 106, 210, 0.1);
  font-weight: 500;
}

/* 关键指标 */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-item {
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.metric-value.positive { color: var(--accent-success); }
.metric-value.negative { color: var(--accent-danger); }
.metric-value.neutral { color: var(--accent-secondary); }

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.metric-change {
  font-size: 0.75rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.metric-change.up { color: var(--accent-success); }
.metric-change.down { color: var(--accent-danger); }

/* 建议列表 */
.recommendation-list {
  list-style: none;
}

.recommendation-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.recommendation-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.recommendation-icon.high { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); }
.recommendation-icon.medium { background: rgba(245, 158, 11, 0.15); color: var(--accent-warning); }
.recommendation-icon.low { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); }

.recommendation-icon svg {
  width: 16px;
  height: 16px;
}

.recommendation-content h4 {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.recommendation-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* 图表容器 */
.chart-container {
  margin-top: 12px;
  height: 200px;
  position: relative;
}

.chart-container canvas {
  max-height: 100%;
}

/* 行动按钮 */
.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

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

.action-btn.primary:hover {
  background: #4a5ab8;
  box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.action-btn.secondary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.action-btn.secondary:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

/* 输入区域 */
.chat-input-area {
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  transition: all 0.25s ease;
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  min-height: 24px;
  max-height: 120px;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  background: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #4a5ab8;
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--bg-card);
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ========================================
   右侧数据面板
   ======================================== */

.data-panel {
  width: 45%;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-secondary);
}

.panel-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.panel-tab {
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.panel-tab:hover {
  color: var(--text-secondary);
}

.panel-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.panel-content::-webkit-scrollbar {
  width: 6px;
}

.panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

/* 数据卡片 */
.data-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.data-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
}

.data-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.data-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.9rem;
}

.data-card-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent-primary);
}

.data-card-badge {
  font-size: 0.7rem;
  padding: 4px 8px;
  background: rgba(94, 106, 210, 0.15);
  color: var(--accent-primary);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* 图表区域 */
.chart-wrapper {
  height: 180px;
  position: relative;
}

.chart-wrapper canvas {
  max-height: 100%;
}

/* 实时指示器 */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--accent-success);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-success);
  border-radius: 50%;
  animation: livePulse 2s ease-in-out infinite;
}

/* 数据网格 */
.data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.data-grid-item {
  background: var(--bg-secondary);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.data-grid-item .value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.data-grid-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.data-grid-item .change {
  font-size: 0.75rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.data-grid-item .change.up { color: var(--accent-success); }
.data-grid-item .change.down { color: var(--accent-danger); }

/* 进度条 */
.progress-list {
  margin-top: 12px;
}

.progress-item {
  margin-bottom: 14px;
}

.progress-item:last-child {
  margin-bottom: 0;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

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

.progress-value {
  color: var(--text-primary);
  font-weight: 500;
  font-family: var(--font-mono);
}

.progress-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease-out;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

/* 预警列表 */
.alert-list {
  margin-top: 12px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.alert-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.alert-icon.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

.alert-icon.info {
  background: rgba(94, 106, 210, 0.15);
  color: var(--accent-primary);
}

.alert-icon svg {
  width: 14px;
  height: 14px;
}

.alert-content {
  flex: 1;
}

.alert-content .title {
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.alert-content .desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ========================================
   动画
   ======================================== */

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

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

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 1024px) {
  .ai-demo-container {
    flex-direction: column;
  }
  
  .chat-section {
    max-width: 100%;
    height: 60vh;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  
  .data-panel {
    width: 100%;
    height: 40vh;
  }
  
  .role-switcher {
    display: none;
  }
  
  .welcome-card {
    padding: 24px 16px;
  }
  
  .preset-questions {
    flex-direction: column;
  }
  
  .preset-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .chat-header {
    padding: 16px;
  }
  
  .chat-messages {
    padding: 16px;
  }
  
  .chat-input-area {
    padding: 16px;
  }
  
  .panel-header {
    padding: 16px;
  }
  
  .panel-content {
    padding: 16px;
  }
  
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .data-grid {
    grid-template-columns: 1fr;
  }
  
  .welcome-icon {
    width: 60px;
    height: 60px;
  }
  
  .welcome-card h2 {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .panel-tabs {
    display: none;
  }
  
  .data-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .chart-wrapper {
    height: 150px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   工具提示
   ======================================== */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.tooltip:hover::after {
  opacity: 1;
}
