/* SDK Agent — Supervisor Dashboard */
:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #242836;
    --border: #2e3347;
    --text: #e4e6f0;
    --text-dim: #8b8fa3;
    --accent: #6c7cff;
    --accent-dim: #4a56b5;
    --green: #34d399;
    --red: #f87171;
    --orange: #fbbf24;
    --radius: 8px;
}

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

body {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.header-left h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }
.header-left .subtitle { font-size: 12px; color: var(--text-dim); margin-left: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.status-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px; font-size: 12px;
    background: var(--surface-2);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-badge.online .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-badge.offline .status-dot { background: var(--red); }

.mode-badge {
    padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600;
    background: var(--accent-dim); color: #fff; letter-spacing: 1px;
}

/* Main layout */
main { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.top-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.main-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; height: calc(100vh - 260px); min-height: 400px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.card-body { padding: 16px; display: flex; gap: 24px; }

.metric { display: flex; flex-direction: column; align-items: center; }
.metric-value { font-size: 28px; font-weight: 700; color: var(--text); }
.metric-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.external-link {
    font-size: 11px; color: var(--accent); text-decoration: none;
    padding: 2px 8px; border: 1px solid var(--accent-dim); border-radius: 4px;
}
.external-link:hover { background: var(--accent-dim); color: #fff; }

/* Project card metrics */
.metric-group { flex: 1; }
.metric-group-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.metric-row { display: flex; gap: 20px; }
.metric-divider { width: 1px; background: var(--border); margin: 0 4px; }

.card-footer {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; border-top: 1px solid var(--border);
}
.conversion-label { font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.conversion-bar {
    flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden;
}
.conversion-fill {
    height: 100%; background: var(--green); border-radius: 3px;
    transition: width 0.6s ease;
}
.conversion-pct { font-size: 12px; font-weight: 700; color: var(--green); min-width: 40px; text-align: right; }

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

.msg { max-width: 85%; padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent-dim); color: #fff; }
.msg.agent { align-self: flex-start; background: var(--surface-2); }
.msg.system { align-self: center; color: var(--text-dim); font-size: 11px; font-style: italic; }
.msg.streaming { border-left: 2px solid var(--accent); }

.chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
#chat-input {
    flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 6px; padding: 8px 12px; font-family: inherit; font-size: 13px; resize: none;
}
#chat-input:focus { outline: none; border-color: var(--accent); }
.btn-send {
    padding: 8px 20px; background: var(--accent); color: #fff; border: none;
    border-radius: 6px; font-family: inherit; font-weight: 600; cursor: pointer;
    font-size: 13px;
}
.btn-send:hover { background: var(--accent-dim); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small {
    font-size: 11px; padding: 2px 8px; background: transparent; color: var(--text-dim);
    border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-family: inherit;
}
.btn-small:hover { color: var(--text); border-color: var(--text-dim); }

/* Activity Log */
.log-card { display: flex; flex-direction: column; }
.activity-log { flex: 1; overflow-y: auto; padding: 12px 16px; font-size: 12px; }

.log-entry { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: baseline; }
.log-time { color: var(--text-dim); font-size: 11px; white-space: nowrap; }
.log-type { font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.log-type.tool { background: #1e3a5f; color: #60a5fa; }
.log-type.mode { background: #3b2f5e; color: #a78bfa; }
.log-type.error { background: #5f1e1e; color: var(--red); }
.log-type.info { background: #1e4d3a; color: var(--green); }
.log-msg { color: var(--text); }

#log-filter {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 4px; padding: 2px 8px; font-family: inherit; font-size: 11px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Tool Call Messages */
.msg.tool-call {
    align-self: flex-start;
    background: #1a2332;
    border: 1px solid #2a3a5a;
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
}
.msg.tool-call.tool-ok { border-left-color: var(--green); }
.msg.tool-call.tool-err { border-left-color: var(--red); }

.tool-icon { font-size: 16px; flex-shrink: 0; }
.tool-name { color: var(--accent); font-weight: 600; white-space: nowrap; }
.tool-args { color: var(--text-dim); font-size: 11px; margin-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.tool-args::before { content: '('; }
.tool-args::after { content: ')'; }

.tool-spinner {
    width: 12px; height: 12px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: tool-spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes tool-spin { to { transform: rotate(360deg); } }

.tool-badge {
    font-size: 10px; padding: 1px 8px; border-radius: 3px;
    font-weight: 600; white-space: nowrap; margin-left: auto;
}
.tool-badge.ok { background: #1e4d3a; color: var(--green); }
.tool-badge.err { background: #5f1e1e; color: var(--red); }

/* Responsive */
@media (max-width: 900px) {
    .top-row { grid-template-columns: 1fr; }
    .main-row { grid-template-columns: 1fr; height: auto; }
    .chat-card, .log-card { min-height: 400px; }
}
