/* ═══════════════════════════════════════════════════
   AGENT KAI — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

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

:root {
    --gold:   #FFD700;
    --orange: #F97316;
    --green:  #22C55E;
    --purple: #A78BFA;
    --blue:   #3B82F6;
    --bg:     #0a0f0a;
    --surface: rgba(255,255,255,0.04);
    --border:  rgba(255,255,255,0.08);
    --text:    rgba(255,255,255,0.9);
    --dim:     rgba(255,255,255,0.45);
    --sidebar-w: 230px;
}

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* ── LAYOUT ── */
.app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: rgba(0,0,0,0.5);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 10px;
    gap: 8px;
    overflow-y: auto;
    transition: width 0.3s ease;
    backdrop-filter: blur(10px);
}

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

.logo-orb {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--orange));
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 900; color: #1B4332;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(255,215,0,0.5);
}

.logo-title { font-size: 13px; font-weight: 900; letter-spacing: 2px; color: var(--gold); }
.logo-sub   { font-size: 9px; color: var(--dim); letter-spacing: 1px; margin-top: 1px; }

.collapse-btn {
    margin-left: auto; background: transparent; border: none;
    color: var(--dim); cursor: pointer; font-size: 16px;
}

.nav-label {
    font-size: 9px; font-weight: 700; color: var(--dim);
    letter-spacing: 2px; padding: 8px 8px 4px; text-transform: uppercase;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    text-decoration: none; color: var(--dim);
    font-size: 13px; font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: rgba(255,215,0,0.1); color: var(--gold); font-weight: 700; }

.nav-icon { font-size: 16px; flex-shrink: 0; }

/* Agent panel */
.agent-panel { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

.agent-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; font-size: 11px; color: var(--dim);
    border-radius: 8px; transition: background 0.3s;
}
.agent-item.active-agent { background: rgba(255,215,0,0.08); color: var(--gold); }

.agent-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green); flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}
.agent-dot.busy { background: var(--gold); }
.agent-dot.idle { background: rgba(255,255,255,0.2); animation: none; }

@keyframes pulse-dot {
    0%,100% { opacity:1; transform:scale(1); }
    50%      { opacity:0.5; transform:scale(0.7); }
}

/* Sidebar footer */
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--orange));
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; color: #1B4332; font-size: 14px;
}
.user-name { font-size: 12px; font-weight: 700; }
.user-tag  { font-size: 10px; color: var(--dim); }

