/* ========================================
   聊天窗口样式 - Study With Miku
   半透明玻璃态设计，左下角固定定位
   ======================================== */

#chat-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 320px; /* 稍微调窄一点适配小屏 */
  max-height: 450px;
  background: rgba(28, 28, 40, 0.75); /*稍微增加透明度*/
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(57, 210, 192, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001; /* 确保在最上层 */
  font-family: 'Quicksand', "Microsoft YaHei", sans-serif;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-container.minimized {
  height: 56px; /* 固定最小化高度 */
  overflow: hidden;
}

/* 头部 */
#chat-header {
  background: linear-gradient(135deg, rgba(57, 210, 192, 0.2), rgba(138, 85, 204, 0.2));
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#chat-title {
  color: #39d2c0;
  font-size: 15px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-online-count {
  color: #ddd;
  font-size: 12px;
}

#chat-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

#chat-toggle:hover {
  background: rgba(57, 210, 192, 0.3);
}

/* 消息区域 */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* 适配Firefox滚动条 */
  scrollbar-width: thin;
  scrollbar-color: rgba(57, 210, 192, 0.4) transparent;
}

/* Chrome/Safari 滚动条 */
#chat-messages::-webkit-scrollbar {
  width: 4px;
}
#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(57, 210, 192, 0.4);
  border-radius: 4px;
}

/* 消息项 */
.chat-message {
  display: flex;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}

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

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}

.chat-message-content {
  flex: 1;
  min-width: 0;
}

.chat-message-username {
  font-size: 12px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-message-username.github { color: #39d2c0; font-weight: bold; }
.chat-message-username.guest { color: #aaa; }

.chat-message-badge {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(57, 210, 192, 0.2);
  color: #39d2c0;
  border: 1px solid rgba(57, 210, 192, 0.3);
}

.chat-message-text {
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  background: rgba(255,255,255,0.08);
  padding: 6px 10px;
  border-radius: 0 10px 10px 10px;
}

.chat-message-time {
  color: #666;
  font-size: 10px;
  margin-top: 4px;
  text-align: right;
}

/* 系统消息 */
.chat-system-message {
  text-align: center;
  color: #8a55cc;
  font-size: 12px;
  padding: 4px 0;
  opacity: 0.8;
}

/* 输入区域 */
#chat-input-area {
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-auth-prompt {
  text-align: center;
  padding: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #ccc;
}

#chat-github-login {
  background: #24292e;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 5px;
  transition: 0.2s;
}
#chat-github-login:hover { background: #444; }

#chat-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

#chat-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

#chat-user-name {
  flex: 1;
  color: #39d2c0;
  font-size: 12px;
  font-weight: bold;
}

#chat-logout {
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
#chat-logout:hover { color: #fff; border-color: #fff; }

#chat-input-wrapper {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  padding: 8px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
#chat-input::placeholder { color: rgba(255,255,255,0.3); }

#chat-send {
  background: #39d2c0;
  border: none;
  color: #000;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}
#chat-send:hover { background: #5ce0d0; }