/* public/style.css */
/* 高考志愿决策系统 · 前端样式 */

:root {
  --bg: #343541;
  --white: #444654;
  --text: #ececf1;
  --text-secondary: #8e8ea0;
  --primary: #e35d3b;
  --primary-light: #3e1f1a;
  --card-reach: #f87171;
  --card-match: #fbbf24;
  --card-safety: #60a5fa;
  --card-avoid: #6b7280;
  --border: #565869;
  --bubble-user: #1d1d1f;
  --bubble-ai: #444654;
  --shadow: none;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- 侧边栏 ---- */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
  transition: transform 0.3s;
}

.sidebar-header {
  margin-bottom: 20px;
}
.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.logo-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.new-chat-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: 0.2s;
}
.new-chat-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #3e1f1a;
}

/* ---- API Key 配置 ---- */
.api-key-section {
  margin: 16px 0;
  padding: 12px;
  background: #3e3f4b;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.api-key-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.api-key-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: monospace;
  background: #40414f;
  color: var(--text);
}
.api-key-input:focus {
  outline: none;
  border-color: var(--primary);
}
.api-key-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}
.api-key-hint a {
  color: var(--primary);
}

/* ---- 历史记录 ---- */
.history-section {
  margin: 12px 0;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.history-export-btn {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: 0.2s;
}
.history-export-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: #565869; border-radius: 2px; }
.history-empty {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  padding: 12px 0;
}
.history-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.15s;
  position: relative;
  border: 1px solid transparent;
}
.history-item:hover { background: #3e3f4b; }
.history-item.active {
  background: #3e1f1a;
  border-color: var(--primary);
}
.history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 20px;
}
.history-item-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.history-item-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.history-item-del:hover { background: #ef4444; color: white; }
.history-notice {
  font-size: 10px;
  color: #6b7280;
  text-align: center;
  margin-top: 8px;
  line-height: 1.4;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  text-align: center;
}
.mode-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #fef3c7;
  color: #92400e;
}
.mode-badge.online {
  background: #d1fae5;
  color: #065f46;
}
.sidebar-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

/* ---- 主聊天区 ---- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.chat-header h1 {
  font-size: 18px;
  font-weight: 700;
}
.chat-header-sub {
  font-size: 13px;
  color: var(--text-secondary);
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}

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

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}
.message.assistant {
  align-self: flex-start;
}
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--bg);
  flex-shrink: 0;
}
.message.user .message-avatar {
  background: var(--bubble-user);
}

.message-body {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  line-height: 1.7;
  box-shadow: var(--shadow);
}
.message.user .message-body {
  background: var(--bubble-user);
  color: white;
  border: none;
}

.message-text {
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- 推荐卡片 ---- */
.recommend-cards {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rec-section-title {
  font-size: 15px;
  font-weight: 700;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rec-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.rec-card {
  border-radius: 12px;
  padding: 14px 16px;
  border-left: 5px solid;
  font-size: 14px;
}
.rec-card.reach {
  background: #3e1f1a;
  border-left-color: var(--card-reach);
}
.rec-card.match {
  background: #3e3528;
  border-left-color: var(--card-match);
}
.rec-card.safety {
  background: #1e2a3a;
  border-left-color: var(--card-safety);
}
.rec-card.avoid {
  background: #3e3f4b;
  border-left-color: var(--card-avoid);
}

.rec-card .major-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.rec-card .major-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.rec-card .major-quote {
  font-size: 13px;
  color: #8e8ea0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-style: italic;
}

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

.student-form {
  max-width: 800px;
}
.form-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-group .required { color: var(--primary); }
.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #40414f;
  color: var(--text);
  transition: 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227,93,59,0.1);
}

.submit-btn {
  margin-top: 16px;
  padding: 12px 40px;
  background: var(--bubble-user);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.submit-btn:hover { opacity: 0.9; transform: scale(0.98); }
.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.form-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- 追问区 ---- */
.followup-area {
  display: flex;
  gap: 10px;
  max-width: 800px;
}
.followup-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 30px;
  font-size: 15px;
  font-family: inherit;
  transition: 0.2s;
}
.followup-input:focus {
  outline: none;
  border-color: var(--primary);
}
.send-btn {
  padding: 12px 24px;
  background: var(--bubble-user);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}
.send-btn:hover { opacity: 0.9; }

/* ---- Loading ---- */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 8px 0;
}
.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8e8ea0;
  animation: bounce 1.4s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* ---- V3: 画像进度指示器 ---- */
.profile-indicator {
  margin: 12px 0;
  padding: 10px 12px;
  background: #3e3f4b;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.profile-indicator-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.profile-bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  margin-bottom: 8px;
  overflow: hidden;
}
.profile-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #059669);
  border-radius: 3px;
  transition: width 0.5s ease;
}
.profile-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.profile-field {
  font-size: 11px;
  color: #9ca3af;
  padding: 2px 0;
}
.profile-field.filled {
  color: #059669;
  font-weight: 500;
}

/* ---- V3: 快速模式 ---- */
.quick-mode-section {
  margin: 8px 0;
}
.quick-mode-toggle {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: 0.2s;
}
.quick-mode-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.quick-mode-section .student-form {
  margin-top: 8px;
  padding: 8px 0;
}
.quick-mode-section .form-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}
.quick-mode-section .form-group input,
.quick-mode-section .form-group select {
  padding: 6px 10px;
  font-size: 12px;
}
.quick-mode-section .form-group label {
  font-size: 11px;
}
.quick-mode-section .submit-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  font-size: 13px;
}

/* ---- V3: 话题建议 Chips ---- */
.suggestions-container {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.suggestions-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}
.suggestions-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggestion-chip {
  display: inline-flex;
  flex-direction: column;
  padding: 10px 14px;
  background: #1e3a5f;
  border: 1.5px solid #2d5a8e;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 500;
  color: #7ab8f5;
  max-width: 100%;
}
.suggestion-chip:hover {
  background: #254878;
  border-color: #3d7ab8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(122,184,245,0.15);
}
.suggestion-chip .chip-desc {
  font-size: 11px;
  font-weight: 400;
  color: #6b7280;
  margin-top: 3px;
  line-height: 1.4;
}

/* ---- V3: 聊天输入行 ---- */
.chat-input-row {
  display: flex;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto;
}
.chat-input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: 30px;
  font-size: 15px;
  font-family: inherit;
  transition: 0.2s;
  background: #40414f;
  color: var(--text);
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(227,93,59,0.08);
}
.chat-input:disabled {
  background: #3e3f4b;
  color: #6e6e80;
}
.input-hint {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  margin-top: 8px;
}

/* ---- V3: 聊天状态 ---- */
.chat-header-status {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-secondary);
  background: #3e3f4b;
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ---- V3: 头像 ---- */
.avatar-img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.avatar-static {
  width: 38px;
  height: 38px;
}
.avatar-static .avatar-img {
  width: 100%;
  height: 100%;
}

/* ---- 滚动条暗色 ---- */
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: #565869; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
body::-webkit-scrollbar { width: 6px; }
body::-webkit-scrollbar-thumb { background: #565869; border-radius: 3px; }
body::-webkit-scrollbar-track { background: transparent; }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-toggle { display: block; }
  .message { max-width: 95%; }
  .form-grid { grid-template-columns: 1fr; }
  .rec-cards-row { grid-template-columns: 1fr; }
}
