/* ========================================
   聊天页样式
   ======================================== */

.chat-body {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.chat-layout {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
}

/* ========== 侧边栏 ========== */
.chat-sidebar {
  width: 280px;
  background: #FAFBFC;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sidebar-head .brand {
  gap: 8px;
}

.sidebar-head .brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
}

.sidebar-head .brand-title {
  font-size: 18px;
}

.sidebar-head .brand-sub {
  font-size: 11px;
}

.sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text-soft);
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background: var(--primary);
  color: #fff;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 10px 16px;
  background: #fff;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background: var(--primary);
  color: #fff;
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 16px;
}

.sidebar-section-title {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 8px;
}

.chat-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.chat-history-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.chat-history-item.active {
  background: rgba(21, 101, 192, 0.10);
  color: var(--primary);
  font-weight: 600;
}

.chat-history-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-nav-item:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

.sidebar-foot {
  padding: 12px 16px 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.user-plan {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.user-plan a {
  color: var(--primary);
  font-weight: 600;
}

/* ========== 主聊天区 ========== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

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

.topbar-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  transition: all 0.2s ease;
}

.topbar-icon:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

#sidebarToggle {
  display: none;
}

.chat-title-wrap {
  display: flex;
  align-items: center;
}

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

.chat-title-avatar {
  width: 36px;
  height: 36px;
  background: transparent !important;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}

.chat-title-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-title-verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

.chat-title-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.20);
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ========== 聊天内容区 ========== */
.chat-content {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* 欢迎页 */
.chat-welcome {
  max-width: 880px;
  margin: 0 auto;
  padding: 60px 24px 40px;
}

.welcome-hero {
  text-align: center;
  margin-bottom: 40px;
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  background: transparent !important;
  margin: 0 auto 20px;
  border-radius: 0;
  box-shadow: none;
  animation: float 3s ease-in-out infinite;
  object-fit: contain;
}

.welcome-hero h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.welcome-hero p {
  font-size: 15px;
  color: var(--text-soft);
}

.welcome-hero strong {
  color: var(--primary);
  font-weight: 700;
}

.welcome-capabilities {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 40px;
}

.capability {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  transition: all 0.2s ease;
}

.capability:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cap-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 12px;
}

.cap-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.cap-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.welcome-prompts {
  margin-top: 32px;
}

.prompts-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 16px;
  text-align: center;
}

.prompts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.prompt-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: all 0.2s ease;
  cursor: pointer;
}

.prompt-card:hover {
  border-color: var(--primary);
  background: var(--bg-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.prompt-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.prompt-content { flex: 1; min-width: 0; }

.prompt-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.prompt-desc {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== 消息列表 ========== */
.chat-messages {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message {
  display: flex;
  gap: 12px;
  animation: msgIn 0.3s ease;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-ai .message-avatar {
  background: transparent;
  border-radius: 0;
  overflow: visible;
}

.message-ai .message-avatar img {
  object-fit: contain;
}

.message-user .message-avatar {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}

.message-content {
  max-width: 75%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  border-top-left-radius: 4px;
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-user .message-content {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}

.message-content strong {
  font-weight: 700;
  color: var(--primary);
}

.message-user .message-content strong {
  color: #FFD54F;
}

.message-content code {
  background: rgba(21, 101, 192, 0.08);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message-ai:hover .message-actions {
  opacity: 1;
}

.msg-action {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.msg-action:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

/* 思考中 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

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

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 推荐 chips */
.msg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.msg-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(21, 101, 192, 0.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.msg-chip:hover {
  background: var(--primary);
  color: #fff;
}

/* ========== 输入区 ========== */
.chat-input-wrap {
  padding: 16px 24px 20px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-box {
  max-width: 880px;
  margin: 0 auto;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  transition: all 0.3s ease;
  overflow: hidden;
  animation: breatheGlow 3s ease-in-out infinite;
}

@keyframes breatheGlow {
  0%, 100% {
    box-shadow: 0 0 8px rgba(21, 101, 192, 0.08), 0 0 16px rgba(21, 101, 192, 0.04);
    border-color: rgba(21, 101, 192, 0.15);
  }
  50% {
    box-shadow: 0 0 20px rgba(21, 101, 192, 0.22), 0 0 40px rgba(21, 101, 192, 0.10);
    border-color: rgba(21, 101, 192, 0.35);
  }
}

.chat-input-box:focus-within {
  border-color: var(--primary);
  animation: none;
  box-shadow: 0 0 0 4px rgba(21, 101, 192, 0.12), 0 0 28px rgba(21, 101, 192, 0.22);
}

.chat-input-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 0;
}

.input-tool {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.input-tool:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

.chat-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 8px 16px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: transparent;
  max-height: 200px;
  min-height: 24px;
  font-family: inherit;
}

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

.chat-input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 8px;
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.send-btn:disabled {
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.chat-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ========== 响应式 ========== */
@media (max-width: 960px) {
  #sidebarToggle { display: flex; }
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.10);
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: flex; }
  .welcome-capabilities { grid-template-columns: repeat(2, 1fr); }
  .prompts-grid { grid-template-columns: 1fr; }
  .welcome-hero h1 { font-size: 24px; }
}

@media (max-width: 640px) {
  .chat-topbar { padding: 10px 12px; }
  .chat-content { padding: 0; }
  .chat-welcome { padding: 32px 16px; }
  .chat-messages { padding: 16px 12px 24px; }
  .message-content { max-width: 85%; }
  .chat-input-wrap { padding: 12px 12px 16px; }
}
