/* DeFiSage — dark theme, navy/teal accent, JetBrains Mono for data */

:root {
    --bg-0: #0b0f17;
    --bg-1: #111827;
    --bg-2: #1a2332;
    --bg-3: #243043;
    --border: #2d3a52;
    --text-1: #e6edf6;
    --text-2: #97a3b6;
    --text-3: #5b6677;
    --accent: #4ade80;
    --accent-2: #22d3ee;
    --warn: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
}

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

html, body {
    background: var(--bg-0);
    color: var(--text-1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }

code, pre, .mono {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 36px; }

.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: 0.4px; }
.logo-icon { font-size: 22px; }

.nav { display: flex; gap: 22px; }
.nav-link {
    color: var(--text-2);
    font-weight: 500;
    padding: 6px 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--text-1); }
.nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.header-right { display: flex; align-items: center; gap: 18px; }

.token-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}
.token-icon { color: var(--warn); }
.token-count { color: var(--accent); font-weight: 600; }
.token-label { color: var(--text-3); }

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
    animation: pulse 2s infinite;
}
.status-dot.error { background: var(--danger); box-shadow: 0 0 12px var(--danger); }

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

.tab-content { display: none; padding: 28px; max-width: 1280px; margin: 0 auto; }
.tab-content.active { display: block; }

.dashboard { display: flex; flex-direction: column; gap: 24px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.stat-icon { font-size: 22px; margin-bottom: 8px; }
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}
.stat-label {
    color: var(--text-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
}
.stat-bar {
    height: 4px;
    background: var(--bg-3);
    border-radius: 4px;
    margin-top: 12px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 100%);
    width: 0%;
    transition: width 0.4s ease;
}

.panel {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px;
}
.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.panel-sub { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.agent-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    transition: transform 0.2s, border-color 0.2s;
}
.agent-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.agent-icon { font-size: 22px; margin-bottom: 6px; }
.agent-name { font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.agent-desc { color: var(--text-2); font-size: 12.5px; line-height: 1.5; margin-bottom: 10px; }
.agent-tokens {
    color: var(--accent-2);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
}

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 140px;
    padding: 10px 0;
}
.trend-bar {
    flex: 1;
    background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
    border-radius: 4px 4px 0 0;
    min-height: 6px;
    position: relative;
    transition: opacity 0.2s;
}
.trend-bar:hover { opacity: 0.7; }
.trend-bar-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10.5px;
    color: var(--text-3);
    font-family: 'JetBrains Mono', monospace;
}
.empty-state {
    color: var(--text-3);
    text-align: center;
    padding: 32px;
    font-size: 13px;
}

.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.input-text {
    flex: 1;
    min-width: 180px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-1);
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}
.input-text:focus { border-color: var(--accent); }

.code-area {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-1);
    padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    line-height: 1.6;
    outline: none;
    resize: vertical;
    min-height: 320px;
    margin: 12px 0;
}
.code-area:focus { border-color: var(--accent); }

.btn-primary, .btn-secondary {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: var(--bg-0);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-2);
    color: var(--text-1);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-3); }

.check-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
}
.check-row input[type="checkbox"] { accent-color: var(--accent); }

.result-area {
    margin-top: 18px;
    padding: 18px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    min-height: 80px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-1);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 720px;
    overflow-y: auto;
}
.result-area:empty::before {
    content: "Results will appear here...";
    color: var(--text-3);
}

.result-section {
    margin-bottom: 18px;
    padding: 14px;
    background: var(--bg-1);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
}
.result-section h4 {
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-family: 'Inter', sans-serif;
}
.result-section .meta {
    color: var(--text-3);
    font-size: 11.5px;
    margin-bottom: 8px;
}

.severity-critical { color: #ef4444; font-weight: 700; }
.severity-high { color: #f59e0b; font-weight: 600; }
.severity-medium { color: #fbbf24; }
.severity-low { color: var(--accent-2); }

.chat-panel {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 520px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.chat-msg {
    padding: 12px 16px;
    border-radius: 10px;
    max-width: 86%;
    line-height: 1.6;
}
.chat-msg.user {
    background: var(--bg-3);
    align-self: flex-end;
    border: 1px solid var(--border);
}
.chat-msg.agent {
    background: var(--bg-2);
    align-self: flex-start;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}
.chat-msg.system {
    background: transparent;
    color: var(--text-3);
    font-style: italic;
    text-align: center;
    align-self: center;
    font-size: 12.5px;
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-1);
    padding: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    resize: vertical;
    outline: none;
}
.chat-input:focus { border-color: var(--accent); }

.footer {
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    background: var(--bg-1);
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    .header { flex-direction: column; gap: 12px; padding: 12px 16px; }
    .nav { gap: 12px; }
    .tab-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { flex-direction: column; align-items: stretch; }
    .input-text { width: 100%; }
}
