/* ==================== 全局样式 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --navbar-height: 60px;
  --bg-primary: #212121;
  --bg-secondary: #2f2f2f;
  --bg-tertiary: #171717;
  --bg-message-user: #2f2f2f;
  --bg-message-assistant: #212121;
  --color-text: #ececec;
  --color-text-secondary: #b4b4b4;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-accent: #19c37d;
  --color-accent-hover: #1a9f6a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg-primary);
  color: var(--color-text);
  overflow: hidden;
}

/* ==================== 顶部导航栏 ==================== */
.navbar {
  height: var(--navbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 100;
}

.navbar-content {
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.navbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.navbar-config {
  display: flex;
  align-items: center;
}

.config-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.config-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-slider {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.range-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.range-slider::-moz-range-thumb:hover {
  transform: scale(1.1);
}

.range-value {
  min-width: 20px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-accent);
}

.navbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s;
}

.navbar-btn:hover {
  background: var(--bg-secondary);
}

/* ==================== 主容器 ==================== */
.main-container {
  height: calc(100vh - var(--navbar-height));
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* ==================== 消息容器 ==================== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
}

.messages-container::-webkit-scrollbar {
  width: 8px;
}

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

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

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== 欢迎界面 ==================== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
}

.welcome-icon {
  margin-bottom: 24px;
  animation: fadeIn 0.6s ease;
}

.welcome-title {
  font-size: 32px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
  animation: fadeIn 0.8s ease;
}

.welcome-subtitle {
  font-size: 16px;
  color: var(--color-text-secondary);
  margin-bottom: 40px;
  animation: fadeIn 1s ease;
}

.welcome-features {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeIn 1.2s ease;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  min-width: 160px;
  transition: all 0.3s;
}

.feature-item:hover {
  background: var(--bg-tertiary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature-item svg {
  color: var(--color-accent);
}

.feature-item span {
  font-size: 14px;
  color: var(--color-text);
  font-weight: 500;
}

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

/* ==================== 消息组 ==================== */
.message-group {
  padding: 28px 0;
}

.message-group--user {
  background: var(--bg-message-user);
  border-bottom: 1px solid var(--color-border);
}

.message-group--assistant {
  background: var(--bg-message-assistant);
  border-bottom: 1px solid var(--color-border);
}

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

/* ==================== 头像 ==================== */
.avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.avatar--user {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.avatar--assistant {
  background: var(--color-accent);
}

/* ==================== 消息内容 ==================== */
.message-body {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.75;
  word-wrap: break-word;
}

/* 思考块 */
.think-block {
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.think-block summary {
  list-style: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.think-block summary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.think-block summary::-webkit-details-marker {
  display: none;
}

.think-block summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.2s;
}

.think-block[open] summary::before {
  transform: rotate(90deg);
}

.think-content {
  padding: 12px 14px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.2);
}

/* ==================== Markdown 样式 ==================== */
.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4 {
  margin: 1.5em 0 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

.message-body h1:first-child,
.message-body h2:first-child,
.message-body h3:first-child,
.message-body h4:first-child {
  margin-top: 0;
}

.message-body h1 { font-size: 2em; }
.message-body h2 { font-size: 1.5em; }
.message-body h3 { font-size: 1.25em; }
.message-body h4 { font-size: 1.1em; }

.message-body p {
  margin: 0.8em 0;
}

.message-body p:first-child {
  margin-top: 0;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body code {
  background: rgba(255, 255, 255, 0.1);
  color: #e4e4e7;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Courier New', monospace;
}

.message-body pre {
  background: #000;
  border-radius: 8px;
  padding: 16px;
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--color-border);
}

.message-body pre code {
  background: transparent;
  padding: 0;
  color: #d4d4d4;
  font-size: 14px;
  line-height: 1.6;
}

.message-body ul,
.message-body ol {
  margin: 0.8em 0;
  padding-left: 2em;
}

.message-body li {
  margin: 0.4em 0;
}

.message-body blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 3px solid var(--color-accent);
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
  border-radius: 8px;
  overflow: hidden;
}

.message-body th,
.message-body td {
  border: 1px solid var(--color-border);
  padding: 10px 14px;
  text-align: left;
}

.message-body th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.message-body a {
  color: var(--color-accent);
  text-decoration: underline;
  transition: color 0.2s;
}

.message-body a:hover {
  color: var(--color-accent-hover);
  text-decoration: none;
}

/* ==================== 底部输入区域 ==================== */
.input-area {
  flex-shrink: 0;
  background: var(--bg-primary);
  padding: 16px 0 24px;
  border-top: 1px solid var(--color-border);
}

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

.input-form {
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(25, 195, 125, 0.2);
}

.input-wrapper textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

.input-wrapper textarea::placeholder {
  color: var(--color-text-secondary);
}

.input-wrapper textarea::-webkit-scrollbar {
  width: 6px;
}

.input-wrapper textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.btn-send,
.btn-stop {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-send {
  background: var(--color-accent);
  color: #fff;
}

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

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.1);
}

.btn-stop {
  background: #ef4444;
  color: #fff;
}

.btn-stop:hover {
  background: #dc2626;
  transform: scale(1.05);
}

.input-footer {
  margin-top: 12px;
  text-align: center;
}

.footer-text {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  .navbar-content {
    padding: 0 16px;
  }

  .navbar-title {
    font-size: 16px;
  }

  .navbar-controls {
    gap: 12px;
  }

  .config-name {
    display: none;
  }

  .range-slider {
    width: 80px;
  }

  .message-content {
    padding: 0 16px;
    gap: 16px;
  }

  .input-container {
    padding: 0 16px;
  }

  .welcome-features {
    flex-direction: column;
    gap: 16px;
    max-width: 300px;
  }

  .feature-item {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .navbar-content {
    padding: 0 12px;
  }

  .navbar-controls {
    gap: 8px;
  }

  .navbar-config {
    gap: 8px;
  }

  .config-control {
    gap: 6px;
  }

  .range-slider {
    width: 60px;
  }

  .navbar-btn {
    width: 32px;
    height: 32px;
  }

  .navbar-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ==================== 加载动画 ==================== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ==================== 复选框开关样式 ==================== */
.checkbox-toggle {
  appearance: none;
  width: 40px;
  height: 22px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.3s;
}

.checkbox-toggle::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.checkbox-toggle:checked {
  background: var(--color-accent);
}

.checkbox-toggle:checked::before {
  transform: translateX(18px);
}

/* ==================== 多选下拉菜单样式 ==================== */
.multi-select-dropdown {
  position: relative;
}

.dropdown-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 100px;
}

.dropdown-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--color-accent);
}

.dropdown-button svg {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.multi-select-dropdown.active .dropdown-button svg {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  min-width: 180px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.multi-select-dropdown.active .dropdown-menu {
  display: block;
  animation: dropdown-fade-in 0.2s ease;
}

@keyframes dropdown-fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu::-webkit-scrollbar {
  width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
  background: transparent;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dropdown-item input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.dropdown-item input[type="checkbox"]:checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.dropdown-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.dropdown-item span {
  font-size: 13px;
  color: var(--color-text);
}

/* ==================== 响应式（下拉菜单） ==================== */
@media (max-width: 768px) {
  .dropdown-button {
    min-width: 80px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .dropdown-menu {
    min-width: 150px;
  }
}
