:root {
  /* Dark Theme Variables */
  --bg-app: #09070f;
  --bg-sidebar: #0e0c15;
  --bg-input: #151121;
  --bg-card: #151121;
  --bg-card-hover: #1f1930;
  --text-main: #f5f3ff;
  --text-muted: #9c92c2;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --accent-light: rgba(168, 85, 247, 0.15);
  --border: #261f38;
  --chat-user: #8b5cf6;
  --chat-ai: #130f1e;
  --glass-bg: rgba(19, 15, 30, 0.85);

  --bg-primary: #0f0c1b;
  --card-bg: rgba(22, 18, 36, 0.85);
  --border-color: rgba(168, 85, 247, 0.25);
  --text-primary: #f3f4f6;
  --input-bg: rgba(22, 18, 36, 0.75);
  --counter-bg: rgba(255, 255, 255, 0.05);
  --counter-border: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] {
  /* Light Theme Variables */
  --bg-app: #fcfaff;
  --bg-sidebar: #ffffff;
  --bg-input: #ffffff;
  --bg-card: #f5f0ff;
  --bg-card-hover: #ebdfff;
  --text-main: #1e1333;
  --text-muted: #6b5b8a;
  --accent: #800080;
  --accent-hover: #660066;
  --accent-light: rgba(128, 0, 128, 0.1);
  --border: #e8dff5;
  --chat-user: #800080;
  --chat-ai: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.85);

  --bg-primary: #f8fafc;
  --card-bg: #ffffff;
  --border-color: rgba(168, 85, 247, 0.3);
  --text-primary: #1e1b4b;
  --input-bg: #ffffff;
  --counter-bg: rgba(168, 85, 247, 0.08);
  --counter-border: rgba(168, 85, 247, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Sidebar Styling & Animations */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: relative;
  overflow: hidden;
  z-index: 2;
  flex-shrink: 0;
}

.sidebar-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.bubble {
  position: absolute;
  bottom: -50px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.35) 0%, rgba(168, 85, 247, 0) 70%);
  border-radius: 50%;
  animation: floatUp 12s infinite linear;
}

.bubble:nth-child(1) { left: 10%; width: 18px; height: 18px; animation-duration: 9s; animation-delay: 0s; }
.bubble:nth-child(2) { left: 35%; width: 12px; height: 12px; animation-duration: 14s; animation-delay: 2s; }
.bubble:nth-child(3) { left: 55%; width: 22px; height: 22px; animation-duration: 11s; animation-delay: 4s; }
.bubble:nth-child(4) { left: 75%; width: 15px; height: 15px; animation-duration: 13s; animation-delay: 1s; }
.bubble:nth-child(5) { left: 20%; width: 25px; height: 25px; animation-duration: 16s; animation-delay: 5s; }
.bubble:nth-child(6) { left: 85%; width: 10px; height: 10px; animation-duration: 10s; animation-delay: 3s; }

@keyframes floatUp {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  20% { opacity: 0.5; }
  80% { opacity: 0.5; }
  100% { transform: translateY(-1050px) scale(1.2); opacity: 0; }
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--text-main);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background-color: var(--accent);
  color: white;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  box-shadow: 0 0 12px var(--accent-light);
  animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 12px var(--accent-light); }
  50% { box-shadow: 0 0 22px rgba(168, 85, 247, 0.5); }
}

.new-chat-btn {
  width: 100%;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.25);
}

.new-chat-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.4);
}

.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-section { margin-bottom: 18px; }

.nav-section h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  padding-left: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background-color: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 3px;
  background-color: var(--accent);
  border-radius: 0 4px 4px 0;
}

/* Developer Footer Card */
.sidebar-user-card {
  display: flex;
  align-items: center;
  padding: 14px 12px 6px 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: transparent;
}

.sidebar-user-card .user-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.developer-credit {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.4;
  letter-spacing: 0.2px;
}

.developer-credit strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Social Buttons Container */
.social-links {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

/* Styled Icon Buttons */
.social-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: var(--accent-light);
  color: var(--accent) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
  border: 1px solid var(--border-color);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.social-icon-btn i {
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  display: inline-block;
}

.social-icon-btn:hover {
  background-color: var(--accent);
  color: #ffffff !important;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.35);
}

.social-icon-btn:active {
  transform: translateY(0);
}

/* Main Workspace Layout */
.main-workspace {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100vh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.current-mode { display: flex; align-items: center; gap: 10px; }
.mode-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.5px; }

.mode-badge {
  color: var(--accent);
  background: var(--accent-light);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.top-actions { display: flex; align-items: center; gap: 12px; }

.top-new-chat-btn {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(168, 85, 247, 0.4);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.15);
}

.top-new-chat-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
}

