/* ============================================
   AI Chat Styles
   ============================================ */

/* ---- AI Message Container ---- */
.message.ai {
  align-self: flex-start;
  align-items: flex-start;
  max-width: 80%;
}

.message.ai .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border-radius: 4px;
}

/* ---- Thinking Message ---- */
.ai-thinking-message {
  background: var(--bubble-thinking-bg) !important;
  border: 1px solid var(--color-gray-200) !important;
  color: var(--bubble-thinking-text) !important;
  font-style: italic;
  min-width: 180px;
}

.ai-thinking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-thinking-indicator {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-gray-600);
}

.ai-thinking-indicator::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  margin-left: 4px;
  animation: aiThinkingPulse 1.5s infinite;
}

.ai-thinking-toggle {
  padding: 4px;
  border-radius: 4px;
  color: var(--color-gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-thinking-toggle:active {
  background: rgba(0, 0, 0, 0.06);
}

.ai-thinking-content {
  overflow: hidden;
  transition: max-height 300ms ease, opacity 300ms ease;
}

.ai-thinking-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.ai-thinking-content.expanded {
  max-height: 300px;
  opacity: 1;
  overflow-y: auto;
}

.thinking-text {
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- AI Response Message ---- */
.ai-response-message {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.ai-response-header {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-response-indicator {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
}

/* ---- AI Response Text ---- */
.ai-response-message .text-message {
  color: #ffffff !important;
}

.ai-response-message .text-message.markdown-rendered {
  padding-right: 24px !important;
}

.ai-response-message .text-message.markdown-rendered h1,
.ai-response-message .text-message.markdown-rendered h2,
.ai-response-message .text-message.markdown-rendered h3,
.ai-response-message .text-message.markdown-rendered h4,
.ai-response-message .text-message.markdown-rendered h5,
.ai-response-message .text-message.markdown-rendered h6 {
  color: #ffffff;
}

.ai-response-message .text-message.markdown-rendered blockquote {
  border-left-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.ai-response-message .text-message.markdown-rendered code {
  background: rgba(255, 255, 255, 0.12);
  color: #f0f0f0;
}

.ai-response-message .text-message.markdown-rendered pre {
  background: rgba(255, 255, 255, 0.08);
}

.ai-response-message .text-message.markdown-rendered a {
  color: #c3dafe;
  text-decoration: underline;
}

.ai-response-message .text-message.markdown-rendered hr {
  border-top-color: rgba(255, 255, 255, 0.15);
}

/* ---- AI Markdown Toggle ---- */
.ai-response-message .markdown-toggle {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.ai-response-message .markdown-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---- Typing Indicator ---- */
.ai-typing-indicator {
  display: inline-block;
  color: rgba(255, 255, 255, 0.7);
  animation: aiTypingBlink 1s infinite;
  font-weight: bold;
  margin-left: 2px;
}

/* ---- Response Complete ---- */
.ai-response-complete::after {
  content: '✓';
  position: absolute;
  bottom: 4px;
  right: 4px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}

/* ---- AI Error ---- */
.message.ai .message-content.ai-error {
  background: linear-gradient(135deg, #ff6b6b, #ee5252) !important;
  color: #ffffff !important;
}

/* ---- Animations ---- */
@keyframes aiTypingBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.2; }
}

@keyframes aiThinkingPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

.message.ai.fade-in {
  animation: fadeIn 200ms ease-out;
}

/* ---- Thinking Scrollbar ---- */
.ai-thinking-content::-webkit-scrollbar { width: 2px; }
.ai-thinking-content::-webkit-scrollbar-track { background: transparent; }
.ai-thinking-content::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 2px; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .message.ai { max-width: 85%; }
  .ai-thinking-content.expanded { max-height: 200px; }
  .thinking-text { font-size: 12px; }
}

@media (min-width: 768px) {
  .message.ai { max-width: 70%; }
  .ai-thinking-content.expanded { max-height: 400px; }
}
