:root {
  /* Gradients */
  --gradient: linear-gradient(90deg, #0EA5E9 0%, #1E40AF 100%);

  /* Light Theme */
  --bg-light: #f3f4f6;
  --text-light: #111827;
  --sidebar-bg-light: #ffffff;
  --border-light: #e5e7eb;
  --card-bg-light: #ffffff;
  --muted-text-light: #6b7280;

  /* Dark Theme */
  --bg-dark: #18181b;
  --text-dark: #e4e4e7;
  --sidebar-bg-dark: #18181b;
  --border-dark: #3f3f46;
  --card-bg-dark: #27272a;
  --muted-text-dark: #a1a1aa;
}

/* ================= Base ================= */
html { font-size: 14px; }
body {
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.3s, color 0.3s;
}
#yc { text-decoration: none; border-bottom: 1px dotted currentColor; }
.transition-width { transition: width 0.3s ease-in-out; }
.smooth-scroll { scroll-behavior: smooth; }

/* ================= Typography ================= */
.font-default { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; }
.font-system { font-family: system-ui; }
.font-dyslexic { font-family: Verdana, sans-serif; }

.main-heading { font-weight: 800; line-height: 1.2; }
h1.main-heading { font-size: 2rem; }
h2.main-heading { font-size: 1.5rem; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}
.gradient-bg { background: var(--gradient); }

/* ================= Theming ================= */
.themed-sidebar { background-color: var(--sidebar-bg-light); border-color: var(--border-light); }
.themed-card { background-color: var(--card-bg-light); border-color: var(--border-light); }
.themed-text-muted { color: var(--muted-text-light); }

.themed-form-input {
  background-color: var(--card-bg-light);
  border: 1px solid var(--border-light);
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.themed-button {
  border-color: var(--border-light);
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  transition: background-color 0.2s;
}
.themed-button:hover { background-color: var(--bg-light); }

/* ================= Layout ================= */
/* ================= Layout ================= */
.sidebar-collapsed { width: 3.5rem; }
.sidebar-expanded { width: 14rem; }

/* --- CHAT CONTAINER --- */
.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /* Full-width layout, scrollbar on right edge */
  width: 100%;
  height: 100%;
  padding: 1rem 1.5rem 6rem; /* space for input bar */
}

/* Scrollbar Styling */
.chat-container::-webkit-scrollbar {
  width: 8px;
}
.chat-container::-webkit-scrollbar-thumb {
  background-color: rgba(100, 100, 100, 0.3);
  border-radius: 4px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 100, 100, 0.5);
}

/* Optional: message bubbles centered within wide chat area */
.chat-container .message {
  max-width: 42rem;
  margin: 0.25rem auto;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
}

/* --- WELCOME SECTION --- */
#welcome-section {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  transition: all 0.3s ease-in-out;

  /* Take full width but center internal content */
  width: 100%;
  padding: 0 1.5rem;
}

/* In chat mode, input stays centered and sticky */
#welcome-section.chat-mode {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}
#welcome-section.chat-mode #welcome-messages { display: none; }
#welcome-section.chat-mode #input-section {
  position: sticky;
  bottom: 0;
  margin-bottom: 1rem;
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

/* No-break utility */
.no-break { white-space: nowrap; }

/* ================= Sidebar ================= */
.sidebar-link.active { color: #0EA5E9; }

.sidebar-link svg,
.sidebar-link i[data-lucide] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-expanded .sidebar-link:hover { background-color: #f3f4f6; }
.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  width: 2.5rem;
}
.sidebar-collapsed .sidebar-link:hover { background-color: #f3f4f6; }

.sidebar-collapsed #profile-btn { justify-content: center; padding-left: 0; padding-right: 0; }
#profile-btn:hover { background-color: #f3f4f6; }
.sidebar-collapsed #profile-btn:hover { background-color: transparent; }
.sidebar-collapsed #profile-btn:hover #profile-avatar { background-color: #f3f4f6; }

/* Force text labels to hide in collapsed mode */
.sidebar-collapsed .sidebar-text {
  display: none;
}

/* ================= Navigation ================= */
#mobile-menu-toggle {
  background-color: #f9fafb;
  color: #111827;
  transition: all 0.2s ease-in-out;
}
#mobile-menu-toggle:hover {
  background-color: #f9fafb;
  color: #111827;
}
#mobile-menu-toggle svg { transition: opacity 0.2s ease-in-out; }

