/* BCP Monitor — Dark Terminal Theme */

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

:root {
    --bg-base:      #0d1117;
    --bg-surface:   #161b22;
    --bg-elevated:  #1c2128;
    --bg-hover:     #21262d;
    --border:       #30363d;
    --border-subtle:#21262d;

    --text-primary: #e6edf3;
    --text-secondary:#8b949e;
    --text-muted:   #484f58;

    --c-critical:   #ff4d4d;
    --c-high:       #ff8c00;
    --c-medium:     #f5c518;
    --c-low:        #3ecf8e;
    --c-unknown:    #4a5568;
    --c-accent:     #58a6ff;

    --font-ui:      'Syne', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;

    --radius:       6px;
    --radius-lg:    10px;
    --shadow:       0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --transition:   all 0.18s ease;
}

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

body {
    font-family: var(--font-ui);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Subtle grid texture on bg */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(88,166,255,.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(88,166,255,.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px;
}

.mono { font-family: var(--font-mono); }

/* ── Header ─────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

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

.logo-mark {
    font-family: var(--font-mono);
    font-size: 22px;
    color: var(--c-accent);
    letter-spacing: -2px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.logo-mark i { font-size: 18px; color: var(--c-accent); }
.logo-bracket { color: var(--text-muted); }

.header-titles h1 {
    font-family: var(--font-ui);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.subtitle {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

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

.header-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.header-stat-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--c-accent);
    line-height: 1;
}

.header-stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c-low);
    box-shadow: 0 0 8px var(--c-low);
    animation: pulse-dot 2s ease-in-out infinite;
}

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

/* ── Buttons ─────────────────────────────────── */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    letter-spacing: 0.3px;
}

.btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--c-accent);
}

.btn-refresh {
    color: var(--c-low);
    border-color: rgba(62,207,142,.3);
}

.btn-refresh:hover {
    background: rgba(62,207,142,.08);
    border-color: var(--c-low);
    color: var(--c-low);
}

/* ── Stats Bar ───────────────────────────────── */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.stats-bar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-right: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.stats-bar-item:hover {
    background: var(--bg-hover);
}

.stats-bar-item.total { border-left: 3px solid var(--c-accent); }
.stats-bar-item.critical { border-left: 3px solid var(--c-critical); }
.stats-bar-item.high { border-left: 3px solid var(--c-high); }
.stats-bar-item.medium { border-left: 3px solid var(--c-medium); }
.stats-bar-item.low { border-left: 3px solid var(--c-low); }

.stats-bar-spacer { flex: 1; }

.stats-bar-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stats-bar-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sev-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sev-critical { background: var(--c-critical); box-shadow: 0 0 6px var(--c-critical); }
.sev-high     { background: var(--c-high);     box-shadow: 0 0 6px var(--c-high); }
.sev-medium   { background: var(--c-medium);   box-shadow: 0 0 6px var(--c-medium); }
.sev-low      { background: var(--c-low);      box-shadow: 0 0 6px var(--c-low); }