.top-new-chat-btn:active {
  transform: translateY(0);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  display: grid;
  place-items: center;
  transition: color 0.2s;
}

.theme-toggle:hover { color: var(--text-main); }

.header-avatar {
  width: 32px;
  height: 32px;
  background-color: var(--accent);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Chat & Empty State Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 14%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 100%;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  text-align: center;
  padding: 20px 0;
  width: 100%;
}

.mode-icon-large {
  width: 68px;
  height: 68px;
  background-color: var(--accent-light);
  color: var(--accent);
  font-size: 1.9rem;
  border-radius: 20px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.empty-state h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 32px;
  max-width: 520px;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 860px;
}

@media (max-width: 768px) {
  .suggestions-grid {
    grid-template-columns: 1fr;
  }
}

.suggestion-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 18px 20px;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.suggestion-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.25);
}

.suggestion-card i {
  color: var(--accent);
  font-size: 1.1rem;
  margin-bottom: 10px;
}

/* Chat Message Items */
.message-wrapper {
  display: flex;
  width: 100%;
  max-width: 100%;
  gap: 14px;
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-wrapper.user { flex-direction: row-reverse; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: bold;
  flex-shrink: 0;
}

.avatar.user-avatar { background-color: var(--accent); color: white; }
.avatar.ai-avatar { background-color: var(--accent-light); color: var(--accent); border: 1px solid var(--border); }

.message-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-bubble {
  width: 100%;
  max-width: 100%;
  padding: 16px 20px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.95rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message-wrapper.user .message-bubble {
  background-color: var(--chat-user);
  color: white;
  border-top-right-radius: 2px;
}

.message-wrapper.ai .message-bubble {
  background-color: var(--chat-ai);
  border: 1px solid var(--border);
  border-top-left-radius: 2px;
}

/* Markdown Formatting */
.message-bubble p { margin-bottom: 12px; line-height: 1.65; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { color: #ffffff; font-weight: 600; }
[data-theme="light"] .message-bubble strong { color: #110726; }

.message-bubble ol, .message-bubble ul {
  margin: 12px 0 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-bubble li { line-height: 1.6; }

.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  color: var(--accent);
  margin-top: 18px;
  margin-bottom: 10px;
  font-weight: 700;
}

.message-bubble pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  border-radius: 8px;
  padding: 14px;
  margin: 10px 0;
}

.message-bubble code {
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 15px;
  background-color: var(--accent);
  margin-left: 4px;
  border-radius: 2px;
  vertical-align: middle;
  animation: blinkCursor 0.7s infinite;
}

@keyframes blinkCursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.output-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.tool-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.tool-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

/* Input Box Wrapper & Container */
.input-area-wrapper {
  width: 100%;
  padding: 0 20px 20px 20px;
  background: transparent;
  flex-shrink: 0;
}

.input-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px 12px 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12),
              0 0 0 1px rgba(168, 85, 247, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-container:focus-within {
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 8px 30px -4px rgba(168, 85, 247, 0.2);
}

.input-container textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 0.975rem;
  font-family: inherit;
  line-height: 1.5;
  max-height: 200px;
  min-height: 24px;
}

.input-container textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.input-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.char-counter {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--counter-bg);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--counter-border);
  letter-spacing: 0.3px;
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  color: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(168, 85, 247, 0.45);
}

.send-btn:active {
  transform: translateY(0);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  box-shadow: none;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 8px 0;
}

.dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Toast Notification Container */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary, #f3f4f6);
  background: var(--card-bg, rgba(22, 18, 36, 0.9));
  border: 1px solid var(--border-color, rgba(168, 85, 247, 0.3));
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(168, 85, 247, 0.15);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.success i {
  color: #10b981;
  font-size: 1.05rem;
}

.toast.error i {
  color: #ef4444;
  font-size: 1.05rem;
}

[data-theme="light"] .toast {
  background: #ffffff;
  color: #1e1b4b;
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08),
              0 0 0 1px rgba(168, 85, 247, 0.1);
}
