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

:root {
    --bg-dark: #1e1e1e;
    --bg-sidebar: #252526;
    --bg-chat: #1e1e1e;
    --bg-input: #2d2d2d;
    --bg-bubble-user: #264f78;
    --bg-bubble-agent: #333333;
    --text: #cccccc;
    --text-bright: #e0e0e0;
    --text-dim: #888888;
    --accent: #569cd6;
    --border: #3e3e3e;
    --hover: #2a2d2e;
    --agent-active: #37373d;
    --status-running: #4ec9b0;
    --status-idle: #4ec94e;
    --status-offline: #888888;
    --status-error: #f44747;
}

html, body { height: 100%; font-family: 'Segoe UI', sans-serif; background: var(--bg-dark); color: var(--text); }

#app { display: flex; height: 100%; }

/* ─── Sidebar ─── */
#sidebar { width: 280px; min-width: 220px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
#sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
#sidebar-header h2 { font-size: 14px; font-weight: 600; color: var(--text-bright); text-transform: uppercase; letter-spacing: 1px; }
#agent-list { flex: 1; overflow-y: auto; padding: 8px; }

.agent-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 4px; border-radius: 6px;
    cursor: pointer; transition: background 0.15s;
}
.agent-item:hover { background: var(--hover); }
.agent-item.active { background: var(--agent-active); border-left: 3px solid var(--accent); }

.agent-status-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--status-idle);
}
.agent-status-dot.running { background: var(--status-running); animation: pulse 1.5s infinite; }
.agent-status-dot.offline { background: var(--status-offline); }
.agent-status-dot.error { background: var(--status-error); }

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 13px; font-weight: 500; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-model { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ─── Chat Area ─── */
#chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-chat); }

#chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
#chat-agent-name { font-size: 15px; font-weight: 600; color: var(--text-bright); }
#chat-header-actions { display: flex; gap: 8px; }
#chat-header-actions button {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
#chat-header-actions button:hover { background: var(--hover); border-color: var(--accent); }

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

#empty-state { display: flex; align-items: center; justify-content: center; height: 100%; }
#empty-state p { color: var(--text-dim); font-size: 14px; }

.chat-bubble {
    max-width: 75%; padding: 10px 14px; border-radius: 10px;
    font-size: 13px; line-height: 1.5; word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-bubble.user { background: var(--bg-bubble-user); color: var(--text-bright); align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-bubble.assistant { background: var(--bg-bubble-agent); color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; }

.chat-bubble .timestamp { display: block; font-size: 10px; color: var(--text-dim); margin-top: 4px; }

.typing-indicator { align-self: flex-start; padding: 10px 14px; background: var(--bg-bubble-agent); border-radius: 10px; }
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background: var(--text-dim); border-radius: 50%; margin: 0 2px; animation: typing 1.4s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* ─── Input ─── */
#chat-input-area {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px 20px; border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}
#chat-input {
    flex: 1; resize: none; border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-input); color: var(--text-bright); padding: 10px 12px;
    font-family: inherit; font-size: 13px; line-height: 1.4;
    max-height: 120px; outline: none;
}
#chat-input:focus { border-color: var(--accent); }
#btn-send {
    background: var(--accent); color: #fff; border: none; border-radius: 6px;
    padding: 10px 18px; cursor: pointer; font-size: 13px; font-weight: 500;
    white-space: nowrap;
}
#btn-send:hover { opacity: 0.85; }
#btn-send:disabled { opacity: 0.4; cursor: default; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
