/* =============================================================
   CrowdSec UI — Industrial Dark Dashboard
   Palette: near-black surfaces · electric cyan accent · threat-red · safe-green
   Fonts: JetBrains Mono (data) · IBM Plex Sans (UI)
   ============================================================= */

/* ---------------------------------------------------------------
   CSS Variables
--------------------------------------------------------------- */
:root {
    --s-950: #04070d;
    --s-900: #080b10;
    --s-800: #0d1117;
    --s-700: #111823;
    --s-600: #182030;
    --s-500: #1e2a3f;
    --accent: #00d4ff;
    --accent-dim: #0099bb;
    --threat: #ff3b3b;
    --threat-dim: #cc2222;
    --safe: #00e676;
    --safe-dim: #00a854;
    --warn: #ffb300;
    --warn-dim: #cc8800;
    --muted: #4a5568;
    --border: rgba(255,255,255,0.06);
    --sidebar-w: 240px;
}

/* ---------------------------------------------------------------
   Global reset & base
--------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: var(--s-950);
    color: #c9d1d9;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--s-950); }
::-webkit-scrollbar-thumb { background: var(--s-600); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ---------------------------------------------------------------
   Sidebar
--------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--s-900);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

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

.logo-icon {
    width: 32px;
    height: 32px;
    background: rgba(0,212,255,0.08);
    border: 1px solid rgba(0,212,255,0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-name {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 13px;
    color: #e6edf3;
    line-height: 1.2;
}

.logo-sub {
    display: block;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #6e7681;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    margin-bottom: 2px;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    color: #c9d1d9;
    background: rgba(255,255,255,0.04);
}

.nav-item--active {
    color: var(--accent);
    background: rgba(0,212,255,0.06);
    border-left-color: var(--accent);
}

.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.cli-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
}

.cli-badge--ok   { color: var(--safe);  background: rgba(0,230,118,0.08); }
.cli-badge--warn { color: var(--warn);  background: rgba(255,179,0,0.08); }

.version-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
}

/* Mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
}

/* ---------------------------------------------------------------
   Status pill
--------------------------------------------------------------- */
.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
}

.status-pill--loading { background: rgba(74,85,104,0.3); color: var(--muted); }
.status-pill--healthy { background: rgba(0,230,118,0.1); color: var(--safe); border: 1px solid rgba(0,230,118,0.2); }
.status-pill--unhealthy { background: rgba(255,59,59,0.1); color: var(--threat); border: 1px solid rgba(255,59,59,0.2); }

.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------------------------------------------------------------
   Top bar
--------------------------------------------------------------- */
.topbar {
    height: 52px;
    background: var(--s-900);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    flex-shrink: 0;
}