.settings-link {
  transition: all 0.2s;
  white-space: nowrap;
}
.settings-link:hover { background-color: var(--bg-light); }
.settings-link.active {
  color: #0EA5E9;
  background-color: var(--bg-light);
}

/* ================= Inputs ================= */
.form-input {
  background-color: #27272a;
  border: 1px solid #52525b;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.form-input:focus {
  border-color: #a1a1aa;
  outline: none;
}
.textarea-auto-resize { resize: none; overflow: hidden; }

/* ================= Cards ================= */
.settings-card, .font-card {
  background-color: var(--card-bg-light);
  border: 2px solid var(--border-light);
  border-radius: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}
.settings-card { padding: 1rem; }
.font-card { padding: 1.5rem; }

.settings-card:hover,
.font-card:hover { border-color: #0EA5E9; }

.settings-card.selected,
.font-card.selected {
  border-color: #0EA5E9;
  background-color: #eff6ff;
}

/* ================= Toggles ================= */
.toggle-switch input:checked + div { background-color: #3b82f6; }
.toggle-switch input:checked + div > div { transform: translateX(100%); }

/* ================= Messages ================= */
.message {
  display: flex;
  width: 100%;
}
.message + .message {
  margin-top: 0.75rem;
}

/* Base message bubble */
.message-content {
  display: inline-block;
  max-width: 80%;
  /*padding: 0.6rem 0.85rem;*/
  border-radius: 0.85rem;
  font-size: 0.9rem;
  margin-left: 0.25rem;
  margin-right: 0.25rem;
  line-height: 1.5;

  /* prevent long text/code from overflowing */
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
}

/* User messages (right-aligned) */
.message.user {
  justify-content: flex-end;
}
.message.user .message-content {
  background: var(--gradient);
  color: white;

  /* Allow horizontal scroll for long code or text lines */
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Assistant messages (left-aligned) */
.message.assistant {
  justify-content: flex-start;
}
.message.assistant .message-content {
  background-color: var(--card-bg-light);
  border: 1px solid var(--border-light);

  /* Same scroll behavior */
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Code blocks inside messages */
.message-content pre {
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;

  /* Allow internal scroll if code line is too long */
  overflow-x: auto;
  white-space: pre;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

/* Inline code */
.message-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  background-color: rgba(0, 0, 0, 0.08);
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
}

/* Optional scrollbar polish for horizontal scroll */
.message-content::-webkit-scrollbar,
.message-content pre::-webkit-scrollbar {
  height: 6px;
}
.message-content::-webkit-scrollbar-thumb,
.message-content pre::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.5);
  border-radius: 4px;
}
.message-content::-webkit-scrollbar-thumb:hover,
.message-content pre::-webkit-scrollbar-thumb:hover {
  background-color: rgba(59, 130, 246, 0.6);
}


/* ================= Responsive ================= */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: -16rem;
    height: 100%;
    width: 14rem;
    transition: left 0.3s ease-in-out;
    z-index: 40;
  }
  #sidebar.mobile-open { left: 0; }
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
  }
  #sidebar-overlay.active { display: block; }
  #sidebar.sidebar-collapsed,
  #sidebar.sidebar-expanded { width: 14rem; }

  #main-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .message-content { max-width: 85%; }

  #welcome-section { padding-top: 2rem; }
  #welcome-messages h1 { font-size: 2rem; }
  #welcome-messages p { font-size: 1rem; }

  .settings-nav-links {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .settings-nav-links::-webkit-scrollbar { display: none; }
  .settings-nav-links a { flex: 0 0 auto; white-space: nowrap; }

  #main-content > div {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  #main-content > div > div {
    padding-top: 0.5rem !important;
    padding-bottom: 1rem !important;
  }

  #chat-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  #chat-container::-webkit-scrollbar { display: none; }
}


/* Add this to your style.css file */

/* ================= Message Feedback Buttons ================= */
.message {
  display: flex;
  width: 100%;
  flex-direction: column; /* Stack message content and buttons vertically */
  align-items: flex-start; /* Default alignment for assistant messages */
}

.message.user {
  align-items: flex-end; /* Right-align user messages */
}

.message-content {
  display: inline-block; /* Keep as inline-block */
  max-width: 80%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.85rem;
  font-size: 0.9rem;
}

