/**
 * 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-list-centered {
  align-items: center;
  text-align: center;
}

.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-list-centered .task-item {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.task-item .task-content {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.task-item .task-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.task-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.task-action-btn:hover {
  background: rgba(19, 91, 236, 0.1);
  color: #135bec;
}

.task-action-btn .material-symbols-outlined {
  font-size: 20px;
}

.task-done-btn:hover { color: #22c55e; }
.task-reschedule-btn:hover { color: #135bec; }
.task-delete-btn:hover { color: #ef4444; }

.task-item.completed {
  opacity: 0.6;
  background: rgba(34, 197, 94, 0.05);
  border-color: #22c55e;
}

.task-item.completed strong {
  text-decoration: line-through;
  color: #64748b;
}

.dark .task-item.completed strong {
  color: #94a3b8;
}

.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;
}

.reminder-priority {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 8px;
}
.reminder-priority.priority-high {
  background: #fef2f2;
  color: #dc2626;
}
.reminder-priority.priority-low {
  background: #f0fdf4;
  color: #16a34a;
}
.dark .reminder-priority.priority-high {
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
}
.dark .reminder-priority.priority-low {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
}

.task-recur {
  font-size: 0.75rem;
  color: #64748b;
}

.dark .task-recur {
  color: #94a3b8;
}

.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;
}

/* Search summary paragraph at top of results */
.search-summary {
  margin: 12px 0 16px 0;
  padding: 12px 16px;
  background: rgba(19, 91, 236, 0.08);
  border-left: 3px solid #135bec;
  border-radius: 8px;
}

.search-summary-text {
  margin: 0;
  color: inherit;
  font-size: 14px;
  line-height: 1.5;
}

/* 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 #135bec;
}

.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: #135bec;
  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;
}

/* Search filters and sentiment badges */
.search-filters {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 8px;
}
.result-sentiment {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  text-transform: capitalize;
}
.result-sentiment.sentiment-positive {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}
.result-sentiment.sentiment-negative {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}
.result-sentiment.sentiment-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: #94a3b8;
}

/* Citation and confidence styling */
.result-similarity {
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
}

.result-citation {
  background: rgba(19, 91, 236, 0.1);
  border-left: 2px solid #60a5fa;
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
  font-style: italic;
}

.result-matched-phrases {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.result-matched-phrases::before {
  content: "🎯 ";
  margin-right: 4px;
}

/* About Results - Enhanced Formatting */
.about-results {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(19, 91, 236, 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(19, 91, 236, 0.1), rgba(19, 91, 236, 0.05));
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

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

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

.count-badge {
  background: rgba(19, 91, 236, 0.2);
  color: #60a5fa;
  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 #135bec;
  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: #135bec;
  font-size: 16px;
  font-weight: bold;
}

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

.more-results {
  text-align: center;
  color: #135bec;
  font-size: 12px;
  font-weight: 600;
  margin-top: 12px;
  padding: 8px;
  background: rgba(19, 91, 236, 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(19, 91, 236, 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: #60a5fa;
  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 #135bec;
  border-radius: 6px;
}

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

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

/* AI Summary Section */
.ai-summary {
  background: linear-gradient(135deg, rgba(19, 91, 236, 0.15), rgba(19, 91, 236, 0.08));
  border: 1px solid rgba(19, 91, 236, 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: #60a5fa;
}

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

/* Memo saved confirmation */
.memo-saved {
  color: #94a3b8;
  font-size: 14px;
  padding: 4px 0;
}

/* Copy button on AI messages */
.msg-copy-btn {
  color: inherit;
  cursor: pointer;
}
.msg-copy-btn .material-symbols-outlined {
  font-size: 16px;
}

/* Settings command styling */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.settings-section {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border-left: 3px solid #135bec;
}

/* Dark mode: better contrast for settings sections */
.dark .settings-section {
  background: rgba(30, 41, 59, 0.5);
}

.settings-section h5 {
  font-size: 12px;
  font-weight: 600;
  color: #60a5fa;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-section div {
  font-size: 14px;
  color: #e2e8f0;
  margin-bottom: 4px;
}

.settings-section div:last-child {
  margin-bottom: 0;
}

/* Sync command styling */
.sync-results {
  margin-top: 12px;
}

.sync-item {
  padding: 8px 0;
  font-size: 14px;
  color: #e2e8f0;
}

.sync-errors {
  margin-top: 12px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 14px;
}

.sync-errors ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

/* Status command */
.status-message {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #e2e8f0;
}

/* Tags */
.tags-results {
  padding: 4px 0;
}
.tags-results .tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.tags-results .tag-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 9999px;
  background: rgba(19, 91, 236, 0.2);
  color: #135bec;
  font-size: 13px;
  text-decoration: none;
  transition: background 0.2s;
}
.tags-results .tag-pill:hover {
  background: rgba(19, 91, 236, 0.35);
}
.tags-results .tag-pill .tag-count {
  opacity: 0.8;
  font-size: 11px;
  margin-left: 4px;
}
.tags-results .tag-hint {
  font-size: 12px;
  color: #94a3b8;
  margin: 8px 0 0 0;
}
.tags-results .tag-count {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}
.dark .tags-results .tag-pill {
  background: rgba(19, 91, 236, 0.35);
  color: #93c5fd;
}
.dark .tags-results .tag-pill:hover {
  background: rgba(19, 91, 236, 0.5);
}

/* Related notes (bidirectional linking) */
.related-notes {
  margin-top: 12px;
  padding: 12px;
  background: rgba(19, 91, 236, 0.08);
  border-left: 3px solid #135bec;
  border-radius: 8px;
}
.related-suggestion {
  font-size: 13px;
  color: #94a3b8;
  font-style: italic;
  margin-bottom: 8px;
  padding: 4px 0;
}
.related-notes-list {
  margin: 8px 0 0 0;
  padding-left: 20px;
  list-style: disc;
}
.related-note-item {
  margin-bottom: 4px;
  font-size: 13px;
  color: #cbd5e1;
  cursor: pointer;
}
.related-note-item:hover {
  color: #60a5fa;
}
.related-date {
  color: #64748b;
  font-size: 11px;
  margin-right: 6px;
}

/* Contextual suggestions (location, time patterns) */
.contextual-suggestion {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.08);
  border-left: 3px solid #22c55e;
  border-radius: 6px;
  font-size: 13px;
  color: #94a3b8;
}
.contextual-suggestion.location {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}
.contextual-suggestion.time {
  margin-top: 4px;
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}
.contextual-suggestion .contextual-action {
  color: #135bec;
  font-weight: 500;
}
.contextual-suggestion .note-link,
.contextual-suggestion .conv-link {
  color: #135bec;
  text-decoration: none;
}
.contextual-suggestion .note-link:hover,
.contextual-suggestion .conv-link:hover {
  text-decoration: underline;
}

/* Threads */
.threads-result .thread-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
}
.thread-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border-left: 3px solid #135bec;
  display: flex;
  align-items: center;
  gap: 10px;
}
.thread-icon {
  font-size: 18px;
}
.thread-meta {
  font-size: 12px;
  color: #64748b;
  margin-left: auto;
}