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

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface2: #24243a;
  --border: #2e2e44;
  --text: #d4d4e0;
  --text-dim: #8888a0;
  --accent: #5b9bd5;
  --accent2: #44cc88;
  --danger: #e0556a;
  --user-bubble: #2a4a6e;
  --n8n-bubble: #2e4a3a;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 600; color: var(--accent); }
.topbar-controls { display: flex; align-items: center; gap: 10px; }
.topbar-controls label { font-size: 13px; color: var(--text-dim); }
.topbar-controls input { width: 220px; }

/* Layout */
.layout {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
}
.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.panel:last-child { border-right: none; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 48px;
}
.panel-header h2 { font-size: 14px; font-weight: 600; }
.panel-header label { font-size: 13px; color: var(--text-dim); }

/* Inputs & Buttons */
input[type="text"], input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent);
}
input[type="number"] { width: 80px; }

.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #2e2e50; border-color: #4a4a66; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #6aade0; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #3a1a20; border-color: var(--danger); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-empty {
  color: var(--text-dim);
  text-align: center;
  margin-top: 40px;
  font-size: 13px;
}

.message {
  max-width: 75%;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.message.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}
.message.n8n {
  align-self: flex-start;
  background: var(--n8n-bubble);
  border-bottom-left-radius: 4px;
}
.message .msg-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.message.pending {
  opacity: 0.5;
}

/* Chat input */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-area input {
  flex: 1;
  padding: 8px 14px;
  font-size: 14px;
}

/* Status dot */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: auto;
}
.status-dot.connected { background: var(--accent2); }
.status-dot.disconnected { background: var(--danger); }

/* Badge */
.badge {
  padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.badge-idle { background: var(--surface2); color: var(--text-dim); }
.badge-running { background: #2a4a2a; color: var(--accent2); }
.badge-error { background: #4a1a20; color: var(--danger); }

/* Test config */
.test-config { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.config-row { display: flex; gap: 12px; }
.config-row label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.config-row input { width: 70px; }

/* Test actions */
.test-actions { padding: 0 16px 12px; display: flex; gap: 8px; }

/* Test stats */
.test-stats {
  display: flex;
  gap: 0;
  padding: 0 16px 12px;
}
.stat {
  flex: 1;
  text-align: center;
  background: var(--surface2);
  border-radius: 6px;
  padding: 8px 4px;
  margin: 0 2px;
}
.stat-value { display: block; font-size: 18px; font-weight: 700; color: var(--accent); }
.stat-label { display: block; font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* Test log */
.test-log {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  font-size: 11px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}
.log-empty { color: var(--text-dim); text-align: center; margin-top: 20px; }
.log-entry { padding: 3px 0; border-bottom: 1px solid #1a1a28; }
.log-entry.error { color: var(--danger); }
.log-entry.info { color: var(--accent2); }
.log-entry.warn { color: #e0b040; }

/* User selector dropdown */
.user-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  max-width: 180px;
  cursor: pointer;
}
.user-select option { color: var(--text); background: var(--surface); }
