/* ================================================================
   EventNexus - Dark Infrastructure Theme
   Blue/purple accents, event-driven visualization palette
   ================================================================ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2b3d;
    --bg-input: #0d1421;
    --bg-sidebar: #070b12;
    --border-primary: #1e3048;
    --border-secondary: #2a3f5a;
    --border-accent: #3b5bdb;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-header: linear-gradient(90deg, #1e3a5f 0%, #2d1b69 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.15);
    --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --sidebar-width: 240px;
    --transition: all 0.2s ease;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    letter-spacing: 1px;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(59, 130, 246, 0.08);
    color: var(--text-primary);
    border-left-color: var(--accent-blue);
}

.nav-link.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-primary);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
}

.status-dot.offline {
    background: var(--accent-red);
}

/* ── Main Content ────────────────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 28px 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ── Cards ───────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Stats Grid ──────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow-blue);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.stat-value.blue { color: var(--accent-blue); }
.stat-value.purple { color: var(--accent-purple); }
.stat-value.green { color: var(--accent-green); }
.stat-value.red { color: var(--accent-red); }
.stat-value.yellow { color: var(--accent-yellow); }
.stat-value.cyan { color: var(--accent-cyan); }

.stat-footer {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Charts ──────────────────────────────────────────────────────── */

.chart-container {
    margin-bottom: 28px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding: 12px 0;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    max-width: 40px;
    background: var(--gradient-primary);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.4s ease;
    position: relative;
}

.bar:hover {
    filter: brightness(1.2);
}

.bar-label {
    font-size: 10px;
    color: var(--text-muted);
}

.bar-value {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ── Tables ──────────────────────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 5;
}

tbody tr {
    border-bottom: 1px solid rgba(30, 48, 72, 0.5);
    transition: var(--transition);
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

tbody td {
    padding: 10px 16px;
    color: var(--text-secondary);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Status Badges ───────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-delivered { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge-retrying { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.badge-pending { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-dead { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
.badge-retried { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.badge-discarded { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-inactive { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-webhook { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-email { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.badge-in_app, .badge-in-app { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }

/* ── Forms ───────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow-blue);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    filter: brightness(1.15);
    box-shadow: var(--shadow-glow-blue);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-primary);
}

.btn-secondary:hover {
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

.btn-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.25);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Filters ─────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-control {
    max-width: 220px;
}

/* ── Flow Visualization ──────────────────────────────────────────── */

.flow-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 30px 20px;
    margin-bottom: 28px;
}

.flow-node {
    background: var(--bg-card);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    text-align: center;
    min-width: 140px;
    transition: var(--transition);
}

.flow-node:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow-blue);
    transform: scale(1.05);
}

.flow-node.publisher {
    border-color: var(--accent-blue);
}

.flow-node.bus {
    border-color: var(--accent-purple);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.flow-node.subscriber {
    border-color: var(--accent-green);
}

.flow-node-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.flow-node-value {
    font-size: 20px;
    font-weight: 700;
}

.flow-arrow {
    font-size: 28px;
    color: var(--text-muted);
    padding: 0 12px;
    animation: pulse-arrow 1.5s infinite;
}

@keyframes pulse-arrow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; color: var(--accent-blue); }
}

/* ── Grid Layouts ────────────────────────────────────────────────── */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* ── Toast Notifications ─────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    min-width: 260px;
    box-shadow: var(--shadow-lg);
    animation: slide-in 0.3s ease;
}

.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast-info { background: linear-gradient(135deg, #2563eb, #3b82f6); }

@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Loading Spinner ─────────────────────────────────────────────── */

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 16px;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .brand-text, .nav-link span:not(.nav-icon), .status-text { display: none; }
    .sidebar-brand { justify-content: center; }
    .nav-link { justify-content: center; padding: 14px; }
    .main-content { margin-left: 60px; padding: 20px 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .flow-container { flex-direction: column; }
    .flow-arrow { transform: rotate(90deg); }
}

/* ── Scrollbar ───────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

/* ── JSON display ────────────────────────────────────────────────── */

.json-display {
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--accent-cyan);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* ── Empty state ─────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 16px;
}

/* ── Pagination ──────────────────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 0;
}

.pagination .btn {
    min-width: 36px;
    justify-content: center;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 12px;
}
