/**
 * WebChat 自定义样式 - 根据设计图调整
 */

:root {
  --primary-color: #0A1B3F;
  --accent-color: #FFA726;
  --bg-color: #FFFAE0;
  --text-color: #0A1B3F;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius-sm: 10px;
  --radius-md: 15px;
  --radius-lg: 25px;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
}

/* 按钮样式 */
.btn {
  font-weight: 600;
  padding: 0.5rem 2rem;
  /* border-radius: var(--radius-lg); */
  transition: all 0.3s ease;
}

.btn-primary {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: var(--primary-color);
}

.btn-primary:hover {
  background-color: #FF9100;
  border-color: #FF9100;
  transform: translateY(-2px);
}

.btn-primary:active {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(0);
}

.btn-outline-primary {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.btn-outline-primary:hover {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
}

.btn-outline-primary:active {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
  transform: translateY(0);
}

/* 主页欢迎区域 */
.jumbotron {
  background-color: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 3rem;
}

.display-4 {
  color: var(--primary-color);
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.lead {
  color: var(--primary-color);
  opacity: 0.8;
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

/* 容器调整 */
#chat-container {
  margin: 0;
  padding: 1rem;
  width: 100%;
  height: 100vh;
  display: flex;
}

/* 侧边栏样式 */
.sidebar {
  background-color: white;
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), rgba(76, 201, 240, 0.05));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  height: calc(100vh - 2rem);
  margin-right: 1rem;
  border: 1px solid rgba(0,0,0,0.05);
  width: 280px;
  flex-shrink: 0;
}

.sidebar .conversations-list {
  overflow-y: auto;
  height: calc(100% - 120px);
  padding: 0.25rem;
  margin: 0 -0.5rem;
}

/* 对话列表项样式 */
.conversation-item {
  background: white;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-sm);
  /*margin-bottom: 0.75rem;*/
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.conversation-item:hover {
  transform: translateX(5px);
  border-color: var(--accent-color);
  background-color: rgba(255, 167, 38, 0.05);
}

.conversation-item.active {
  background: linear-gradient(145deg, var(--accent-color) 0%, #FF9100 100%);
  border-color: var(--accent-color);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 167, 38, 0.25);
}

.conversation-item .mb-1 {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.25rem !important;
}

.conversation-item small {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* 新对话按钮 */
#new-chat-btn {
  background: linear-gradient(145deg, var(--accent-color) 0%, #FF9100 100%);
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  box-shadow: 0 2px 4px rgba(255, 167, 38, 0.2);
}

#new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 167, 38, 0.3);
}

/* 删除按钮 */
#delete-chat-btn {
  color: #dc3545;
  border-color: #dc3545;
  background: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  /* margin-top: 1rem; */
  /* width: 100%; */
  transition: all 0.3s ease;
}

#delete-chat-btn:hover {
  background-color: #dc3545;
  color: white;
  transform: translateY(-2px);
}

/* 聊天主区域 */
.chat-main {
  background-color: white;
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), rgba(76, 201, 240, 0.05));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  height: calc(100vh - 2rem);
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0; /* 防止flex子项溢出 */
}

/* 聊天标题区域 */
.chat-header {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 0.5rem;
}

#current-chat-title {
  font-size: 1.25rem;
  color: var(--primary-color);
}

#edit-title-btn {
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: white;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}

#edit-title-btn:hover {
  background-color: var(--accent-color);
  color: white;
  transform: translateY(-2px);
}

/* 消息列表区域 */
.messages-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  /*background-color: var(--bg-color);*/
  border-radius: var(--radius-sm);
  margin: 0;
}

/* 消息样式 */
.message {
  display: flex;
  margin-bottom: 1rem;
}

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

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

.message-content {
  max-width: 85%;
  padding: 8px 12px;
  position: relative;
  line-height: 1.5;
  /* font-size: 14px; */
  background-color: transparent;
  color: #333;
  border: 1px solid #0A1B3F;
  border-radius: 8px;
}

.user-message .message-content {
  border-bottom-right-radius: 2px;
}

.assistant-message .message-content {
  border-bottom-left-radius: 2px;
}

/* 消息时间戳 */
.message-time {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

/* 代码块样式 */
.message-content pre {
  background: #f8f9fa;
  padding: 8px;
  border-radius: 4px;
  margin: 8px 0;
  overflow-x: auto;
}

.message-content code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}

/* 内联代码样式 */
.message-content :not(pre) > code {
  /* background: #f8f9fa; */
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 13px;
}

/* 打字指示器样式 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border-radius: 50%;
  display: inline-block;
  animation: typing 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* 消息发送区域优化 */
.chat-footer {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  /*background: white;*/
  /*border-radius: 0 0 var(--radius-md) var(--radius-md);*/
}

.input-group {
  background: var(--bg-color);
  border-radius: var(--radius-lg);
  padding: 0.25rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
}

.input-group .form-control {
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  background: transparent;
  line-height: normal;
  height: auto;
  display: flex;
  align-items: center;
}

.input-group .form-control:focus {
  box-shadow: none;
}

.input-group .btn {
  margin: 0.25rem;
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.5rem;
  background: linear-gradient(145deg, var(--accent-color) 0%, #FF9100 100%);
  border: none;
  color: white;
  font-weight: 500;
  min-width: 120px;
}

.input-group .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 167, 38, 0.3);
}

.input-group .btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(255, 167, 38, 0.2);
}

/* 空状态样式 */
.messages-list .text-center {
  padding: 3rem 1rem;
}

.messages-list .text-center img {
  opacity: 0.7;
  margin-bottom: 1.5rem;
}

.messages-list .text-center p {
  color: var(--primary-color);
  opacity: 0.6;
  font-size: 1.1rem;
}

/* 模态框样式 */
.modal-content {
  border-radius: var(--radius-md);
  border: none;
}

.modal-header {
  border-bottom: none;
  padding: 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: none;
  padding: 1.5rem;
}

/* 统计数字 */
.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 2rem;
  color: var(--text-color);
  opacity: 0.8;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.875rem;
}

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

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* 导航栏调整 */
.navbar {
   padding: 2px 0;
}

.navbar-brand {
  font-size: 1.4rem;
  font-weight: 600;
}

.navbar-brand i {
  font-size: 1.8rem;
}

/* 用户下拉菜单 */
.auth-user-name {
  font-weight: 500;
}

/* 侧边栏调整 */
.sidebar .d-flex.flex-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.conversations-list {
  margin-top: 10px;
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  margin-bottom: 15px;
}

.conversation-item:hover:not(.active) {
  background-color: #e9ecef;
}

/* 删除按钮容器 */
.sidebar .d-flex.justify-content-between.align-items-center.mt-3 {
  margin-top: auto !important;
  padding-top: 10px;
  border-top: 1px solid #e9ecef;
}

/* 响应式调整 */
@media (max-width: 768px) {
  #chat-container {
    flex-direction: column;
    padding: 0.5rem;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    margin-right: 0;
    margin-bottom: 1rem;
    max-height: 300px;
  }
  
  .chat-main {
    height: calc(100vh - 350px);
  }
}