.stats-bar-clock {
    padding: 0 20px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ── Layout ─────────────────────────────────── */
.main-content {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 1100px) {
    .main-content { grid-template-columns: 1fr; }
}

/* ── Cards ─────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card:last-child { margin-bottom: 0; }

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-body { padding: 16px; }

.chart-body {
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Toolbar ────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 12px;
}

.search-input {
    width: 100%;
    padding: 7px 12px 7px 30px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    transition: var(--transition);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--c-accent); box-shadow: 0 0 0 2px rgba(88,166,255,.15); }

.toolbar-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 7px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:focus, .filter-select:hover {
    border-color: var(--c-accent);
    color: var(--text-primary);
}

.score-filter {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-filter-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.score-btns {
    display: flex;
    gap: 3px;
}

.score-btn {
    padding: 5px 9px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.score-btn:hover, .score-btn.active {
    background: rgba(88,166,255,.1);
    border-color: var(--c-accent);
    color: var(--c-accent);
}

/* ── Severity Pills ─────────────────────────── */
.sev-pills {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.sev-pill {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.sev-pill:hover { border-color: var(--text-secondary); color: var(--text-primary); }
.sev-pill.active { background: rgba(88,166,255,.12); border-color: var(--c-accent); color: var(--c-accent); }

.sev-pill-critical.active, .sev-pill-critical:hover { border-color: var(--c-critical); color: var(--c-critical); background: rgba(255,77,77,.08); }
.sev-pill-high.active, .sev-pill-high:hover     { border-color: var(--c-high);     color: var(--c-high);     background: rgba(255,140,0,.08); }
.sev-pill-medium.active, .sev-pill-medium:hover { border-color: var(--c-medium);   color: var(--c-medium);   background: rgba(245,197,24,.08); }
.sev-pill-low.active, .sev-pill-low:hover       { border-color: var(--c-low);      color: var(--c-low);      background: rgba(62,207,142,.08); }

.pill-count {
    background: rgba(255,255,255,.07);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
}

/* ── Incidents List ─────────────────────────── */
.incidents-list {
    max-height: 65vh;
    overflow-y: auto;
}

.incident-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.incident-item:hover { background: var(--bg-hover); }
.incident-item:last-child { border-bottom: none; }

.incident-sev-strip {
    width: 3px;
    flex-shrink: 0;
    border-radius: 3px 0 0 3px;
}

.severity-critical .incident-sev-strip { background: var(--c-critical); }
.severity-high     .incident-sev-strip { background: var(--c-high); }
.severity-medium   .incident-sev-strip { background: var(--c-medium); }
.severity-low      .incident-sev-strip { background: var(--c-low); }
.severity-unknown  .incident-sev-strip { background: var(--c-unknown); }

.incident-body {
    flex: 1;
    padding: 10px 12px;
    min-width: 0;
}

.incident-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.incident-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge-critical { background: rgba(255,77,77,.18);  color: var(--c-critical); border: 1px solid rgba(255,77,77,.3); }
.badge-high     { background: rgba(255,140,0,.18);  color: var(--c-high);     border: 1px solid rgba(255,140,0,.3); }
.badge-medium   { background: rgba(245,197,24,.18); color: var(--c-medium);   border: 1px solid rgba(245,197,24,.3); }
.badge-low      { background: rgba(62,207,142,.18); color: var(--c-low);      border: 1px solid rgba(62,207,142,.3); }
.badge-unknown  { background: rgba(74,85,104,.18);  color: var(--text-muted); border: 1px solid rgba(74,85,104,.3); }

.incident-source {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--c-accent);
    font-weight: 500;
}

.incident-time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.incident-score {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.score-max { font-weight: 400; color: var(--text-muted); }

.score-3 { color: var(--c-critical); border-color: rgba(255,77,77,.3); }
.score-2 { color: var(--c-high);     border-color: rgba(255,140,0,.3); }
.score-1 { color: var(--c-medium);   border-color: rgba(245,197,24,.3); }
.score-0 { color: var(--text-muted); }

.incident-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.incident-summary {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.incident-arrow {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 11px;
    opacity: 0;
    transition: var(--transition);
}

.incident-item:hover .incident-arrow { opacity: 1; color: var(--c-accent); }

/* ── Sources ─────────────────────────────────── */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.source-name {
    width: 120px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.source-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-base);
    border-radius: 2px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--c-accent), rgba(88,166,255,.4));
    border-radius: 2px;
    transition: width 0.6s ease;
    min-width: 4px;
}

.source-count {
    width: 28px;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ── Pipeline / Health ───────────────────────── */
.pipeline-status {
    padding: 12px;
    border-radius: var(--radius);
    background: var(--bg-base);
    border-left: 3px solid var(--border);
}

.pipeline-status.status-healthy  { border-left-color: var(--c-low);      background: rgba(62,207,142,.05); }
.pipeline-status.status-warning  { border-left-color: var(--c-high);     background: rgba(255,140,0,.05); }
.pipeline-status.status-error    { border-left-color: var(--c-critical);  background: rgba(255,77,77,.05); }

.pipeline-status-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.pipeline-detail {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.pipeline-detail:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); }
.detail-value { color: var(--text-secondary); font-weight: 500; }

.sources-health-list { display: flex; flex-direction: column; gap: 8px; }

.source-health-item {
    padding: 8px 10px;
    background: var(--bg-base);
    border-radius: var(--radius);
    border-left: 2px solid var(--border);
}

.source-health-name {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.source-health-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
}

.source-health-status.status-healthy { color: var(--c-low); }
.source-health-status.status-warning { color: var(--c-high); }
.source-health-status.status-error   { color: var(--c-critical); }
.source-health-status.status-unknown { color: var(--text-muted); }

.source-health-details {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Empty / Loading states ──────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    display: block;
    color: var(--text-muted);
}

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ── Modal ───────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 760px;
    max-height: 88vh;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    flex-shrink: 0;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: var(--transition);
    flex-shrink: 0;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ── Footer ──────────────────────────────────── */
.footer {
    padding: 12px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.footer-dot { color: var(--border); }

/* ── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .stats-bar { flex-direction: column; }
    .stats-bar-item { border-right: none; border-bottom: 1px solid var(--border-subtle); width: 100%; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-wrap { min-width: unset; }
}
