/* ========== 基础变量 ========== */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #111128;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --accent-blue: #00d4ff;
  --accent-cyan: #0ff;
  --accent-purple: #7b68ee;
  --accent-green: #00ff88;
  --accent-red: #ff4757;
  --border-color: #2a2a4a;
  --glow-blue: 0 0 10px rgba(0, 212, 255, 0.3);
  --glow-cyan: 0 0 15px rgba(0, 255, 255, 0.2);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.3s ease;
}

/* ========== 全局样式 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

/* ========== 顶部导航 ========== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  color: var(--accent-blue);
  text-shadow: var(--glow-blue);
}

.logo h1 {
  font-size: 18px;
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
}

.subtitle-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(123, 104, 238, 0.1));
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 12px;
  font-size: 11px;
  color: var(--accent-cyan);
  font-weight: 500;
}

.header-right {
  display: flex;
  gap: 10px;
}

/* ========== 按钮样式 ========== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--glow-blue);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  color: var(--bg-primary);
}

.btn-accent:hover {
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: white;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

.btn-send {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: var(--bg-primary);
  font-weight: 600;
  padding: 12px 24px;
}

.btn-send:hover {
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--accent-blue);
}

/* ========== 常见问题侧边栏 ========== */
.faq-sidebar {
  position: fixed;
  top: 60px;
  right: -320px;
  width: 300px;
  height: calc(100% - 60px);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 90;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.faq-sidebar.open {
  right: 0;
}

.faq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.faq-header h3 {
  font-size: 15px;
  color: var(--accent-blue);
}

.faq-list {
  list-style: none;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.faq-item {
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.faq-item:hover {
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
  transform: translateX(-4px);
}

.faq-icon {
  font-size: 18px;
}

.faq-item span:last-child {
  font-size: 13px;
  line-height: 1.4;
}

/* ========== 主聊天区域 ========== */
.chat-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 滚动背景文字 - 增强效果 */
.scroll-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  /* 添加渐变遮罩，让文字有淡入淡出效果 */
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}

.scroll-text-track {
  animation: scrollUp 50s linear infinite;
  padding: 20px 40px;
}

.scroll-line {
  font-size: 17px;
  color: rgba(0, 212, 255, 0.12);
  padding: 20px 0;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
  transition: all 0.3s ease;
}

/* 奇数行：青色光晕效果 */
.scroll-line:nth-child(odd) {
  color: rgba(0, 255, 255, 0.10);
  transform: translateX(40px);
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.4), 0 0 20px rgba(0, 255, 255, 0.2);
  animation: glow-pulse 4s ease-in-out infinite;
}

/* 3的倍数行：紫色渐变效果 */
.scroll-line:nth-child(3n) {
  color: rgba(123, 104, 238, 0.10);
  font-size: 19px;
  transform: translateX(-30px);
  text-shadow: 0 0 10px rgba(123, 104, 238, 0.4);
  background: linear-gradient(90deg, rgba(123, 104, 238, 0.1), rgba(0, 212, 255, 0.1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 5的倍数行：绿色强调 */
.scroll-line:nth-child(5n) {
  color: rgba(0, 255, 136, 0.12);
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

/* 发光脉冲动画 */
@keyframes glow-pulse {
  0%, 100% {
    opacity: 0.8;
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.4), 0 0 20px rgba(0, 255, 255, 0.2);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 18px rgba(0, 255, 255, 0.6), 0 0 30px rgba(0, 255, 255, 0.3);
  }
}

/* 向上滚动动画 */
@keyframes scrollUp {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

/* 鼠标悬停时暂停滚动（可选） */
.chat-container:hover .scroll-text-track {
  animation-play-state: paused;
}

/* 消息列表 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  z-index: 2;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

/* 欢迎消息 */
.welcome-message {
  text-align: center;
  padding: 60px 20px;
  max-width: 500px;
  margin: 0 auto;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.welcome-message h2 {
  font-size: 22px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-message p {
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-size: 14px;
}

.welcome-hint {
  margin-top: 16px !important;
  font-size: 13px !important;
  color: var(--text-muted) !important;
}

.welcome-tips {
  margin-top: 24px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius);
  display: inline-block;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
}

.welcome-tips strong {
  color: var(--accent-blue);
}

/* ========== 信任徽章 - 著作展示 ========== */
.trust-badge {
  margin-top: 28px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(26, 26, 46, 0.8), rgba(22, 33, 62, 0.8));
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: var(--radius-lg);
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(0, 212, 255, 0.1);
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.trust-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 15px;
  color: var(--accent-cyan);
}

.trust-icon {
  font-size: 20px;
}

.trust-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px !important;
  line-height: 1.5;
}

.book-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.book-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(0, 212, 255, 0.05);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-blue);
  transition: var(--transition);
  font-size: 13px;
  color: var(--text-primary);
}

.book-list li:hover {
  background: rgba(0, 212, 255, 0.1);
  border-left-color: var(--accent-cyan);
  transform: translateX(4px);
}

.book-icon {
  font-size: 14px;
  color: var(--accent-cyan);
}

.trust-footer {
  margin-top: 14px !important;
  font-size: 12px !important;
  color: var(--text-muted) !important;
  font-style: italic;
  border-top: 1px dashed rgba(0, 212, 255, 0.2);
  padding-top: 10px;
}

/* 消息气泡 */
.message {
  display: flex;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  margin-left: 10px;
  order: 2;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
  margin-right: 10px;
}

.message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  word-wrap: break-word;
}

.message.user .message-content {
  background: linear-gradient(135deg, #1e3a5f, #1a2a4a);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-top-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  color: var(--accent-cyan);
}

.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-content li {
  margin-bottom: 4px;
}

/* 正在思考动画 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-blue);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.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(-8px);
    opacity: 1;
  }
}

/* ========== 底部输入区 ========== */
.input-area {
  padding: 12px 20px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 10;
}

.input-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#user-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  transition: var(--transition);
}

#user-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
}

#user-input::placeholder {
  color: var(--text-muted);
}

/* ========== 模态框 ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), var(--glow-cyan);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 18px;
  color: var(--accent-blue);
}

/* 表单样式 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: var(--glow-blue);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.form-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.form-success {
  color: var(--accent-green);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 10px;
    padding: 10px 16px;
  }

  .header-left {
    flex-direction: column;
    gap: 4px;
  }

  .subtitle {
    border-left: none;
    padding-left: 0;
  }

  .header-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .faq-sidebar {
    top: 100px;
    width: 100%;
    right: -100%;
  }

  .message-content {
    max-width: 85%;
  }

  .welcome-message {
    padding: 30px 16px;
  }

  .input-area {
    padding: 10px 16px 14px;
  }

  .btn {
    font-size: 12px;
    padding: 6px 12px;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 15px;
  }

  .message-content {
    max-width: 90%;
    font-size: 13px;
  }

  .input-actions {
    flex-wrap: wrap;
  }
}
