:root {
  --bg-light: #EFF6FF;
  --ai-bubble-light: #DBEAFE;
  --input-bg-light: #dbeafe80;
  --bg-dark: #0D1117;
  --bg-darker: #090c10;
  --text-light: #1F2937;
  --text-dark: #E5E7EB;
  --border-light: rgba(0, 0, 0, 0.15);
  --border-dark: rgba(255, 255, 255, 0.2);
  --user-bubble: #2563EB;
  --accent-blue: #3B82F6;
  --ai-bubble-dark: #161B22; 
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  background-color: var(--bg-light);
  color: var(--text-light);
}
.dark body {
  background-color: var(--bg-darker);
  color: var(--text-dark);
}

.preloader-logo svg {
  animation: glow 2s ease-in-out;
  filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.5));
}
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.5)); }
  50% { filter: drop-shadow(0 0 20px rgba(59, 130, 246, 1)); }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; visibility: hidden; }
}

.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.dark .custom-scrollbar::-webkit-scrollbar-thumb { background: #374151; }

.message-container {
  display: flex; gap: 0.75rem; width: 100%; position: relative;
  animation: slideUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.message-container.user-align { justify-content: flex-end; }
.message-container.ai-align { justify-content: flex-start; }

.message-bubble {
  max-width: 80%; border-radius: 1.25rem;
  line-height: 1.7; word-wrap: break-word; width: fit-content;
}
.user-message {
  background-color: var(--user-bubble); color: white;
  border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
  padding: 0.75rem 1.25rem;
}
.model-message {
  background-color: var(--ai-bubble-light);
  border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-light);
}
.model-message.thinking {
  padding: 0;
  background-color: transparent;
  border: none;
}
.dark .model-message { 
  background-color: var(--ai-bubble-dark);
  border: 1px solid var(--border-dark);
}
.dark .model-message.thinking { 
  background-color: transparent;
  border: none;
}

.ai-icon-container {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center; align-self: flex-end;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.example-prompt {
  background-color: var(--ai-bubble-light);
  padding: 0.75rem 1.25rem; border-radius: 0.75rem;
  border: 1px solid var(--border-light); text-align: left;
  transition: all 0.2s ease; cursor: pointer;
}
.dark .example-prompt { border-color: var(--border-dark); background-color: var(--ai-bubble-dark); }
.example-prompt:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.dark .example-prompt:hover {
  box-shadow: none;
}

.light-input-bg {
  background-color: var(--input-bg-light);
}

.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol {
  margin-left: 1.5rem;
  padding-left: 0.5rem;
  list-style-position: outside;
}
.message-content ul {
  list-style-type: disc;
}
.message-content ol {
  list-style-type: decimal;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.9em;
}
.message-content th, .message-content td {
  border: 1px solid var(--border-light);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.dark .message-content th, .dark .message-content td {
  border-color: var(--border-dark);
}
.message-content thead {
  background-color: rgba(0,0,0,0.03);
}
.dark .message-content thead {
  background-color: rgba(255,255,255,0.05);
}
.message-content th {
  font-weight: 600;
}

.code-block-wrapper { 
  margin: 1rem 0;
  border-radius: 0.75rem; 
  overflow: hidden; 
  background: #010411; 
  border: 1px solid #334155; 
}
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 1rem; background: #1e2b3b; }
.code-language { font-size: 0.8rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; }
.copy-btn { background: #475569; color: white; border: none; padding: 0.3rem 0.6rem; border-radius: 6px; cursor: pointer; font-size: 0.75rem; transition: all 0.2s; display: flex; align-items: center; gap: 0.35rem; }
.copy-btn:hover { background: #64748b; } .copy-btn.copied { background: #10b981; }
pre { margin: 0 !important; padding: 1rem !important; overflow-x: auto; background: #010411 !important; }
pre code.hljs { font-family: 'SF Mono', 'Fira Code', monospace !important; font-size: 0.875rem !important; line-height: 1.7 !important; }
.message-content code:not(pre code) { background: rgba(0,0,0,0.1); color: var(--text-light); padding: 0.2rem 0.4rem; border-radius: 6px; font-size: 0.875rem; }
.dark .message-content code:not(pre code) { background: #374151; color: #a5b4fc; }

.blinking-cursor, .typing-cursor { display: inline-block; width: 3px; background-color: #4b5563; animation: blink 1s step-end infinite; vertical-align: bottom; }
.dark .blinking-cursor, .dark .typing-cursor { background-color: #9ca3af; }
.blinking-cursor { height: 1.2em; }
.typing-cursor { height: 1em; }
@keyframes blink { 50% { opacity: 0; } }

.thinking-indicator { display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.thinking-indicator div { width: 8px; height: 8px; margin: 0 3px; background-color: #9ca3af; border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.thinking-indicator div:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator div:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
#mic-btn.listening .material-symbols-outlined { color: #ef4444; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }

.message-actions { display: flex; gap: 0.25rem; position: absolute; top: -16px; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.message-container.user-align .message-actions { right: 0; }
.message-container.ai-align .message-actions { left: 44px; }
.message-container:hover .message-actions { opacity: 1; visibility: visible; }
.action-btn { background-color: white; border: 1px solid var(--border-light); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.dark .action-btn { background-color: var(--ai-bubble-dark); border-color: var(--border-dark); }
.action-btn:hover { background-color: #DBEAFE; }
.dark .action-btn:hover { background-color: #374151; }
.action-btn .material-symbols-outlined { font-size: 18px; color: #6b7280; }
.dark .action-btn .material-symbols-outlined { color: #9ca3af; }

.file-preview { display: inline-flex; align-items: center; gap: 8px; background-color: #e5e7eb; color: #1f2937; padding: 4px 8px; border-radius: 6px; font-size: 14px; }
.dark .file-preview { background-color: #374151; color: #e5e7eb; }

.mermaid-graph { background-color: white; padding: 1rem; border-radius: 0.75rem; margin: 1rem -0.25rem; display: flex; justify-content: center; align-items: center; }
.dark .mermaid-graph { background-color: #f9fafb; }
.message-content p:has(+ .mermaid-graph) { margin-bottom: 0.5rem; }

/* Table Container for Mobile Responsiveness */
.message-content table,
.model-message table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile specific table fixes */
@media (max-width: 768px) {
  table {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.8em;
  }

  .message-bubble {
    max-width: 90vw;
    overflow-x: hidden;
  }

  .message-content {
    overflow-x: auto;
  }
}
