/* ========== 基础变量 ========== */
:root {
  --bg-primary: #191d3e;
  --bg-secondary: #2a2f52;
  --accent: #407b8b;
  --accent-light: #65a7b5;
  --text-primary: #cad9db;
  --text-secondary: #8d9ab0;
  --border-color: rgba(101, 167, 181, 0.3);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 16rpx;
  --radius-lg: 20rpx;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* ========== 布局 ========== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  margin: 0 auto;
}

/* ========== 顶部导航 ========== */
.header {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-img {
  width: 36px;
  height: 36px;
}

.logo-text {
  font-size: 20px;
  font-weight: bold;
  color: #ffffff;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.nav-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ========== 主内容区 ========== */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page {
  display: none;
  flex: 1;
  overflow: hidden;
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* ========== 聊天页面 ========== */
.page-chat {
  background: var(--bg-primary);
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========== 消息样式 ========== */
.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.message-ai {
  align-self: flex-start;
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 15px;
}

.bubble-ai {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}

.bubble-user {
  background: var(--accent);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.bubble p {
  margin-bottom: 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 12px;
}

.typing span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ========== 标的识别提示 ========== */
.watch-tip {
  padding: 0 20px 10px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.watch-tip-content {
  background: rgba(42, 47, 82, 0.98);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-align: center;
}

.watch-tip-text {
  color: var(--text-primary);
  margin-bottom: 12px;
  font-size: 14px;
}

.watch-tip-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ========== 输入区 ========== */
.input-area {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.input-field {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}

.input-field::placeholder {
  color: var(--text-secondary);
}

.input-field:focus {
  border-color: var(--accent);
}

/* ========== 按钮 ========== */
.btn {
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-light);
}

.btn-secondary {
  background: rgba(101, 167, 181, 0.2);
  color: var(--accent-light);
}

.btn-secondary:hover {
  background: rgba(101, 167, 181, 0.3);
}

.btn-send {
  padding: 12px 24px;
  background: var(--accent);
  color: #ffffff;
  font-weight: bold;
}

.btn-send:hover {
  background: var(--accent-light);
}

.btn-send:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
}

/* ========== 关注列表页面 ========== */
.page-watchlist,
.page-history {
  background: var(--bg-primary);
  padding: 20px;
  overflow-y: auto;
}

.watchlist-container,
.history-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 28px;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.watch-empty,
.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.watch-empty p,
.history-empty p {
  margin-bottom: 8px;
}

.hint {
  font-size: 13px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.watch-list,
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.watch-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
}

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

.watch-name {
  font-weight: bold;
  color: var(--text-primary);
}

.watch-code {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
}

.watch-delete {
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
}

.watch-delete:hover {
  background: rgba(239, 68, 68, 0.3);
}

.watch-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.watch-price {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-primary);
}

.watch-change {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
}

.watch-change.up {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.watch-change.down {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.watch-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ========== 历史记录 ========== */
.history-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item-title {
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.history-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  
  .nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .nav-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .message {
    max-width: 90%;
  }
  
  .input-area {
    padding: 12px 16px;
  }
  
  .page-watchlist,
  .page-history {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .logo-text {
    font-size: 18px;
  }
  
  .avatar {
    width: 32px;
    height: 32px;
  }
  
  .bubble {
    font-size: 14px;
    padding: 10px 14px;
  }
  
  .btn-send {
    padding: 10px 16px;
  }
}
