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

:root {
  color-scheme: dark;
  --bg: #050816;
  --bg-elevated: #0b1020;
  --bg-hover: #141a33;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.15);
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --danger: #f97373;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #111827 0, #020617 55%, #000 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

/* SIDEBAR */

.sidebar {
  border-right: 1px solid var(--border-subtle);
  padding: 16px 18px;
  background: linear-gradient(180deg, #020617 0%, #020617 40%, #020617 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 0, #a855f7, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 15px;
  font-weight: 600;
}

.logo-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

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

.footer-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.footer-list {
  list-style: none;
  font-size: 13px;
  color: var(--text-muted);
}

/* CHAT */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chat-header {
  padding: 18px 22px 10px;
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.9),
    rgba(15, 23, 42, 0.96)
  );
}

.chat-header h1 {
  font-size: 20px;
  margin-bottom: 4px;
}

.chat-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.chat-window {
  flex: 1;
  padding: 16px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-row {
  display: flex;
  margin-bottom: 6px;
}

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

.message-row--assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  border-radius: 18px;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid var(--border-subtle);
}

.message-bubble--user {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.message-bubble--assistant {
  background: rgba(15, 23, 42, 0.95);
}

.message-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* INPUT */

.chat-input {
  display: flex;
  gap: 10px;
  padding: 10px 18px 16px;
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 1)
  );
}

#chatInput {
  flex: 1;
  resize: none;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  background: #020617;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}

#chatInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.6);
}

.btn {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: #1f2937;
}

.status-badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
}

.status-badge--ok {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.3);
}

.status-badge--ok::before {
  background: #22c55e;
}

.status-badge--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}

.status-badge--error::before {
  background: #ef4444;
}

/* MOBILE */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .chat-header {
    padding-top: 14px;
  }

  .chat-window {
    padding: 12px 12px 8px;
  }

  .chat-input {
    padding: 10px;
  }

  .message-bubble {
    max-width: 90%;
  }
}