/**
 * Chat Interface Styles
 * 通用聊天介面組件，用於「效率 AI」專欄
 * 支援多個 AI 依序回答的對話流程
 */

/* ===== Chat Container ===== */
.chat-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ===== Message Bubble Base ===== */
.message {
  display: flex;
  gap: 0.75rem;
  animation: messageSlideIn 0.3s ease-out;
}

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

/* ===== User Message ===== */
.message.user {
  flex-direction: row-reverse;
}

.message.user .message-content {
  background: #e3f2fd;
  color: #1e293b;
  margin-left: auto;
  max-width: 70%;
}

/* ===== AI Messages ===== */
.message.ai {
  flex-direction: row;
}

.message.ai .message-content {
  background: white;
  border: 1px solid #e2e8f0;
  max-width: 85%;
}

/* ===== Avatar ===== */
.message-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.5rem;
}

.user .message-avatar {
  background: transparent;
}

/* AI Specific Avatars */
.chatgpt .message-avatar {
  background: transparent;
}

.gemini .message-avatar {
  background: transparent;
}

.claude .message-avatar {
  background: transparent;
}

/* ===== Message Content ===== */
.message-content {
  border-radius: 1rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
}

.message-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #1e293b;
}

.message-body p {
  margin-bottom: 0.5rem;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body ul {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.message-body li {
  margin-bottom: 0.25rem;
}

.message-body code {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #334155;
}

/* ===== AI Thinking Indicator ===== */
.ai-thinking {
  font-size: 0.85rem;
  color: #475569;
  font-style: italic;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-thinking::after {
  content: "▲";
  font-size: 0.7rem;
  color: #64748b;
  font-style: normal;
}

.gemini .ai-thinking {
  /* no special color */
}

.claude .ai-thinking {
  border: 1px solid #e7e5e4;
  background: #fdfcfb;
}

.claude .ai-thinking::after {
  content: "▼";
}

/* ===== Message Footer (Actions) ===== */
.message-footer {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
  padding-top: 0;
  border-top: none;
}

.message-action {
  padding: 0.25rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  border: none;
}

.message-action:hover {
  background: #f8fafc;
  color: #1e293b;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .chat-container {
    padding: 1rem 0.5rem;
  }

  .message-content {
    max-width: 100% !important;
  }

  .message.user .message-content {
    max-width: 85% !important;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }

  .message-body {
    font-size: 0.9rem;
  }
}

/* ===== ChatGPT Specific ===== */
.chatgpt .message-content {
  background: white;
  border-color: #e5e7eb;
}

/* ===== Gemini Specific ===== */
.gemini .message-content {
  background: white;
  border-color: #e8eaed;
}

.gemini .message-header::before {
  content: "★";
  color: #4285f4;
  margin-right: 0.25rem;
}

/* ===== Claude Specific ===== */
.claude .message-content {
  background: #fdfcfb;
  border-color: #e7e5e4;
}

.claude .message-footer {
  border-top-color: #e7e5e4;
}

.claude-warning {
  font-size: 0.75rem;
  color: #a8a29e;
  margin-top: 0.5rem;
  font-style: italic;
}

/* ===== Chat Input Box ===== */
.chat-input-container {
  position: sticky;
  bottom: 0;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 1rem;
  margin-top: 2rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-message-notice {
  max-width: 800px;
  margin: 0 auto 0.75rem;
  padding: 0.75rem 1rem;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  background: linear-gradient(90deg,
    #ff0000, #ff7f00, #ffff00, #00ff00,
    #0000ff, #4b0082, #9400d3, #ff0000);
  background-size: 200% auto;
  color: white;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: slideDown 0.3s ease-out, rainbowShift 3s linear infinite;
}

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

@keyframes rainbowShift {
  0% {
    background-position: 0% center;
  }
  100% {
    background-position: 200% center;
  }
}

.chat-input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
}

.chat-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.75rem 3rem 0.75rem 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  font-family: inherit;
  transition: border-color 0.2s;
  max-height: 150px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.chat-input::-webkit-scrollbar {
  width: 6px;
}

.chat-input::-webkit-scrollbar-track {
  background: transparent;
}

.chat-input::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.chat-input::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-input::placeholder {
  color: #94a3b8;
}

.chat-send-btn {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  background: #d1fae5;
  color: #10b981;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  z-index: 10;
}

.chat-send-btn.active {
  background: #10b981;
  color: white;
  opacity: 1;
}

.chat-send-btn:hover {
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.75rem;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .chat-input-container {
    padding: 0.75rem;
  }

  .chat-input-wrapper {
    gap: 0.5rem;
  }

  .chat-send-btn {
    padding: 0.75rem 1rem;
  }
}
