/* AI Assistant - Floating Chat Widget */

#ai-assistant-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary, #58a6ff), var(--brand-primary-hover, #1f6feb));
  border: none;
  cursor: pointer;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(88, 166, 255, 0.4);
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
#ai-assistant-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(88, 166, 255, 0.6);
}

#ai-assistant-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 460px;
  max-height: 640px;
  background: var(--bg-secondary, #161b22);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9989;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}
#ai-assistant-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.ai-panel-header {
  padding: 12px 16px;
  background: var(--bg-primary, #0d1117);
  border-bottom: 1px solid var(--border-color, #30363d);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #c9d1d9);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-panel-close {
  background: none;
  border: none;
  color: var(--text-secondary, #8b949e);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.ai-panel-close:hover { color: var(--text-primary, #c9d1d9); background: var(--bg-tertiary, #21262d); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border-color, #30363d); border-radius: 2px; }

.ai-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.bot {
  background: var(--bg-tertiary, #21262d);
  color: var(--text-primary, #c9d1d9);
  align-self: flex-start;
  border-radius: 10px 10px 10px 2px;
}
.ai-msg.user {
  background: linear-gradient(135deg, #1f6feb, #388bfd);
  color: white;
  align-self: flex-end;
  border-radius: 10px 10px 2px 10px;
}
.ai-msg.bot a { color: var(--accent-primary, #58a6ff); text-decoration: none; }
.ai-msg.bot a:hover { text-decoration: underline; }

.ai-quick-btns {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border-color-light, #21262d);
}
.ai-quick-btn {
  padding: 4px 10px;
  background: var(--bg-tertiary, #21262d);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 16px;
  color: var(--text-secondary, #8b949e);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.ai-quick-btn:hover {
  background: var(--border-color, #30363d);
  color: var(--text-primary, #c9d1d9);
  border-color: var(--accent-primary, #58a6ff);
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-color, #30363d);
  background: var(--bg-primary, #0d1117);
}
.ai-input {
  flex: 1;
  background: var(--bg-tertiary, #21262d);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 8px;
  color: var(--text-primary, #c9d1d9);
  font-size: 13px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.ai-input:focus { border-color: var(--accent-primary, #58a6ff); }
.ai-input::placeholder { color: var(--text-secondary, #8b949e); }
.ai-send-btn {
  padding: 7px 14px;
  background: #1f6feb;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.ai-send-btn:hover { background: #388bfd; }

@media (max-width: 480px) {
  #ai-assistant-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 76px;
  }
}

/* 放大模式 */
#ai-assistant-panel.ai-expanded {
  width: 780px;
  max-height: 85vh;
  bottom: 20px;
  right: 20px;
}
#ai-assistant-panel.ai-expanded .ai-messages {
  min-height: 500px;
}
#ai-assistant-panel.ai-expanded .ai-msg {
  font-size: 14px;
  max-width: 78%;
}
#ai-assistant-panel.ai-expanded .ai-input {
  font-size: 14px;
}

.ai-panel-expand {
  background: none;
  border: none;
  color: var(--text-secondary, #8b949e);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 2px;
}
.ai-panel-expand:hover { color: var(--text-primary, #c9d1d9); background: var(--bg-tertiary, #21262d); }

@media (max-width: 820px) {
  #ai-assistant-panel.ai-expanded {
    width: calc(100vw - 32px);
    right: 16px;
    left: 16px;
  }
}