/* ── MAIN ── */
.main {
    flex: 1;
    display: flex; flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Top bar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.view-label  { font-size: 14px; font-weight: 800; }
.network-badge {
    font-size: 9px; font-weight: 700; color: var(--green);
    letter-spacing: 1px;
}

.icon-btn {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px 10px; cursor: pointer;
    color: var(--dim); font-size: 13px; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* ── THINKING BAR ── */
.thinking-bar {
    padding: 10px 20px;
    background: rgba(255,215,0,0.04);
    border-bottom: 1px solid rgba(255,215,0,0.15);
    flex-shrink: 0;
}

.thinking-steps {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}

.thinking-step {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.4;
}

.thinking-step.pending {
    color: var(--dim);
    border-color: rgba(255,255,255,0.1);
}

.thinking-step.active {
    color: var(--gold);
    border-color: rgba(255,215,0,0.4);
    background: rgba(255,215,0,0.08);
    opacity: 1;
}

.thinking-step.done {
    color: var(--green);
    border-color: rgba(34,197,94,0.3);
    background: rgba(34,197,94,0.06);
    opacity: 1;
}

.step-dot {
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

.thinking-step.active .step-dot {
    animation: pulse-dot 0.8s ease-in-out infinite;
}

.thinking-arrow { color: var(--dim); font-size: 10px; flex-shrink: 0; }

/* ── CHAT VIEW ── */
.chat-view {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

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

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Welcome */
.welcome {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; height: 100%;
    padding: 30px;
}
.welcome-orb { font-size: 52px; margin-bottom: 12px; }
.welcome-title { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.welcome-sub { color: var(--dim); font-size: 12px; margin-bottom: 24px; }

.quick-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; max-width: 480px; width: 100%;
}

.quick-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px 16px;
    font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
    text-align: left; transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}
.quick-card:hover {
    background: rgba(255,215,0,0.08);
    border-color: rgba(255,215,0,0.3);
    color: var(--gold);
    transform: translateY(-2px);
}

/* Messages */
.msg { display: flex; gap: 12px; max-width: 820px; }
.msg.user { flex-direction: row-reverse; align-self: flex-end; }
.msg.ai   { align-self: flex-start; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 900; align-self: flex-end;
}

.msg.user .msg-avatar {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: #1B4332;
}

.msg.ai .msg-avatar {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,215,0,0.2);
}

.msg-body { display: flex; flex-direction: column; gap: 4px; max-width: calc(100% - 44px); }

.msg-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; font-weight: 700; padding: 3px 8px;
    border-radius: 999px; align-self: flex-start;
    background: rgba(255,215,0,0.1); color: var(--gold);
    border: 1px solid rgba(255,215,0,0.2);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.msg-text {
    padding: 12px 16px; border-radius: 18px;
    font-size: 13px; line-height: 1.7;
}

.msg.user .msg-text {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: #1B4332; font-weight: 600;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(255,215,0,0.25);
}

.msg.ai .msg-text {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,215,0,0.15);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.msg-text b  { color: var(--gold); }
.msg-text code {
    background: rgba(255,255,255,0.08); border-radius: 4px;
    padding: 1px 5px; font-size: 12px; color: var(--purple);
    font-family: 'Courier New', monospace;
}
.msg-text h3 { font-size: 14px; color: var(--gold); margin-bottom: 8px; }

/* Typing Indicator */
.typing-indicator {
    display: flex; gap: 5px; align-items: center;
    padding: 14px 18px;
}
.typing-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.typing-dot:nth-child(1) { animation: typing 1s ease-in-out 0s infinite; }
.typing-dot:nth-child(2) { animation: typing 1s ease-in-out 0.2s infinite; }
.typing-dot:nth-child(3) { animation: typing 1s ease-in-out 0.4s infinite; }

@keyframes typing {
    0%,100% { opacity:0.2; transform:scale(0.8); }
    50%      { opacity:1;   transform:scale(1.2); }
}

/* ── INPUT DOCK ── */
.input-dock {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.input-box {
    display: flex; align-items: flex-end; gap: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,215,0,0.2);
    border-radius: 16px; padding: 8px 8px 8px 12px;
    transition: border-color 0.2s;
}
.input-box:focus-within { border-color: rgba(255,215,0,0.5); }

.input-icon-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 18px; padding: 4px; flex-shrink: 0;
    opacity: 0.6; transition: opacity 0.2s;
}
.input-icon-btn:hover { opacity: 1; }
.input-icon-btn.recording { animation: pulse-dot 0.6s ease-in-out infinite; }

#user-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text); font-size: 13px; font-family: 'Inter', sans-serif;
    resize: none; max-height: 120px; line-height: 1.6;
    padding: 4px 0;
}
#user-input::placeholder { color: var(--dim); }

.send-btn {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--gold), var(--orange));
    border: none; cursor: pointer; font-size: 16px; font-weight: 900;
    color: #1B4332; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; box-shadow: 0 0 12px rgba(255,215,0,0.3);
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.send-btn:not(:disabled):hover { transform: scale(1.05); }

.input-hint {
    font-size: 10px; color: var(--dim); text-align: center; margin-top: 8px;
}

/* ── DATA VIEW ── */
.data-view {
    flex: 1; overflow-y: auto; padding: 24px;
}

.data-panel { max-width: 780px; margin: 0 auto; }

.data-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px; padding: 20px; margin-bottom: 12px;
}

.data-card h3 {
    font-size: 15px; font-weight: 800; margin-bottom: 12px;
    color: var(--gold);
}

.data-table {
    width: 100%; border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 10px 12px; text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 12px;
}

.data-table th { color: var(--dim); font-weight: 600; }
.data-table td { color: var(--text); }

.badge-apy {
    background: rgba(34,197,94,0.2); color: var(--green);
    padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 11px;
}

.stat-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    margin-bottom: 16px;
}

.stat-box {
    background: rgba(255,255,255,0.04); border-radius: 12px; padding: 14px;
    text-align: center; border: 1px solid var(--border);
}
.stat-val { font-size: 20px; font-weight: 900; color: var(--gold); }
.stat-lbl { font-size: 10px; color: var(--dim); margin-top: 4px; font-weight: 600; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
