/* ========================================================
   AI Assistant Conversational Interface Styles
   ======================================================== */
.chat-page-layout {
  display: flex;
  height: calc(100vh - var(--header-height) - 48px);
  gap: 20px;
  overflow: hidden;
}

/* Chat History Sidebar */
.chat-history-sidebar {
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-history-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chat-history-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.chat-history-item.active {
  background: rgba(139, 92, 246, 0.14);
  color: #ffffff;
  font-weight: 500;
}

.chat-history-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-history-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.chat-history-item:hover .chat-history-delete {
  opacity: 1;
}
.chat-history-delete:hover {
  color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
}

/* Chat Central Main Area */
.chat-main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.chat-status-bar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
}

.chat-model-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Message Bubbles */
.message-row {
  display: flex;
  gap: 14px;
  max-width: 85%;
  animation: messageIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-row.user .message-avatar {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.8rem;
}

.message-row.assistant .message-avatar {
  background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.message-row.user .message-meta {
  justify-content: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 0.92rem;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
}

.message-row.assistant .message-bubble {
  background: #182238;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-bubble p {
  color: inherit;
  margin-bottom: 8px;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-bubble code {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.84em;
  color: var(--accent-cyan);
}

/* Assistant Interactive Action Blocks */
.chat-action-card {
  margin-top: 10px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-action-text {
  font-size: 0.82rem;
  color: #e2e8f0;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: #182238;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingPulse 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0; }

@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Chat Composer */
.chat-composer-container {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(14, 20, 36, 0.9);
}

.chat-composer-box {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--border-radius-lg);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-composer-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 4px 0;
  max-height: 140px;
  min-height: 24px;
  resize: none;
  font-size: 0.92rem;
  line-height: 1.4;
  color: #ffffff;
}

.chat-textarea:focus {
  border: none;
  box-shadow: none;
  background: transparent;
}

.composer-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-helper {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* Suggested starter cards */
.chat-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 24px;
  max-width: 650px;
  width: 100%;
}

.suggestion-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suggestion-card:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.35);
  transform: translateY(-2px);
}

.suggestion-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
}

.suggestion-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}
