/* Terminal-style dark theme for secdashboards */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --green: #3fb950;
    --green-dim: #238636;
    --cyan: #58a6ff;
    --red: #f85149;
    --yellow: #d29922;
    --orange: #db6d28;
    --purple: #bc8cff;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

body {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

/* Navigation */
.nav-brand {
    padding: 0.5rem 1rem 1.5rem;
    color: var(--green);
    font-weight: bold;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-left-color: var(--cyan);
}

.nav-link.active {
    color: var(--cyan);
    border-left-color: var(--cyan);
    background: var(--bg-tertiary);
}

.nav-section {
    padding: 0.8rem 1rem 0.3rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Typography */
h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; color: var(--cyan); }
h3 { font-size: 1rem; }

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-secondary);
    font-weight: normal;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover {
    background: var(--bg-tertiary);
}

/* Status indicators */
.status-ok { color: var(--green); }
.status-warn { color: var(--yellow); }
.status-error { color: var(--red); }
.status-info { color: var(--cyan); }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge-ok { background: var(--green-dim); color: var(--green); }
.badge-error { background: #3d1214; color: var(--red); }
.badge-warn { background: #3d2e00; color: var(--yellow); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-primary { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.btn-primary:hover { background: var(--green); color: var(--bg-primary); }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    border-left: 4px solid;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.alert-success { border-color: var(--green); background: rgba(63, 185, 80, 0.1); }
.alert-error { border-color: var(--red); background: rgba(248, 81, 73, 0.1); }
.alert-warning { border-color: var(--yellow); background: rgba(210, 153, 34, 0.1); }
.alert-info { border-color: var(--cyan); background: rgba(88, 166, 255, 0.1); }

/* Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* HTMX loading indicator */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid var(--border);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Form elements */
select, input, textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--cyan);
}

/* Stat cards */
.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--green);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Rule tags */
.rule-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    margin: 0.1rem 0.15rem;
    border-radius: 3px;
    font-size: 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* Detection result stat boxes */
.result-stat {
    text-align: center;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

/* Triggered card highlight */
.card-triggered {
    border-color: var(--red);
    border-left: 3px solid var(--red);
}

/* Match results table */
.match-table td {
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
}

.match-table th {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

/* ─── Timeline Panel ──────────────────────────── */
.timeline-panel {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.timeline-filter-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.timeline-filter-btn {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.timeline-filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.timeline-filter-btn.active {
    color: var(--cyan);
    border-color: var(--cyan);
    background: rgba(88, 166, 255, 0.1);
}

.timeline-event {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-left: 2px solid var(--border);
    margin-left: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.timeline-event:hover {
    background: var(--bg-tertiary);
}

.timeline-event.selected {
    background: rgba(88, 166, 255, 0.08);
    border-left-color: var(--cyan);
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0.75rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--bg-secondary);
}

.timeline-event.tag-suspicious::before,
.timeline-event.tag-attack_phase::before,
.timeline-event.tag-initial_access::before,
.timeline-event.tag-data_exfiltration::before,
.timeline-event.tag-impact::before {
    background: var(--red);
}

.timeline-event.tag-important::before {
    background: var(--yellow);
}

.timeline-event.tag-benign::before {
    background: var(--green);
}

.timeline-event.tag-persistence::before,
.timeline-event.tag-privilege_escalation::before {
    background: var(--purple);
}

.timeline-event.tag-lateral_movement::before {
    background: var(--orange);
}

.timeline-time {
    flex-shrink: 0;
    width: 7rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    padding-top: 0.1rem;
}

.timeline-body {
    flex: 1;
    min-width: 0;
}

.timeline-title {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.timeline-tag {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
