/* ═══════════════════════════════════════════════════════════════
   BeamStream Unified Dashboard — Design System
   Inspired by Mux Data, Grafana, Cloudflare
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-base: #060a13;
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #161e2e;
    --bg-card-hover: #1c2640;
    --bg-surface: #1a2235;
    --bg-input: #0d1321;
    --border: #1e293b;
    --border-accent: #2d3a52;
    --border-glow: rgba(99, 102, 241, 0.25);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    --blue: #3b82f6;
    --green: #10b981;
    --purple: #8b5cf6;
    --orange: #f59e0b;
    --red: #ef4444;
    --pink: #ec4899;
    --cyan: #06b6d4;
    --lime: #84cc16;
    --indigo: #6366f1;
    --sidebar-w: 220px;
    --header-h: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --glass: rgba(22, 30, 46, 0.75);
    --glass-border: rgba(99, 102, 241, 0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-accent);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transition: width var(--transition);
}

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

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--indigo), var(--blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.sidebar-logo .logo-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-text span {
    color: var(--blue);
}

.nav-menu {
    flex: 1 1 0%;
    padding: 12px 10px;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* don't shrink */
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    padding: 0 10px 8px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--indigo);
    border-color: rgba(99, 102, 241, 0.15);
}

.nav-item .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-item .nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--indigo);
}

/* ── Main ── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.header {
    height: var(--header-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title .page-icon {
    font-size: 20px;
}

.header-stats {
    display: flex;
    gap: 20px;
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.header-stat .stat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.header-stat .stat-dot.green {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.header-stat .stat-dot.blue {
    background: var(--blue);
}

.header-stat .stat-dot.red {
    background: var(--red);
}

.header-stat .stat-val {
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ── Content Area ── */
.page-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ── Toolbars ── */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(16px);
}

.toolbar h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Input & Select ── */
.filter-select,
.filter-input,
.form-input,
.cap-input,
.rating-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.filter-select:focus,
.filter-input:focus,
.form-input:focus,
.cap-input:focus,
.rating-select:focus {
    border-color: var(--blue);
}

.filter-input::placeholder {
    color: var(--text-dim);
}

/* ── V2 Grids & Config Cards ── */
.v2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(17, 24, 39, 0.3);
}

.card-header h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Form Groups ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-row input {
    flex: 1;
}

.input-suffix {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 600;
}

/* ── Editable Capabilities (Multi-Select Checkboxes) ── */
.multi-select {
    position: relative;
    width: 100%;
}

.multi-select-btn {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.multi-select-btn::after {
    content: '▼';
    font-size: 10px;
    color: var(--text-muted);
}

.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xs);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.multi-select.open .multi-select-dropdown {
    display: block;
}

.multi-select-dropdown label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.1s;
    text-transform: none;
    letter-spacing: normal;
}

.multi-select-dropdown label:hover {
    background: var(--bg-card-hover);
}

.multi-select-dropdown input[type="checkbox"] {
    accent-color: var(--indigo);
    width: 14px;
    height: 14px;
}

/* ── Log Viewers (4 Panes) ── */
.log-container {
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 16px;
    height: calc(100vh - 240px);
    overflow-y: auto;
}

.log-line {
    padding: 4px 6px;
    border-radius: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 12px;
}

.log-line:hover {
    background: rgba(255, 255, 255, 0.05);
}

.log-time {
    color: var(--text-dim);
    min-width: 140px;
}

.log-level {
    min-width: 50px;
    font-weight: 700;
}

.log-src {
    color: var(--purple);
    min-width: 120px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-msg {
    flex: 1;
    color: #cbd5e1;
    word-break: break-all;
}

/* Log Levels */
.ll-deb {
    color: var(--text-muted);
}

.ll-inf {
    color: var(--green);
}

.ll-wrn {
    color: var(--orange);
}

.ll-err {
    color: var(--red);
}

.log-line.err-row {
    background: rgba(239, 68, 68, 0.08);
}

/* ── Mermaid Integration ── */
.v2-trace-views {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mermaid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.mermaid-container svg {
    max-width: 100%;
    height: auto;
}

/* ── Shared & Utilities ── */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--indigo), var(--blue));
    border-color: transparent;
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.status-dot.bsc {
    background: var(--green);
}

.vertical-divider {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 8px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    width: 100%;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 13px;
}

/* ── Container Performance Dashboard ── */
.perf-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.container-perf-row {
    transition: box-shadow var(--transition);
}

.container-perf-row:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(129, 140, 248, 0.1);
}

.detail-tab {
    transition: all var(--transition);
    font-weight: 500;
}

.detail-tab:hover {
    color: var(--text-primary) !important;
    background: rgba(129, 140, 248, 0.05);
}