/**
 * Chat UI Styles
 * Message display, input area, and chat-specific components
 */

/* Chat container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
}

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

/* Message */
.message {
  display: flex;
  gap: var(--spacing-sm);
  max-width: 80%;
  animation: messageSlideIn 0.3s ease-out;
}

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

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

.message.ai {
  align-self: flex-start;
}

.message.system {
  align-self: center;
  max-width: 90%;
}

/* Message avatar */
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

.message.ai .message-avatar {
  background: var(--bg-ai);
  color: #333;
}

.message.system .message-avatar {
  background: var(--bg-system);
  color: #856404;
}

/* Message content */
.message-content {
  flex: 1;
  padding: var(--spacing-md);
  border-radius: var(--border-radius);
  position: relative;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--bg-user), var(--primary-dark));
  color: var(--text-user);
  border-bottom-right-radius: 4px;
}

.message.ai .message-content {
  background: var(--bg-ai);
  color: var(--text-ai);
  border-bottom-left-radius: 4px;
}

.message.system .message-content {
  background: var(--bg-system);
  color: #856404;
  text-align: center;
  border-radius: var(--border-radius-lg);
}

.message.error .message-content {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.message.command-result .message-content {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Message text */
.message-text {
  margin: 0;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Message time */
.message-time {
  display: block;
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: var(--spacing-xs);
}

.message.user .message-time {
  text-align: right;
}

/* Input area */
.input-area {
  border-top: 1px solid var(--border-color);
  background: white;
  padding: var(--spacing-md);
}

.input-controls {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.text-input {
  flex: 1;
  padding: var(--spacing-md);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  font-size: 1rem;
  resize: none;
  max-height: 120px;
  min-height: 48px;
}

.text-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.voice-btn, .send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.voice-btn {
  background: var(--bg-ai);
  color: #333;
}

.voice-btn:hover {
  background: #e2e6ea;
  transform: scale(1.05);
}

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

.send-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.send-btn:disabled {
  background: #e9ecef;
  color: #6c757d;
  cursor: not-allowed;
  transform: none;
}

/* Voice recording indicator */
.voice-recording {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: #fff3cd;
  border-radius: var(--border-radius);
  margin-top: var(--spacing-sm);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: #856404;
  font-weight: 500;
}

.recording-dot {
  width: 12px;
  height: 12px;
  background: #dc3545;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.stop-btn {
  padding: var(--spacing-sm) var(--spacing-lg);
  background: #dc3545;
  color: white;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
}

.stop-btn:hover {
  background: #c82333;
}

/* Command result formatting */
.task-list, .conversation-list, .reminder-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.task-item, .conversation-item, .reminder-item {
  padding: var(--spacing-md);
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.task-item:hover, .conversation-item:hover, .reminder-item:hover {
  border-color: var(--primary-color);
  transform: translateX(2px);
}

.task-item strong, .reminder-item strong {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: #212529;
}

.task-meta {
  display: flex;
  gap: var(--spacing-md);
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: var(--spacing-xs);
}

.priority {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.priority-high {
  background: #f8d7da;
  color: #721c24;
}

.priority-medium {
  background: #fff3cd;
  color: #856404;
}

.priority-low {
  background: #d1ecf1;
  color: #0c5460;
}

/* Empty states */
.no-tasks, .no-conversations, .no-reminders {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-muted);
}

/* Loading state */
.message.loading .message-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.typing-indicator {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #6c757d;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* Hide the "Mentioned:" entities block */
.entities {
  display: none !important;
}

/* Hide message bubbles that only contain hidden entities or tasks */
.message:has(.entities):not(:has(*:not(.entities))),
.message:has(.tasks-extracted):not(:has(*:not(.tasks-extracted))) {
  display: none !important;
}

/* Hide empty AI message bubbles */
.message.ai-message:empty,
.message.command-result:empty,
.message-content:empty {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
/* Force hide any message with empty or whitespace-only content */
.message-content:empty,
.message-content:has(> :only-child:empty) {
  display: none !important;
}

/* Hide parent message div if content is hidden */
.flex.items-start:has(.message-content:empty) {
  display: none !important;
}

/* Tailwind-based message bubbles - hide if empty */
.rounded-2xl:empty {
  display: none !important;
}

/* Hide entire message container if the rounded bubble is empty */
.flex.items-start:has(.rounded-2xl:empty) {
  display: none !important;
}
/* Hide AI messages that only contain hidden entities */
.message.ai-message:has(.entities):not(:has(*:not(.entities))) {
  display: none !important;
}

/* Hide task extraction notification boxes */
.tasks-extracted {
  display: none !important;
}

/* Only hide task lists that are inside extraction notifications */
.tasks-extracted .task-list {
  display: none !important;
}

/* Better formatting for search results */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.search-result {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  border-left: 3px solid #6366f1;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.result-number {
  font-weight: 600;
  color: #6366f1;
  font-size: 14px;
}

.result-date {
  color: #94a3b8;
  font-size: 11px;
}

.result-content {
  margin-top: 4px;
}

.result-text {
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* Remove duplicate "5 5 results" text */
h4 {
  margin-bottom: 8px;
}

/* Hide duplicate count in result headers */
.search-results h4::after {
  content: none;
}

/* About Results - Enhanced Formatting */
.about-results {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.about-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0 0 16px 0;
}

.key-facts {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.fact-item {
  color: #a5b4fc;
  font-size: 15px;
  font-weight: 500;
  padding: 4px 0;
}

.summary-line {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.count-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.conversations-section,
.tasks-section {
  margin-top: 20px;
}

.conversations-section h4,
.tasks-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.convo-item {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #6366f1;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
}

.convo-date {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.convo-text {
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  margin-bottom: 6px;
}

.task-status {
  color: #6366f1;
  font-size: 16px;
  font-weight: bold;
}

.task-title {
  color: #e2e8f0;
  font-size: 14px;
  flex: 1;
}

.more-results {
  text-align: center;
  color: #6366f1;
  font-size: 12px;
  font-weight: 600;
  margin-top: 12px;
  padding: 8px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 6px;
}

.no-results {
  text-align: center;
  padding: 32px 16px;
}

.no-results p {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 8px;
}

.no-results .hint {
  color: #64748b;
  font-size: 12px;
  font-style: italic;
}
/* Help Command Styling */
.help-results {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.help-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0 0 20px 0;
}

.help-section {
  margin-bottom: 24px;
}

.help-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: #a5b4fc;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.command-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.command-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #6366f1;
  border-radius: 6px;
}

.command-name {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: #a5b4fc;
}

.command-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

/* AI Summary Section */
.ai-summary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-icon {
  font-size: 18px;
}

.summary-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #818cf8;
}

.summary-text {
  color: #e2e8f0;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}