/*
 * License-Identifier: HGL
 * Copyright (C) The Usecode Authors (see AUTHORS)
 */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-elevated: #f5f6f8;
  --text: #16181c;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #5b8def;
  --accent-text: #ffffff;
  --bubble-agent: #f0f1f4;
  --bubble-user: #5b8def;
  --bubble-user-text: #ffffff;
  --online: #34c759;
  --away: #f2a93b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f11;
    --bg-elevated: #17181b;
    --text: #f3f4f6;
    --text-muted: #9aa0aa;
    --border: #2a2c30;
    --bubble-agent: #202226;
  }
}
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
}

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

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

.logout-button {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}
.login-card h1 {
  margin: 0 0 8px;
}

.login-subtitle,
.login-hint {
  color: var(--text-muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  color: var(--text);
  text-align: center;
}
.login-form button[type=submit] {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

.login-link {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.login-error {
  color: #e5484d;
  font-size: 13px;
  margin: 0;
}

.agent-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  flex: 1;
}

.agent-list-item {
  width: 100%;
  display: flex;
  gap: 12px;
  border: none;
  background: none;
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: left;
}
.agent-list-item:hover, .agent-list-item.active {
  background: var(--bg-elevated);
}

.avatar {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--text-muted);
}
.status-dot.online {
  background: var(--online);
}
.status-dot.away {
  background: var(--away);
}

.agent-list-meta {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-weight: 600;
}

.agent-time, .agent-preview, .agent-status-text {
  color: var(--text-muted);
  font-size: 12px;
}

.agent-list-row {
  display: flex;
  justify-content: space-between;
}

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.chat-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

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

.chat-header-meta {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bubble-row {
  display: flex;
}

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

.bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--bubble-agent);
}
.bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.bubble.user {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
}

.bubble-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.65;
  text-align: right;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.composer-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 9px 14px;
  background: var(--bg-elevated);
  color: var(--text);
}

.composer-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
}

@media (max-width: 767px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .main-panel {
    min-height: 55vh;
  }
}
