/* ══════════════════════════════════════════════════════════════
   AI 助手对话样式
   ══════════════════════════════════════════════════════════════ */

/* 遮罩层 */
.ai-chat-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.ai-chat-overlay.open {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 20px;
}

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

/* 聊天窗口 */
.ai-chat-window {
  width: 420px;
  max-width: 100%;
  height: 600px;
  max-height: 85vh;
  background: #1a1a2e;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 头部 */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #E8002D, #ff4d6a);
  color: #fff;
}

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

.ai-avatar {
  font-size: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-name {
  font-size: 16px;
  font-weight: 600;
}

.ai-status {
  font-size: 12px;
  opacity: 0.9;
}

.ai-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}

.ai-close:hover {
  background: rgba(255,255,255,0.3);
}

/* 消息区域 */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 欢迎页 */
.ai-welcome {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

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

.welcome-title {
  font-size: 18px;
  color: #fff;
  margin-bottom: 16px;
}

.welcome-desc {
  font-size: 14px;
  margin-bottom: 8px;
}

.welcome-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  text-align: left;
}

.welcome-list li {
  padding: 8px 0;
  font-size: 14px;
  color: #aaa;
}

.welcome-tip {
  margin-top: 24px;
  padding: 12px 16px;
  background: rgba(232, 0, 45, 0.2);
  border-radius: 8px;
  font-size: 13px;
  color: #ff8a9a;
}

/* 消息 */
.ai-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
}

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

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

.ai-message .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-message.user .avatar {
  background: #E8002D;
}

.ai-message.assistant .avatar {
  background: #667eea;
}

.ai-message .msg-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.ai-message.user .msg-content {
  background: #E8002D;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-message.assistant .msg-content {
  background: #2d2d44;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

/* 加载动画 */
.ai-loading {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.ai-loading .dot {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.ai-loading .dot:nth-child(1) { animation-delay: -0.32s; }
.ai-loading .dot:nth-child(2) { animation-delay: -0.16s; }

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

/* 错误 */
.ai-error {
  color: #ff6b6b;
  font-size: 14px;
}

/* 赛事卡片 */
.ai-race-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}

.ai-race-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
}

.race-name {
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.race-date, .race-location {
  display: inline-block;
  margin-right: 12px;
  color: #aaa;
  font-size: 12px;
}

/* 输入区域 */
.ai-chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px;
  background: #16162a;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.ai-chat-input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  background: #2d2d44;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.ai-chat-input-area input:focus {
  border-color: #E8002D;
}

.ai-chat-input-area input::placeholder {
  color: #666;
}

.ai-send-btn {
  padding: 12px 20px;
  background: linear-gradient(135deg, #E8002D, #ff4d6a);
  border: none;
  border-radius: 24px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s, opacity 0.2s;
}

.ai-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

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

.send-icon {
  font-size: 12px;
}

/* 滚动条 */
.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

/* 响应式 */
@media (max-width: 480px) {
  .ai-chat-overlay.open {
    padding: 0;
  }

  .ai-chat-window {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
