/* ==========================================================================
   Aegis SIEM — SOC Console UI
   Aesthetic: Dense, technical, Bloomberg-terminal-meets-modern-fintech.
   Dark theme by default. Sharp edges, precise typography, data-first.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@500;600;700&family=Geist:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Surfaces */
    --bg-base:       #07090f;
    --bg-surface:    #0d1117;
    --bg-elevated:   #131a24;
    --bg-overlay:    #1a2030;
    --bg-hover:      #1f2937;

    /* Borders */
    --border-subtle: #1a2030;
    --border-default:#243042;
    --border-strong: #334155;

    /* Text */
    --text-primary:  #e6edf3;
    --text-secondary:#94a3b8;
    --text-muted:    #64748b;
    --text-faint:    #475569;

    /* Brand & semantic */
    --accent:        #22d3ee;   /* cyan */
    --accent-dim:    #0891b2;
    --accent-glow:   rgba(34, 211, 238, 0.15);

    --crit:          #ef4444;
    --high:          #f97316;
    --med:           #eab308;
    --low:           #3b82f6;
    --info:          #64748b;
    --ok:            #10b981;

    /* Fonts */
    --font-display:  'Bricolage Grotesque', system-ui, sans-serif;
    --font-body:     'Geist', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', 'Courier New', monospace;

    /* Sizing */
    --sidebar-w:     232px;
    --topbar-h:      56px;
    --radius-sm:     4px;
    --radius:        6px;
    --radius-lg:     10px;

    /* Shadows */
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.4);
    --shadow:        0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:     0 16px 48px rgba(0,0,0,0.6);
}

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

html, body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Subtle scanline texture background for that terminal feel */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(34, 211, 238, 0.012) 0px,
        rgba(34, 211, 238, 0.012) 1px,
        transparent 1px,
        transparent 3px
    );
    z-index: 1;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

/* ---------- Sidebar ---------- */
.sidebar {
    grid-area: sidebar;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 14px 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 18px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 8px;
}
.brand-logo {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    border-radius: var(--radius);
    display: grid; place-items: center;
    color: #001018; font-weight: 700;
    font-family: var(--font-display);
    box-shadow: 0 0 24px var(--accent-glow);
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
}
.brand-name small {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-family: var(--font-mono);
}

.nav-section {
    padding: 12px 12px 4px;
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-family: var(--font-mono);
    font-weight: 500;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 16px;
    margin: 1px 8px;
    color: var(--text-secondary);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: background 0.12s, color 0.12s;
}
.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--bg-elevated);
    color: var(--accent);
    border-left-color: var(--accent);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.nav-item .badge {
    margin-left: auto;
    font-size: 10px;
    background: var(--crit);
    color: #fff;
    padding: 2px 6px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: flex; align-items: center; gap: 8px;
}
.health-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok);
    animation: pulse 2s infinite;
}
.health-dot.bad { background: var(--crit); box-shadow: 0 0 8px var(--crit); }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---------- Topbar ---------- */
.topbar {
    grid-area: topbar;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.page-title .crumb {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 8px;
}
.page-title .crumb::after { content: '/'; margin-left: 8px; }

.topbar-spacer { flex: 1; }

.global-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}
.global-search input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 7px 12px 7px 34px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12.5px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.global-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.global-search::before {
    content: '⌕';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 12.5px;
    cursor: pointer;
    color: var(--text-primary);
}
.user-chip:hover { background: var(--bg-hover); text-decoration: none; }
.user-avatar {
    width: 24px; height: 24px;
    background: linear-gradient(135deg, var(--accent-dim), #6366f1);
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 600;
    color: #fff;
}

/* ---------- Main content ---------- */
.main {
    grid-area: main;
    padding: 20px 24px 40px;
    max-width: 100%;
    overflow-x: hidden;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.toolbar h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
}
.toolbar h1 small {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 10px;
    letter-spacing: 0.05em;
}
.toolbar-spacer { flex: 1; }

/* ==========================================================================
   Cards, panels, grids
   ========================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.card-head h3 {
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.card-head .subtle {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-left: auto;
}
.card-body { padding: 16px; }

.grid {
    display: grid;
    gap: 14px;
}
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) {
    .grid-cols-3, .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
    .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .sidebar { display: none; }
}

/* ==========================================================================
   Metric tiles (the SOC overview "vitals")
   ========================================================================== */

.metric {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.metric::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    opacity: 0.7;
}
.metric.crit::before { background: var(--crit); }
.metric.high::before { background: var(--high); }
.metric.ok::before   { background: var(--ok); }
.metric.warn::before { background: var(--med); }

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-bottom: 6px;
}
.metric-value {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text-primary);
}
.metric-trend {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 4px;
}
.metric-trend.up { color: var(--crit); }
.metric-trend.down { color: var(--ok); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-subtle);
}
table.data th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-mono);
    background: var(--bg-base);
    position: sticky; top: 0;
}
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr.selected { background: var(--accent-glow); }
table.data td .ip, table.data td .hash, table.data td .uri {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-secondary);
}
table.data td a { color: var(--text-primary); font-weight: 500; }

