/* 现代AI对话界面样式 - 基于lesson-plans配色方案 */

/* ===== CSS变量定义 ===== */
:root {
  --color-primary: #3B82F6;
  --color-primary-dark: #1D4ED8;
  --color-secondary: #8B5CF6;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-error: #EF4444;
  --color-gray-50: #F9FAFB;
  --color-gray-100: #F3F4F6;
  --color-gray-200: #E5E7EB;
  --color-gray-300: #D1D5DB;
  --color-gray-400: #9CA3AF;
  --color-gray-500: #6B7280;
  --color-gray-600: #4B5563;
  --color-gray-700: #374151;
  --color-gray-800: #1F2937;
  --color-gray-900: #111827;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  --border-radius-2xl: 1.5rem;
  
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--color-gray-900);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== AI粒子效果容器 ===== */
.particles-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particles-left {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 100%;
}

.particles-right {
  position: absolute;
  right: 0;
  top: 0;
  width: 200px;
  height: 100%;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

/* AI粒子样式 - 使用蓝色系 */
.particle-data {
  width: 4px;
  height: 4px;
  background: linear-gradient(45deg, var(--color-primary), #60a5fa);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
  animation: floatUp 8s ease-out infinite;
}

.particle-neural {
  width: 6px;
  height: 6px;
  background: linear-gradient(45deg, var(--color-secondary), #a78bfa);
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
  animation: floatUp 10s ease-out infinite;
}

.particle-thought {
  width: 3px;
  height: 3px;
  background: linear-gradient(45deg, var(--color-success), #34d399);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.6);
  animation: floatUp 6s ease-out infinite;
}

.particle-energy {
  width: 5px;
  height: 5px;
  background: linear-gradient(45deg, var(--color-warning), #fbbf24);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  animation: floatUp 7s ease-out infinite;
}

@keyframes floatUp {
  0% {
    transform: translateY(100vh) translateX(0) scale(0) rotate(0deg);
    opacity: 0;
  }
  5% {
    opacity: 0.3;
    transform: scale(0.5);
  }
  15% {
    opacity: 0.8;
    transform: scale(1);
  }
  25% {
    transform: translateY(75vh) translateX(10px) rotate(45deg);
    opacity: 0.9;
  }
  50% {
    transform: translateY(50vh) translateX(-15px) rotate(180deg) scale(1.1);
    opacity: 1;
  }
  75% {
    transform: translateY(25vh) translateX(20px) rotate(270deg) scale(0.9);
    opacity: 0.7;
  }
  90% {
    transform: translateY(10vh) translateX(-10px) rotate(315deg) scale(0.6);
    opacity: 0.4;
  }
  100% {
    transform: translateY(-10vh) translateX(5px) rotate(360deg) scale(0);
    opacity: 0;
  }
}

/* ===== 主容器 ===== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

/* ===== 顶部导航栏 ===== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: white;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.top-nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots" patternUnits="userSpaceOnUse" width="20" height="20"><circle cx="10" cy="10" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23dots)"/></svg>') repeat;
  pointer-events: none;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
  border-radius: var(--border-radius-lg);
  font-weight: 500;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-title {
  text-align: center;
  flex: 1;
}

.nav-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.025em;
}

.nav-title p {
  font-size: 0.875rem;
  opacity: 0.9;
  font-weight: 300;
}

.nav-actions {
  display: flex;
  gap: 0.5rem;
}

.export-btn, .settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-lg);
  font-weight: 500;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.export-btn:hover, .settings-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ===== 聊天主界面 ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 对话区域 ===== */
.chat-area {
  flex: 1;
  overflow: hidden;
  background: var(--color-gray-50);
}

.chat-container {
  height: 100%;
  overflow-y: auto;
  padding: 1.5rem;
  scroll-behavior: smooth;
}

/* 欢迎消息 */
.welcome-message {
  display: flex;
  gap: 1rem;
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background: white;
  border-radius: var(--border-radius-2xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-gray-200);
}

.welcome-avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.welcome-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-gray-900);
  margin-bottom: 1rem;
}

.welcome-content p {
  color: var(--color-gray-600);
  margin-bottom: 1rem;
}

.welcome-content ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.welcome-content li {
  padding: 0.5rem 0;
  color: var(--color-gray-700);
  font-size: 0.9rem;
}

/* ===== 消息样式 ===== */
.message {
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.3s ease-out;
}

.message-content {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: 800px;
  margin: 0 auto;
}

.user-message .message-content {
  justify-content: flex-end;
}

.user-message .message-text {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  padding: 1rem 1.25rem;
  border-radius: 18px 18px 4px 18px;
  max-width: 70%;
  word-wrap: break-word;
  box-shadow: var(--shadow-md);
  position: relative;
}

.ai-message .message-content {
  justify-content: flex-start;
}

.ai-message .message-text {
  background: white;
  color: var(--color-gray-900);
  padding: 1rem 1.25rem;
  border-radius: 18px 18px 18px 4px;
  max-width: 80%;
  word-wrap: break-word;
  border: 1px solid var(--color-gray-200);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.ai-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
}

/* 复制按钮 */
.copy-message-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: var(--border-radius-sm);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition-normal);
  opacity: 0;
  transform: translateY(-2px);
}

.message-text:hover .copy-message-btn {
  opacity: 1;
  transform: translateY(0);
}

.copy-message-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

/* ===== 输入区域 ===== */
.input-area {
  background: white;
  border-top: 1px solid var(--color-gray-200);
  padding: 1.5rem;
  flex-shrink: 0;
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--color-gray-50);
  border: 2px solid var(--color-gray-200);
  border-radius: var(--border-radius-2xl);
  padding: 0.75rem;
  transition: all var(--transition-normal);
}

