/* ── GODCORE Dark Theme ───────────────────────────────────────────────── */
:root {
    --bg-dark: #0a0e17;
    --bg-card: #111827;
    --bg-sidebar: #0d1220;
    --bg-input: #1a2236;
    --bg-hover: #1e2a42;
    --bg-active: #1a2744;
    --border: #1e2a42;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --gold: #c8a86e;
    --blue: #3b82f6;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --radius: 8px;
    --sidebar-w: 200px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ── App Layout ──────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.logo-text { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: 1px; }

.sidebar-nav { padding: 8px 0; }

.nav-section { margin-bottom: 4px; }

.nav-label {
    display: block;
    padding: 12px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-muted);
    font-size: 13px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-active); color: var(--text); border-left-color: var(--gold); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

/* ── Main ────────────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-version { color: var(--text-dim); font-size: 12px; }
.topbar-user { color: var(--text-muted); font-size: 13px; }
.topbar-logout { color: var(--text); font-weight: 600; padding: 4px 12px; background: var(--bg-input); border-radius: var(--radius); font-size: 12px; }

.content { flex: 1; padding: 24px; overflow-y: auto; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-title { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.card-value { font-size: 24px; font-weight: 600; }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 16px; }

/* ── Status ───────────────────────────────────────────────────────────── */
.status-online, .status-running { color: var(--green); }
.status-offline, .status-error { color: var(--red); }
.status-idle { color: var(--text-dim); }
.status-busy { color: var(--orange); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}
.status-dot.status-online, .status-dot.status-idle { background: var(--green); }
.status-dot.status-busy { background: var(--orange); }
.status-dot.status-error { background: var(--red); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    color: var(--text);
    background: var(--bg-input);
    text-decoration: none;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn-primary { background: var(--gold); color: #000; }
.btn-primary:hover { background: #d4b87a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 700px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--text-muted); }
.form-group small { display: block; margin-top: 4px; color: var(--text-dim); font-size: 11px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }

input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
input:disabled, textarea:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
input[type="text"], input[type="password"], input[type="url"], input[type="email"], textarea, select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
input[type="color"] { width: 60px; height: 36px; padding: 2px; cursor: pointer; }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 11px; text-transform: uppercase; color: var(--text-dim); background: var(--bg-sidebar); }
.data-table td { font-size: 13px; }
.detail-table { width: 100%; }
.detail-table td { padding: 6px 0; }
.detail-table td:first-child { color: var(--text-dim); width: 120px; font-size: 12px; }

/* ── Role Tags ────────────────────────────────────────────────────────── */
.role-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-badge { padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.role-badge.role-user { background: var(--blue); color: #fff; }
.role-badge.role-assistant { background: var(--gold); color: #000; }

/* ── Agent Cards ──────────────────────────────────────────────────────── */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.agent-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.agent-card-info { flex: 1; }
.agent-card-name { font-weight: 600; font-size: 15px; }
.agent-card-id { font-size: 12px; color: var(--text-dim); }
.agent-card-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.agent-card-actions { display: flex; gap: 8px; }

.agent-avatar, .agent-avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--gold);
    flex-shrink: 0;
    overflow: hidden;
}
.agent-avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.agent-avatar img, .agent-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.agent-info { flex: 1; }
.agent-name { font-weight: 600; }
.agent-model { font-size: 12px; color: var(--text-dim); }

/* ── Chat Layout (3 columns) ─────────────────────────────────────────── */
.chat-layout {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 0;
    height: calc(100vh - 100px);
    margin: -24px;
}

.chat-agents {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.chat-agents-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.agent-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    position: relative;
    transition: background 0.15s;
}
.agent-entry:hover { background: var(--bg-hover); text-decoration: none; }
.agent-entry.active { background: var(--bg-active); border-left: 3px solid var(--gold); }

.agent-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
    overflow: hidden;
}
.agent-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

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

.agent-settings-icon {
    color: var(--text-dim);
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s;
}
.agent-entry:hover .agent-settings-icon { opacity: 1; }

/* ── Chat Main ────────────────────────────────────────────────────────── */
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.chat-header-name { font-weight: 600; font-size: 15px; }

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

.chat-msg { max-width: 100%; }
.chat-msg-assistant { padding: 16px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.chat-msg-user { padding: 12px 16px; background: var(--bg-active); border-radius: var(--radius); align-self: flex-end; max-width: 80%; }
.chat-msg-meta { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.chat-msg-time { color: var(--text-dim); font-size: 11px; }

.chat-msg-content { font-size: 14px; line-height: 1.6; }
.chat-msg-content pre { background: var(--bg-dark); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.chat-msg-content code { font-size: 13px; }
.chat-msg-content p { margin: 0 0 8px; }
.chat-msg-content p:last-child { margin-bottom: 0; }
.chat-msg-content h1, .chat-msg-content h2, .chat-msg-content h3, .chat-msg-content h4 { margin: 12px 0 6px; color: var(--gold); }
.chat-msg-content ul, .chat-msg-content ol { padding-left: 20px; margin: 8px 0; }
.chat-msg-content blockquote { border-left: 3px solid var(--gold); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }

.chat-input-area {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}
.chat-input-area form { display: flex; gap: 10px; align-items: flex-end; }
#chatInput {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 42px;
    max-height: 120px;
}
#chatInput:focus { outline: none; border-color: var(--gold); }
.chat-send { font-size: 18px; padding: 8px 16px; }

/* ── Chat User Messages (right column) ───────────────────────────────── */
.chat-user-msgs {
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 0;
}

.user-instruction {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── Alerts ───────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid var(--red); color: var(--red); }

/* ── Code Block ──────────────────────────────────────────────────────── */
.code-block { background: var(--bg-dark); padding: 12px; border-radius: 6px; font-size: 12px; overflow-x: auto; word-break: break-all; white-space: pre-wrap; }

/* ── Empty State ─────────────────────────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-dim); }

/* ── Page Header ─────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h2 { margin: 0; }

.truncate { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 380px;
    text-align: center;
}
.login-logo { margin-bottom: 24px; }
.login-logo h1 { font-size: 24px; letter-spacing: 2px; margin-top: 12px; }
.login-error { background: rgba(239,68,68,0.15); border: 1px solid var(--red); color: var(--red); padding: 10px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.login-container .form-group { text-align: left; }
.login-container .btn { margin-top: 8px; }

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--text-dim); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