/* ==========================================================================
   Badges
   ========================================================================== */

.severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: var(--font-mono);
    border: 1px solid;
}
.sev-critical { color: var(--crit); border-color: var(--crit); background: rgba(239, 68, 68, 0.1); }
.sev-high     { color: var(--high); border-color: var(--high); background: rgba(249, 115, 22, 0.1); }
.sev-medium   { color: var(--med);  border-color: var(--med);  background: rgba(234, 179, 8, 0.1); }
.sev-low      { color: var(--low);  border-color: var(--low);  background: rgba(59, 130, 246, 0.1); }
.sev-info     { color: var(--info); border-color: var(--info); background: rgba(100, 116, 139, 0.1); }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}
.status-open    { background: rgba(239, 68, 68, 0.15);  color: var(--crit); }
.status-progress { background: rgba(234, 179, 8, 0.15); color: var(--med); }
.status-closed  { background: rgba(16, 185, 129, 0.15); color: var(--ok); }
.status-fp      { background: rgba(100, 116, 139, 0.2); color: var(--text-secondary); }
.status-ack     { background: rgba(59, 130, 246, 0.15); color: var(--low); }

.tag {
    display: inline-block;
    padding: 1px 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 10.5px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-right: 3px;
}

/* ==========================================================================
   Forms & buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.12s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); text-decoration: none; }
.btn-primary {
    background: var(--accent);
    color: #001018;
    border-color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover { background: #67e8f9; border-color: #67e8f9; color: #001018; }
.btn-danger {
    background: transparent;
    color: var(--crit);
    border-color: var(--crit);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); color: var(--crit); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

input[type=text], input[type=password], input[type=email], input[type=search],
input[type=number], textarea, select {
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: 7px 12px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-group { margin-bottom: 14px; }
.field-group label {
    display: block;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
textarea { font-family: var(--font-mono); min-height: 84px; resize: vertical; }

/* The big search bar (Hunt page) */
.query-bar {
    display: flex;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 10px;
    align-items: center;
}
.query-bar input[type=text] {
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 6px 8px;
}
.query-bar input[type=text]:focus { box-shadow: none; }
.query-bar select {
    width: auto;
    background: var(--bg-base);
}
.query-bar .btn { white-space: nowrap; }

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.4;
    font-family: var(--font-mono);
}
.empty h3 {
    font-family: var(--font-display);
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 15px;
}
.empty p { font-size: 13px; }

/* ==========================================================================
   Alerts (flash messages)
   ========================================================================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid;
}
.alert-error   { background: rgba(239, 68, 68, 0.1); border-color: var(--crit); color: #fca5a5; }
.alert-success { background: rgba(16, 185, 129, 0.1); border-color: var(--ok); color: #86efac; }
.alert-info    { background: rgba(34, 211, 238, 0.08); border-color: var(--accent); color: #a5f3fc; }

/* ==========================================================================
   Login page
   ========================================================================== */
.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                var(--bg-base);
    position: relative;
}
.login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}
.login-card {
    width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 2;
}
.login-card .brand { padding: 0 0 20px; margin-bottom: 20px; }
.login-card h1 {
    font-family: var(--font-display);
    font-size: 20px;
    margin-bottom: 6px;
    font-weight: 700;
}
.login-card .subtitle {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-bottom: 24px;
    font-family: var(--font-mono);
}

/* ==========================================================================
   Detail panes & timelines
   ========================================================================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
}
@media (max-width: 1100px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.kv-list { font-size: 13px; }
.kv-list > div {
    display: flex;
    padding: 7px 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}
.kv-list > div:last-child { border-bottom: none; }
.kv-list .k {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    min-width: 130px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.kv-list .v {
    font-family: var(--font-mono);
    color: var(--text-primary);
    word-break: break-all;
}

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 6px; top: 4px; bottom: 4px;
    width: 2px;
    background: var(--border-default);
}
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-surface);
    box-shadow: 0 0 0 1px var(--accent);
}
.timeline-item .time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}
.timeline-item .what { font-size: 13px; margin-top: 2px; }

/* ==========================================================================
   Pagination
   ========================================================================== */
.pager {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}
.pager .btn-sm { font-family: var(--font-mono); }

/* ==========================================================================
   Chart container
   ========================================================================== */
.chart-box {
    position: relative;
    height: 260px;
    width: 100%;
}
.chart-box.small { height: 180px; }
.chart-box.large { height: 340px; }

/* ==========================================================================
   Utility
   ========================================================================== */
.muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-crit { color: var(--crit); }
.text-ok { color: var(--ok); }
.no-wrap { white-space: nowrap; }
.truncate {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