.input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#userInput {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 1rem;
  line-height: 1.5;
  font-family: inherit;
  color: var(--color-gray-900);
  min-height: 24px;
  max-height: 120px;
}

#userInput::placeholder {
  color: var(--color-gray-400);
}

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-gray-500);
}

.clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--color-gray-500);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-normal);
  font-size: 0.875rem;
}

.clear-btn:hover {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

/* ===== 设置面板 ===== */
.settings-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: white;
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  transition: right var(--transition-normal);
  overflow-y: auto;
}

.settings-panel.active {
  right: 0;
}

.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  backdrop-filter: blur(4px);
}

.settings-overlay.active {
  opacity: 1;
  visibility: visible;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-gray-200);
}

.settings-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-gray-900);
}

.close-btn {
  background: none;
  border: none;
  color: var(--color-gray-500);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-normal);
}

.close-btn:hover {
  color: var(--color-gray-700);
  background: var(--color-gray-200);
}

.settings-content {
  padding: 1.5rem;
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-label {
  display: block;
  font-weight: 500;
  color: var(--color-gray-700);
  margin-bottom: 0.5rem;
}

.modern-input, .modern-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--border-radius-lg);
  background-color: white;
  font-size: 0.875rem;
  transition: all var(--transition-normal);
  outline: none;
}

.modern-input:focus, .modern-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.modern-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  appearance: none;
}

/* ===== 动画效果 ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

/* ===== 加载状态 ===== */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.thinking-animation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-primary);
  font-style: italic;
}

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

.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes thinking {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* ===== 消息内容样式 ===== */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  color: var(--color-gray-900);
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
}

.message-text h1 {
  font-size: 1.3rem;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0.3rem;
}

.message-text h2 {
  font-size: 1.2rem;
  border-bottom: 1px solid var(--color-gray-300);
  padding-bottom: 0.2rem;
}

.message-text h3 {
  font-size: 1.1rem;
}

.message-text p {
  margin: 0.8rem 0;
}

.message-text ul,
.message-text ol {
  margin: 0.8rem 0;
  padding-left: 1.5rem;
}

.message-text li {
  margin: 0.3rem 0;
}

.message-text blockquote {
  border-left: 3px solid var(--color-primary);
  margin: 0.8rem 0;
  padding: 0.4rem 0.8rem;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 0 6px 6px 0;
}

.message-text code {
  background: var(--color-gray-100);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--color-error);
}

.message-text pre {
  background: var(--color-gray-900);
  color: var(--color-gray-100);
  padding: 0.8rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.8rem 0;
}

.message-text pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.message-text th,
.message-text td {
  border: 1px solid var(--color-gray-300);
  padding: 0.5rem;
  text-align: left;
}

.message-text th {
  background: var(--color-gray-50);
  font-weight: 600;
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-gray-100);
  border-radius: var(--border-radius-md);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: var(--border-radius-md);
  transition: background var(--transition-normal);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-400);
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
  .app-container {
    height: 100vh;
    width: 100%;
  }
  
  .top-nav {
    padding: 1rem;
  }
  
  .nav-title h1 {
    font-size: 1.125rem;
  }
  
  .nav-title p {
    font-size: 0.8rem;
  }
  
  .nav-actions {
    gap: 0.25rem;
  }
  
  .export-btn, .settings-btn {
    padding: 0.5rem;
    font-size: 0.875rem;
  }
  
  .export-btn span, .settings-btn span {
    display: none;
  }
  
  .chat-container {
    padding: 1rem;
  }
  
  .welcome-message {
    margin: 1rem auto;
    padding: 1.5rem;
    flex-direction: column;
    text-align: center;
  }
  
  .welcome-avatar {
    align-self: center;
  }
  
  .message-content {
    max-width: 100%;
  }
  
  .user-message .message-text,
  .ai-message .message-text {
    max-width: 85%;
  }
  
  .input-area {
    padding: 1rem;
  }
  
  .input-footer {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  
  .settings-panel {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 480px) {
  .top-nav {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .nav-title {
    order: -1;
  }
  
  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .export-btn, .settings-btn {
    flex: 1;
    justify-content: center;
  }
  
  .welcome-message {
    margin: 0.5rem auto;
    padding: 1rem;
  }
  
  .welcome-content h3 {
    font-size: 1.125rem;
  }
  
  .message-text {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }
}

/* ===== 工具类 ===== */
.hidden {
  display: none;
}

.cursor-blink {
  animation: blink 1s infinite;
  color: var(--color-primary);
  font-weight: bold;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}