/* StartBox Labs - Dashboard dark mode */

:root {
    --bg-0: #0b0f17;
    --bg-1: #111725;
    --bg-2: #17203099;
    --bg-3: #1c2637;
    --border: #253048;
    --border-soft: #1e2739;
    --text: #e6ecf5;
    --text-muted: #8b95a7;
    --text-dim: #5c6577;
    --accent: #E4C88E;
    --accent-2: #B08A3E;
    --accent-glow: rgba(228, 200, 142, 0.30);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #38bdf8;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(228, 200, 142, 0.08), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(176, 138, 62, 0.08), transparent 60%),
        var(--bg-0);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

/* ---------- Layout ---------- */

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, var(--bg-1), #0d1220);
    border-right: 1px solid var(--border-soft);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 4px 14px;
    border-bottom: 1px solid var(--border-soft);
}

.brand__logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: grid; place-items: center;
    font-weight: 700; color: #fff;
    box-shadow: 0 6px 18px var(--accent-glow);
}

.brand__text h1 {
    font-size: 1.05rem;
}
.brand__text h1 span { color: var(--accent); }
.brand__text p { font-size: 0.75rem; color: var(--text-muted); }

.sidebar__title {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    margin: 0 4px 8px;
}

.agents-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agents-list__empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 12px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.agent-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.agent-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.agent-card--active {
    border-color: var(--warning);
    box-shadow: 0 0 0 1px var(--warning), 0 0 16px rgba(245, 158, 11, 0.25);
    animation: pulse-active 1.6s ease-in-out infinite;
}
@keyframes pulse-active {
    0%, 100% { box-shadow: 0 0 0 1px var(--warning), 0 0 12px rgba(245, 158, 11, 0.20); }
    50%      { box-shadow: 0 0 0 1px var(--warning), 0 0 22px rgba(245, 158, 11, 0.45); }
}

.agent-card__body { min-width: 0; }
.agent-card__name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-card__id {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-dim);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}
.badge--idle    { color: var(--success); background: rgba(34, 197, 94, 0.10);  border-color: rgba(34, 197, 94, 0.30); }
.badge--working { color: var(--warning); background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.badge--error   { color: var(--danger);  background: rgba(239, 68, 68, 0.12);  border-color: rgba(239, 68, 68, 0.35); }
.badge--unknown { color: var(--text-dim); background: rgba(255,255,255,0.04);  border-color: var(--border); }

/* ---------- API status ---------- */

.sidebar__footer { margin-top: auto; }

.api-status {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: var(--bg-2);
    font-size: 0.78rem;
}
.api-status .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-dim);
    box-shadow: 0 0 6px currentColor;
}
.api-status--ok      .dot { background: var(--success); }
.api-status--ok      .label { color: var(--success); }
.api-status--down    .dot { background: var(--danger); }
.api-status--down    .label { color: var(--danger); }
.api-status--unknown .label { color: var(--text-muted); }

/* ---------- Main ---------- */

.main {
    padding: 28px 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.main__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.main__header h2 { font-size: 1.35rem; }

.card {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.00)) var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

/* ---------- Form ---------- */

.mission-form { display: flex; flex-direction: column; gap: 12px; }
.mission-form__label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.mission-form textarea {
    width: 100%;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: var(--font);
    font-size: 0.95rem;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mission-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.mission-form__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.mission-form__hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    color: var(--text);
    background: var(--bg-3);
    border-color: var(--border);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn--sm { padding: 6px 10px; font-size: 0.8rem; }

.btn--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    box-shadow: 0 8px 24px var(--accent-glow);
    color: #fff;
}
.btn--primary:hover { box-shadow: 0 12px 30px var(--accent-glow); }

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

.btn__spinner {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Terminal / Logs ---------- */

.card--terminal { padding: 0; overflow: hidden; }

.terminal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #0e1421;
    border-bottom: 1px solid var(--border-soft);
}
.terminal__header h3 {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.terminal__dots { display: flex; gap: 6px; }
.terminal__dots span {
    width: 10px; height: 10px; border-radius: 50%;
    background: #2a3552;
}
.terminal__dots span:nth-child(1) { background: #ef4444; }
.terminal__dots span:nth-child(2) { background: #f59e0b; }
.terminal__dots span:nth-child(3) { background: #22c55e; }

.terminal__body {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 14px 16px;
    max-height: 460px;
    overflow-y: auto;
    background:
        linear-gradient(180deg, #0a1020, #0b1120);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log {
    display: grid;
    grid-template-columns: 90px 110px 1fr;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    align-items: baseline;
}
.log__time   { color: var(--text-dim); }
.log__source { color: var(--accent); font-weight: 600; }
.log__msg    { color: var(--text); white-space: pre-wrap; word-break: break-word; }

.log--info    .log__source { color: var(--info); }
.log--success .log__source { color: var(--success); }
.log--warning .log__source { color: var(--warning); }
.log--error   .log__source { color: var(--danger); }
.log--error   { background: rgba(239, 68, 68, 0.06); }
.log--agent   .log__source { color: var(--accent-2); }

/* ---------- Human-in-the-loop approval block ---------- */

.human-approval {
    margin: 12px 0;
    padding: 18px 20px;
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-left: 4px solid var(--warning);
    background:
        linear-gradient(180deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.04));
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.10);
    font-family: var(--font);
    animation: pop-in 0.25s ease-out;
}
@keyframes pop-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.human-approval__header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.human-approval__icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--warning);
    color: #1a120a;
    display: grid; place-items: center;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}
.human-approval__title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warning);
    font-weight: 700;
}
.human-approval__from {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.human-approval__question {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    max-height: 260px;
    overflow-y: auto;
}

.human-approval__label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}
.human-approval__textarea {
    width: 100%;
    min-height: 70px;
    padding: 10px 12px;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.human-approval__textarea:focus {
    outline: none;
    border-color: var(--warning);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

.human-approval__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.btn--approve {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 22px rgba(34, 197, 94, 0.30);
}
.btn--approve:hover { box-shadow: 0 12px 28px rgba(34, 197, 94, 0.40); }

.btn--reject {
    background: linear-gradient(135deg, #dc2626, #f97316);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.30);
}
.btn--reject:hover { box-shadow: 0 12px 28px rgba(239, 68, 68, 0.40); }

.human-approval--resolved {
    opacity: 0.6;
    filter: grayscale(0.35);
    pointer-events: none;
}
.human-approval__resolved-label {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #202a40;
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #2d3a58; background-clip: padding-box; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
    }
    .main { padding: 20px; }
    .log { grid-template-columns: 70px 90px 1fr; gap: 8px; font-size: 0.8rem; }
}
