/* AI 对话面板样式 */
#ai-chat-panel {
  position: fixed;
  left: 20px;
  top: 80px;
  width: 420px;
  height: 550px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

#ai-chat-panel.collapsed {
  height: 0;
  opacity: 0;
  pointer-events: none;
  margin-bottom: -20px;
}

.ai-chat-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, #4f6ef7, #6c8cff);
  color: white;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}
  font-weight: 600;
  font-size: 15px;
}

.ai-chat-header-buttons button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.ai-chat-header-buttons button:hover {
  background: rgba(255,255,255,0.2);
}

/* Quick suggestions */
.ai-quick-suggestions {
  padding: 8px 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid #eee;
  background: #f8f9ff;
}

.ai-quick-suggestions button {
  padding: 4px 12px;
  border: 1px solid #d0d5ff;
  background: #fff;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  color: #4f6ef7;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-quick-suggestions button:hover {
  background: #4f6ef7;
  color: #fff;
  border-color: #4f6ef7;
}

/* Messages area */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.ai-message {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
}

.ai-message.user {
  align-self: flex-end;
  background: #e8f0fe;
  color: #333;
  border-bottom-right-radius: 4px;
}

.ai-message.assistant {
  align-self: flex-start;
  background: #f5f5f5;
  color: #333;
  border-bottom-left-radius: 4px;
  max-width: 95%;
}

.ai-message.error {
  align-self: center;
  background: #fff0f0;
  color: #d93025;
  font-size: 12px;
}

.ai-message.thinking {
  align-self: flex-start;
  background: transparent;
  color: #999;
  font-size: 12px;
  font-style: italic;
}

/* Markdown-like formatting inside assistant messages */
.ai-message.assistant strong,
.ai-message.assistant b {
  color: #1a73e8;
}

.ai-message.assistant code {
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

/* Table rendering */
.ai-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}

.ai-table th {
  background: #4f6ef7;
  color: white;
  padding: 6px 8px;
  text-align: left;
  font-weight: 500;
}

.ai-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #eee;
}

.ai-table tr:hover td {
  background: #f0f3ff;
}

/* Card rendering */
.ai-card {
  background: #f0f4ff;
  border: 1px solid #d0d8ff;
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

.ai-card h4 {
  margin: 0 0 8px 0;
  color: #4f6ef7;
  font-size: 14px;
}

.ai-card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ai-card-field {
  display: flex;
  flex-direction: column;
}

.ai-card-field-label {
  font-size: 11px;
  color: #888;
}

.ai-card-field-value {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

/* Chart container */
.ai-chart {
  width: 100%;
  height: 200px;
  margin: 8px 0;
}

/* Input area */
.ai-input-area {
  padding: 10px 14px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ai-input-area input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.ai-input-area input:focus {
  border-color: #4f6ef7;
}

.ai-input-area button {
  padding: 8px 16px;
  background: #4f6ef7;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.ai-input-area button:hover {
  background: #3d5ce5;
}

.ai-input-area button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Float button */
#ai-float-btn {
  position: fixed;
  left: 200px;
  top: 12px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f6ef7, #6c8cff);
  color: white;
  font-size: 24px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(79, 110, 247, 0.4);
  z-index: 99998;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ai-float-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(79, 110, 247, 0.5);
}

/* Scrollbar styling */
.ai-messages::-webkit-scrollbar {
  width: 5px;
}

.ai-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

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