.topbar-menu-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: none;
}
.topbar-menu-btn:hover { color: #c9d1d9; }

@media (max-width: 768px) { .topbar-menu-btn { display: flex; } }

.topbar-breadcrumb { flex: 1; }
.topbar-page { font-weight: 600; font-size: 14px; color: #e6edf3; }

/* ---------------------------------------------------------------
   Flash messages
--------------------------------------------------------------- */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.flash--success { background: rgba(0,230,118,0.08); color: var(--safe); border-left: 3px solid var(--safe); }
.flash--error   { background: rgba(255,59,59,0.08); color: var(--threat); border-left: 3px solid var(--threat); }
.flash--warning { background: rgba(255,179,0,0.08); color: var(--warn); border-left: 3px solid var(--warn); }
.flash--info    { background: rgba(0,212,255,0.08); color: var(--accent); border-left: 3px solid var(--accent); }

.flash-icon { font-size: 14px; flex-shrink: 0; }
.flash-text { flex: 1; }
.flash-close {
    background: none; border: none; cursor: pointer;
    color: currentColor; opacity: 0.6; font-size: 12px; padding: 2px 6px;
}
.flash-close:hover { opacity: 1; }

/* ---------------------------------------------------------------
   Page headings
--------------------------------------------------------------- */
.page-title {
    font-size: 22px;
    font-weight: 600;
    color: #e6edf3;
    line-height: 1.2;
}
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------
   Stat cards
--------------------------------------------------------------- */
.stat-card {
    background: var(--s-800);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    border-top: 2px solid transparent;
    transition: border-color 0.2s;
}

.stat-card--threat { border-top-color: var(--threat); }
.stat-card--warn   { border-top-color: var(--warn); }
.stat-card--accent { border-top-color: var(--accent); }
.stat-card--safe   { border-top-color: var(--safe); }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 32px; font-weight: 600; line-height: 1; color: #e6edf3; margin-bottom: 4px; }
.stat-sub   { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------
   Panels
--------------------------------------------------------------- */
.panel {
    background: var(--s-800);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 13px; font-weight: 600; color: #e6edf3; }
.panel-link  { font-size: 12px; color: var(--accent); text-decoration: none; }
.panel-link:hover { text-decoration: underline; }

.panel-body { padding: 16px 18px; }

/* ---------------------------------------------------------------
   Data tables
--------------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--s-700);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
    color: #c9d1d9;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ---------------------------------------------------------------
   Badges
--------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

.badge-red    { background: rgba(255,59,59,0.15);  color: #ff7b7b; border: 1px solid rgba(255,59,59,0.25); }
.badge-amber  { background: rgba(255,179,0,0.12);  color: #ffc233; border: 1px solid rgba(255,179,0,0.2); }
.badge-green  { background: rgba(0,230,118,0.1);   color: #33e68e; border: 1px solid rgba(0,230,118,0.2); }
.badge-cyan   { background: rgba(0,212,255,0.1);   color: #33deff; border: 1px solid rgba(0,212,255,0.2); }
.badge-blue   { background: rgba(58,130,246,0.15); color: #60a5fa; border: 1px solid rgba(58,130,246,0.2); }
.badge-purple { background: rgba(139,92,246,0.12); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }
.badge-gray   { background: rgba(74,85,104,0.3);   color: #8b949e; border: 1px solid rgba(74,85,104,0.3); }

/* ---------------------------------------------------------------
   Buttons
--------------------------------------------------------------- */
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px;
    background: var(--accent);
    color: #000;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}
.btn-primary:hover   { background: var(--accent-dim); }
.btn-primary:active  { transform: scale(0.97); }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: var(--s-600);
    color: #c9d1d9;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-secondary:hover { background: var(--s-500); }

.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.btn-ghost:hover { color: #c9d1d9; border-color: rgba(255,255,255,0.15); }

.btn-danger-sm {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(255,59,59,0.08);
    color: var(--threat);
    border: 1px solid rgba(255,59,59,0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-danger-sm:hover { background: rgba(255,59,59,0.18); }

.btn-safe-sm {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(0,230,118,0.08);
    color: var(--safe);
    border: 1px solid rgba(0,230,118,0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-safe-sm:hover { background: rgba(0,230,118,0.18); }

.btn-ghost-sm {
    padding: 4px 10px;
    font-size: 12px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}
.btn-ghost-sm:hover { color: #c9d1d9; }

/* ---------------------------------------------------------------
   Form elements
--------------------------------------------------------------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-select, .filter-input {
    padding: 6px 10px;
    background: var(--s-700);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.filter-select:focus, .filter-input:focus {
    border-color: rgba(0,212,255,0.4);
}
.filter-input { min-width: 180px; }
.filter-input::placeholder { color: var(--muted); }

.field-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.field-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--s-950);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #e6edf3;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
    border-color: rgba(0,212,255,0.5);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.07);
}
.field-input::placeholder { color: var(--muted); }

.field-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------------------------------------------------------------
   Pagination
--------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------
   Modal
--------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
    backdrop-filter: blur(4px);
}
.modal-backdrop.hidden { display: none; }

.modal {
    background: var(--s-800);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    animation: modal-in 0.2s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; color: #e6edf3; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 14px; padding: 4px 8px;
}
.modal-close:hover { color: #c9d1d9; }

.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------------------------------------------------------------
   Empty states
--------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 14px; font-weight: 600; color: #6e7681; margin-bottom: 4px; }
.empty-sub  { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------
   CLI unavailable banner
--------------------------------------------------------------- */
.cli-unavail-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(255,179,0,0.05);
    border: 1px solid rgba(255,179,0,0.2);
    border-radius: 8px;
    font-size: 13px;
    color: #c9d1d9;
}

/* ---------------------------------------------------------------
   API Key reveal
--------------------------------------------------------------- */
.apikey-reveal {
    padding: 16px 18px;
    background: rgba(0,230,118,0.05);
    border: 1px solid rgba(0,230,118,0.2);
    border-radius: 8px;
}
.apikey-header { font-size: 13px; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.apikey-box {
    position: relative;
    padding: 12px 16px;
    background: var(--s-950);
    border: 1px solid rgba(0,230,118,0.2);
    border-radius: 6px;
    cursor: pointer;
    word-break: break-all;
}
.apikey-box:hover { border-color: rgba(0,230,118,0.4); }
.apikey-copy-hint {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ---------------------------------------------------------------
   Tabs
--------------------------------------------------------------- */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-item {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
}
.tab-item:hover { color: #c9d1d9; }
.tab-item--active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 1px 5px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}

/* ---------------------------------------------------------------
   Utility helpers
--------------------------------------------------------------- */
.text-accent  { color: var(--accent); }
.text-threat  { color: var(--threat); }
.text-safe    { color: var(--safe); }
.text-warn    { color: var(--warn); }
.text-muted   { color: var(--muted); }

/* Smooth page load */
body { opacity: 0; transition: opacity 0.18s ease; }
body.ready { opacity: 1; }
