/* 
   EmION Dashboard - Mission Control Layout
   Professional Single-Window (No Scroll)
*/

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --success: #22c55e;
    --danger: #ef4444;
    --sidebar-w: 280px;
    --analytics-w: 360px;
    --header-h: 0; /* No explicit header, integrated in sidebar */
    --r: 12px;
}

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden; /* Strict no-scroll */
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-main);
}

/* ── Custom Scrollbars (WebKit/Firefox Compatibility) ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox Specific Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dashboard-grid {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    width: 100%; height: 100%;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden; /* Prevent content bleed */
}

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

.card-header h2 {
    font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-secondary);
}

.card-header h2 small {
    font-weight: 500; font-size: 0.7rem; color: var(--text-muted); opacity: 0.8;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    height: 100%;
    border-radius: 0; 
    border: none; 
    border-right: 1px solid var(--border);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex; 
    -webkit-box-orient: vertical; 
    -webkit-box-direction: normal; 
    -ms-flex-direction: column; 
    flex-direction: column; 
    padding: 24px;
    box-shadow: none !important; /* Fix shadow bleed corruption */
    background: white;
}

.brand { margin-bottom: 32px; }
.brand h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; }
.accent { color: var(--accent); }
.protocol { 
    font-size: 0.65rem; font-weight: 700; background: #eff6ff;
    color: var(--accent); padding: 2px 8px; border-radius: 4px;
    margin-top: 4px; display: inline-block;
}

.nav-section { margin-bottom: 24px; }
.nav-section h3 {
    font-size: 0.7rem; font-weight: 800; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px;
}

.control-group, .control-form { display: flex; flex-direction: column; gap: 8px; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

input {
    width: 100%; padding: 8px 12px; background: #fdfdfd;
    border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.85rem; font-family: 'JetBrains Mono', monospace;
    outline: none; transition: 0.2s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

button {
    padding: 8px 12px; border-radius: 6px; font-size: 0.85rem;
    font-weight: 600; cursor: pointer; border: none; transition: 0.2s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-accent { background: #0f172a; color: white; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fee2e2; }
.btn-secondary { background: #f1f5f9; color: var(--text-secondary); }
.w-full { width: 100%; }

.chip-container { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.system-health { margin-top: auto; border-top: 1px solid var(--border); padding-top: 16px; }
.health-item { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.status-dot.live { background: var(--success); box-shadow: 0 0 8px var(--success); }

/* ── Workspace ── */
.workspace {
    flex: 1; height: 100%; padding: 20px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex; 
    -webkit-box-orient: vertical; 
    -webkit-box-direction: normal; 
    -ms-flex-direction: column; 
    flex-direction: column; 
    gap: 20px;
    min-width: 0; /* Firefox fix: Allow shrinking */
}

.viz-card { 
    flex: 3; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    min-height: 0; /* Firefox fix: contain contents */
}
#viz-container { flex: 1; width: 100%; overflow: hidden; position: relative; background: white; }
#topology-canvas { display: block; width: 100%; height: 100%; }

.history-card { 
    flex: 2; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; /* Firefox fix: contain history table */
}
.history-table-wrapper { flex: 1; overflow-y: auto; padding: 0 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
th { text-align: left; padding: 12px 8px; border-bottom: 2px solid var(--bg-main); color: var(--text-muted); position: sticky; top: 0; background: white; z-index: 10; }
td { padding: 10px 8px; border-bottom: 1px solid var(--bg-main); font-family: 'Inter', sans-serif; }
#bundle-history td:nth-child(1) { font-family: 'JetBrains Mono'; color: var(--text-muted); }

/* ── Analytics ── */
.analytics {
    width: var(--analytics-w);
    height: 100%; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 20px;
    min-width: 0; /* Firefox fix */
}

.chart-card { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; /* Firefox fix */
}
.d3-chart { flex: 1; width: 100%; background: #ffffff; }

.log-card { flex: 1; display: flex; flex-direction: column; }
.console-log {
    flex: 1; overflow-y: auto; padding: 12px;
    font-family: 'JetBrains Mono', monospace; font-size: 0.7rem;
    background: #0f172a; color: #94a3b8; line-height: 1.4;
}
.console-log div { margin-bottom: 4px; }
.log-tx { color: #38bdf8; }
.log-rx { color: #4ade80; }
.log-err { color: #f87171; }

/* Custom Chips */
.chip { 
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; background: #f1f5f9;
    border: 1px solid var(--border); color: var(--text-secondary);
}
.chip.running { background: #f0fdf4; color: var(--success); border-color: #dcfce7; }
