/* GolemLabs Client App — GolemLabs brand dark theme */

:root {
  --bg: #08090d;
  --bg-card: #0c0e14;
  --bg-input: #0f1117;
  --bg-user: #1a1d26;
  --accent: #00e5ff;
  --accent-dim: rgba(0, 229, 255, 0.15);
  --text: #e8eaed;
  --text-strong: #f5f5f7;
  --text-dim: #8a8f9b;
  --text-muted: #5a5f6b;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 229, 255, 0.3);
  --error: #ff4444;
  --success: #00c853;
  --sidebar-width: 260px;
  --header-height: 56px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ============ LOGIN PAGE ============ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  text-align: center;
  max-width: 400px;
  padding: 40px;
}

.login-logo {
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-strong);
}

.accent {
  color: var(--accent);
}

.login-subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-form {
  width: 100%;
}

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

.input-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error-text {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ============ CHAT PAGE ============ */

.chat-page {
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.5px;
}

.header-logo .accent {
  color: var(--accent);
}

.header-user {
  color: var(--text-dim);
  font-size: 13px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* Main layout */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-section {
  padding: 12px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* Agent list */
.agent-list {
  list-style: none;
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.15s;
}

.agent-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.agent-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}

.agent-icon {
  font-size: 16px;
  flex-shrink: 0;
}

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

/* Conversation history */
.history-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.history-item.active {
  background: var(--accent-dim);
  color: var(--text);
}

.btn-new-chat {
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.btn-new-chat:hover {
  background: rgba(0, 229, 255, 0.25);
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-agent-bar {
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.chat-agent-bar strong {
  color: var(--accent);
}

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

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user {
  align-self: flex-end;
  background: var(--bg-user);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

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

.message .content {
  word-wrap: break-word;
}

.message .content p { margin: 0 0 8px 0; }
.message .content p:last-child { margin: 0; }
.message .content code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.message .content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}
.message .content pre code {
  background: none;
  padding: 0;
}
.message .content ul, .message .content ol {
  padding-left: 20px;
  margin: 8px 0;
}
.message .content h1, .message .content h2, .message .content h3 {
  color: var(--text-strong);
  margin: 12px 0 6px 0;
}
.message .content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.message .content th, .message .content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.message .content th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-strong);
}
.message .content strong { color: var(--text-strong); }
.message .content a { color: var(--accent); }
.message .content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-dim);
  margin: 8px 0;
}

.message-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-copy:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Typing indicator */
.typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

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

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Input area */
.input-area {
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

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

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

.btn-send {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

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

.char-count {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.char-count.warn { color: var(--error); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 300px;
}

/* Connection error */
.connection-error {
  padding: 8px 16px;
  background: rgba(255, 68, 68, 0.1);
  border-bottom: 1px solid rgba(255, 68, 68, 0.2);
  color: var(--error);
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

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

  .btn-sidebar-toggle {
    display: block;
  }

  .message {
    max-width: 95%;
  }

  .header-user {
    display: none;
  }
}

/* ============ SCROLLBAR ============ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
