*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --bg-secondary: #1a1c25;
  --bg-tertiary: #242633;
  --text: #e4e4e7;
  --text-muted: #9395a5;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --user-bubble: #2d2f3e;
  --assistant-bubble: transparent;
  --border: #2e303e;
  --success: #34d399;
  --error: #f87171;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

.sidebar.hidden {
  transform: translateX(-100%);
  position: absolute;
  z-index: 10;
  height: 100%;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.project-list {
  list-style: none;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.project-list li {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.project-list li:hover {
  background: var(--bg-tertiary);
}

.project-list li.empty-state {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}

.project-list li.empty-state:hover {
  background: transparent;
}

.project-list a {
  color: var(--text);
  text-decoration: none;
  display: block;
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chat-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.chat-header .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: auto;
}

.sidebar-toggle {
  display: none;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.message.user .message-content {
  background: var(--user-bubble);
  border-radius: 12px;
  padding: 12px 16px;
  margin-left: auto;
  max-width: 85%;
  width: fit-content;
}

.message.assistant .message-content {
  background: var(--assistant-bubble);
  padding: 4px 0;
  width: 100%;
}

.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content em {
  color: var(--text-muted);
}

.message-content a {
  color: var(--accent-hover);
  text-decoration: underline;
}

.message-content code {
  font-family: var(--mono);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
}

/* Tool indicators */
.tool-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0;
  max-width: 800px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.tool-indicator .icon {
  font-size: 16px;
}

.tool-indicator.success {
  border-color: rgba(52, 211, 153, 0.3);
}

.tool-indicator.error {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--error);
}

/* Input area */
.input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 848px;
  width: 100%;
  margin: 0 auto;
}

textarea {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.5;
  transition: border-color 0.15s;
}

textarea:focus {
  border-color: var(--accent);
}

textarea::placeholder {
  color: var(--text-muted);
}

#sendBtn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

#sendBtn:hover {
  background: var(--accent-hover);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* Loading dots */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    z-index: 10;
    height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.visible {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: flex;
  }
  .chat-header .subtitle {
    display: none;
  }
  .input-area {
    padding: 12px 16px;
  }
}
