/* Theme variables from chat-interface-design */
:root {
  --background: 220 13% 18%;
  --foreground: 220 13% 95%;
  --card: 220 13% 15%;
  --card-foreground: 220 13% 95%;
  --popover: 220 13% 15%;
  --popover-foreground: 220 13% 95%;
  --primary: 142 60% 55%;
  --primary-foreground: 220 13% 10%;
  --secondary: 220 13% 22%;
  --secondary-foreground: 220 13% 80%;
  --muted: 220 10% 25%;
  --muted-foreground: 220 10% 55%;
  --accent: 220 13% 25%;
  --accent-foreground: 220 13% 90%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 220 10% 25%;
  --input: 220 10% 25%;
  --ring: 142 60% 55%;
  --radius: 0.75rem;
  --sidebar-bg: 220 13% 12%;
  --sidebar-hover: 220 13% 18%;
  --sidebar-active: 220 13% 22%;
}

* {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', 'Söhne', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: hsl(var(--muted));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground));
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Overlay */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: hsl(var(--background) / 0.8);
  z-index: 40;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: hsl(var(--sidebar-bg));
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  transition: transform 0.2s ease;
}

.sidebar-header {
  padding: 12px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--secondary-foreground));
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.new-chat-btn:hover {
  background: hsl(var(--accent) / 0.5);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.nav-group {
  margin-bottom: 16px;
}

.nav-group-label {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conv-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: hsl(var(--secondary-foreground));
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.conv-item:hover {
  background: hsl(var(--accent) / 0.5);
}

.conv-item.active {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.conv-item svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.conv-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.delete-btn {
  opacity: 0;
  padding: 4px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}

.conv-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background: hsl(var(--muted));
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid hsl(var(--border));
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-row:hover {
  background: hsl(var(--accent) / 0.5);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-name {
  flex: 1;
  font-size: 14px;
  color: hsl(var(--secondary-foreground));
}

.user-more {
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: hsl(var(--background));
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.95);
}

.menu-toggle {
  display: none;
  padding: 6px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.menu-toggle:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.model-select {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid hsl(var(--border));
  outline: none;
  cursor: pointer;
}

/* Messages area */
.messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 140px;
}

.messages-content {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 16px;
  animation: fade-in 0.3s ease-out;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  display: grid;
  place-items: center;
  margin-bottom: 24px;
}

.empty-title {
  font-size: 24px;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 0 0 4px;
  text-align: center;
}

.empty-subtitle {
  font-size: 14px;
  color: hsl(var(--muted-foreground));
  margin: 0 0 32px;
  text-align: center;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 576px;
  width: 100%;
}

.suggestion-card {
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--secondary-foreground));
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.suggestion-card:hover {
  background: hsl(var(--accent) / 0.5);
}

/* Messages */
.message {
  animation: fade-in 0.3s ease-out;
  padding: 16px 0;
}

.message.user {
  display: flex;
  justify-content: flex-end;
}

.message-inner {
  display: flex;
  gap: 16px;
  max-width: 768px;
  width: 100%;
}

.message.user .message-inner {
  flex-direction: row-reverse;
}

.avatar-bot {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.bubble {
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.65;
}

.bubble.user {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  border-bottom-right-radius: 6px;
  display: inline-block;
  max-width: 100%;
}

.bubble.assistant {
  color: hsl(var(--foreground));
}

.bubble pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
}

/* Typing */
.typing {
  display: flex;
  gap: 6px;
  padding: 4px 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: hsl(var(--muted-foreground));
  animation: pulse-dot 1.4s infinite ease-in-out both;
}

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

/* Message actions */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  margin-left: 4px;
}

.action-btn {
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.action-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

/* Input */
.input-wrapper {
  position: fixed;
  bottom: 0;
  left: 260px;
  right: 0;
  padding: 16px 16px 24px;
  background: linear-gradient(to top, hsl(var(--background)) 60%, transparent);
}

.input-box {
  position: relative;
  max-width: 768px;
  margin: 0 auto;
  background: hsl(var(--accent));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  transition: border-color 0.2s;
}

.input-box:focus-within {
  border-color: hsl(var(--muted-foreground) / 0.3);
}

#messageInput {
  width: 100%;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  padding: 14px 16px 56px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  min-height: 56px;
  max-height: 200px;
}

#messageInput::placeholder {
  color: hsl(var(--muted-foreground));
}

.input-actions {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-actions-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.send-btn {
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.2s;
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.send-btn:hover:not(:disabled) {
  opacity: 0.8;
}

.input-disclaimer {
  text-align: center;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  margin-top: 10px;
  max-width: 768px;
  margin-left: auto;
  margin-right: auto;
}

/* Animations */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay.show {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  .input-wrapper {
    left: 0;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
  }
}