/* Feedback buttons container - appears below the message bubble */
.feedback-buttons {
  display: flex;
}

/* Show feedback buttons on hover */
.message.assistant:hover .feedback-buttons-inner {
  opacity: 1 !important;
}

/* Button styling */
.feedback-btn {
  transition: all 0.2s ease;
  color: #6b7280;
}

.feedback-btn:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.feedback-btn:active {
  transform: scale(0.95);
}

.loading-dots {
      display: flex;
      space-x: 1;
    }
    
    .loading-dots .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background-color: #9ca3af;
      margin: 0 1px;
      animation: loading-bounce 1.4s infinite ease-in-out both;
    }
    
    .loading-dots .dot:nth-child(1) { animation-delay: -0.32s; }
    .loading-dots .dot:nth-child(2) { animation-delay: -0.16s; }
    .loading-dots .dot:nth-child(3) { animation-delay: 0s; }
    
    @keyframes loading-bounce {
      0%, 80%, 100% {
        transform: scale(0);
      }
      40% {
        transform: scale(1);
      }
    }

    .create-project-btn {
      margin-top: 1rem;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.75rem 1.5rem;
      background: linear-gradient(to right, #0ea5e9, #6366f1);
      color: white;
      font-weight: 600;
      border-radius: 0.5rem;
      transition: opacity 0.2s;
      cursor: pointer;
      border: none;
    }

    .create-project-btn:hover {
      opacity: 0.9;
    }


/* ================= Scrollbar Styling ================= */

/* Base style for Chrome, Edge, Safari */
.chat-container::-webkit-scrollbar {
  width: 10px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent; /* keeps background clean */
  margin-block: 0.5rem;    /* top & bottom breathing space */
}

.chat-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Firefox scrollbar */
.chat-container {
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}

/* Smooth scroll and subtle fade for modern feel */
.chat-container {
  scroll-behavior: smooth;
  scroll-padding-bottom: 6rem; /* room for input */
}


/* Code block styling */
.code-block {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0.5rem 0 0.75rem;
  overflow-x: auto;
  white-space: pre;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
}

/* Inline code */
.inline-code {
  font-family: 'JetBrains Mono', monospace;
  background-color: rgba(0, 0, 0, 0.08);
  padding: 0.15rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}

/* Optional: subtle color hints for known languages */
.code-block.json { border-left: 4px solid #0ea5e9; }
.code-block.yaml { border-left: 4px solid #10b981; }
.code-block.python { border-left: 4px solid #f59e0b; }
.code-block.js { border-left: 4px solid #facc15; }
.code-block.css { border-left: 4px solid #8b5cf6; }
.code-block.html { border-left: 4px solid #ef4444; }

/* Add these rules to your existing style.css */

/* Update the main flex container */
.flex.h-screen.w-screen.themed-sidebar {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Main content should flex to fill available space */
#main-content {
  flex: 1;
  min-width: 0; /* Important for flex shrinking */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: flex 0.3s ease;
}

/* Chat container adapts to available width */
.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  height: 100%;
  padding: 1rem 1.5rem 6rem;
}

/* Welcome section stays centered within available width */
#welcome-section {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  transition: all 0.3s ease-in-out;
  width: 100%;
  padding: 0 1.5rem;
}

/* Input section centers within available space */
#welcome-section #input-section {
  width: 100%;
  max-width: min(42rem, 90%);
}

/* In chat mode, input stays centered and sticky */
#welcome-section.chat-mode #input-section {
  position: sticky;
  bottom: 0;
  margin-bottom: 1rem;
  max-width: min(42rem, 90%);
  margin-left: auto;
  margin-right: auto;
}

/* Message bubbles adapt to container width */
.chat-container .message {
  max-width: min(42rem, 90%);
  margin: 0.25rem auto;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
}

/* Feature section adapts to available width */
#feature-section,
#news-section {
  width: 100%;
  max-width: min(72rem, 95%);
  margin-left: auto;
  margin-right: auto;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .chat-container .message {
    max-width: 95%;
  }
  
  #welcome-section #input-section {
    max-width: 95%;
  }
}

@media (max-width: 768px) {
  #main-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .message-content {
    max-width: 85%;
  }

  #welcome-section {
    padding-top: 2rem;
  }
}