/* ============ Chat页面布局 ============ */
.chat-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.chat-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  background: var(--bg-secondary);
}


/* ============ 清空历史对话按钮 ============ */
.sidebar-clear-wrapper {
  padding: 4px 16px 8px;
  border-top: 1px solid var(--border);
}

.btn-clear-history {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: var(--transition);
  cursor: pointer;
}

.btn-clear-history:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(248,113,113,0.08);
}

/* ============ Sidebar ============ */
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.btn-new-chat {
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px dashed var(--accent);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
}

.btn-new-chat:hover {
  background: var(--accent);
  color: #0a0e14;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.conversation-item:hover {
  background: var(--bg-hover);
}

.conversation-item.active {
  background: var(--accent-dim);
}

.conversation-item .conv-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  color: var(--text-secondary);
}

.conversation-item.active .conv-title {
  color: var(--accent);
}

.conversation-item .conv-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--error);
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
  flex-shrink: 0;
}

.conversation-item:hover .conv-delete {
  opacity: 0.7;
}

.conversation-item .conv-delete:hover {
  opacity: 1;
  background: rgba(248,113,113,0.15);
}

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

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.user-info #sidebar-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.points-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.btn-credits {
  flex: 1;
  padding: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--border-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
}

.btn-credits:hover {
  background: var(--accent);
  color: #0a0e14;
}

.btn-logout {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(248,113,113,0.1);
}

/* ============ Input Area ============ */
.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  max-height: 120px;
  transition: border-color var(--transition);
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.btn-send {
  background: linear-gradient(135deg, var(--accent), #d4aa78);
  color: #0a0e14;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

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

.input-hint {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

#query-type-hint {
  color: var(--text-secondary);
  transition: var(--transition);
}

#query-type-hint.wcl-mode {
  color: var(--warning);
  font-weight: 600;
}

#points-display strong {
  color: var(--accent);
}

/* ============ 移动端 ============ */
@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    left: -100vw;
    z-index: 100;
    transition: left 0.3s ease;
    height: 100vh;
  }

  .chat-sidebar.open {
    left: 0;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-input-area {
    padding: 12px;
  }

  .chat-header h2 {
    font-size: 14px;
  }
}

/* Sidebar 遮罩层（移动端） */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ============ Footer 备案信息 (Fixed Bottom for SPA) ============ */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  text-align: center;
  padding: 10px 20px;
  background: rgba(15, 15, 25, 0.95);
  border-top: 1px solid #2a2a3a;
  font-size: 12px;
  color: #666;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.site-footer a {
  color: #888;
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: #ffd700;
  text-decoration: underline;
}
