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

:root {
    --primary: #1e293b;
    --accent: #2563eb;
    --success: #059669;
    --error: #dc2626;
    --bg-light: #f8fafc;
    --card-bg: #fff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
    --sidebar-rail: 72px;
    --header-h: 64px;
    --footer-h: 56px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg-light); color: var(--text-main); height: 100vh; overflow: hidden; }

.app-layout { display: flex; height: 100vh; width: 100vw; }

/* Sidebar: Professional Rail */
.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease-in-out;
}
.collapsed .sidebar { width: var(--sidebar-rail); }

.sidebar-header {
    height: var(--header-h);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-toggle-btn {
    background: none; border: none; cursor: pointer; width: 24px; padding: 0;
}
.burger-icon { width: 18px; height: 2px; background: #334155; display: block; position: relative; }
.burger-icon::before, .burger-icon::after { content: ""; width: 100%; height: 100%; background: inherit; position: absolute; left: 0; }
.burger-icon::before { top: -6px; } .burger-icon::after { top: 6px; }

.brand-group { display: flex; align-items: center; gap: 0.75rem; white-space: nowrap; overflow: hidden; }
.nav-logo { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: 1rem; color: var(--text-main); letter-spacing: -0.01em; }
.collapsed .brand-name { display: none; }

.nav-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.nav-links { list-style: none; padding-top: 1rem; }
.nav-links li a {
    display: block; padding: 0.85rem 1.5rem; color: var(--text-muted); text-decoration: none;
    font-size: 0.875rem; font-weight: 600; white-space: nowrap; transition: 0.2s;
}
.nav-links li a:hover, .nav-links li a.active { color: var(--accent); background: #f1f5f9; }
.collapsed .nav-links li a { text-align: center; font-size: 0; padding: 1.25rem 0; }

.nav-footer { padding: 1.25rem; border-top: 1px solid var(--border-color); }
.collapsed .nav-footer { display: none; }
.select-wrapper label { font-size: 0.625rem; font-weight: 800; text-transform: uppercase; color: #94a3b8; display: block; margin-bottom: 4px; }
select { width: 100%; padding: 0.5rem; border: 1px solid var(--border-color); font-weight: 700; font-size: 0.75rem; background: #fff; cursor: pointer; }

/* Main Workspace with Fixed Header/Footer & Scrollable Body */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

.view-header {
    height: var(--header-h);
    background: #fff;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}
.view-header h1 { font-size: 1rem; font-weight: 800; color: #334155; }

.active-badge { border: 1px solid var(--border-color); padding: 0.4rem 0.75rem; border-radius: 20px; font-size: 0.675rem; font-weight: 800; display: flex; align-items: center; gap: 0.5rem; background: #f8fafc; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.node-online .status-dot { background: var(--success); }

/* SCROLLABLE INNER SECTION */
.view-body { flex-grow: 1; overflow-y: auto; background: var(--bg-light); padding: 1.5rem; }
.view-container { max-width: 1400px; margin: 0 auto; width: 100%; }

.view-footer {
    height: 80px; /* Increased footer height to accommodate larger chips */
    background: #fff;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 2.5rem;
    gap: 1.5rem;
    flex-shrink: 0;
}
.sponsor-tag { font-size: 0.75rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 1.5px; margin-right: 1.5rem; }
.sponsor-logos { display: flex; gap: 4rem; align-items: center; }
.sponsor-img { height: 48px; width: auto; opacity: 0.8; transition: 0.3s; }
.sponsor-img:hover { opacity: 1; transform: scale(1.05); }

/* Dashboard Cards - High Density Metrics */
.card { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.card h3 { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; margin-bottom: 1rem; color: #94a3b8; }

/* Unified Node Block System (Status + Telemetry) */
.unified-node-block { 
    background: #fff; 
    border: 1px solid var(--border-color); 
    border-radius: 10px; 
    padding: 1.25rem; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    margin-bottom: 1.5rem; 
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.block-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid #f1f5f9; 
    padding-bottom: 1rem; 
}

.node-main-info { display: flex; flex-direction: column; gap: 0.25rem; }
.node-id { font-size: 1.25rem; font-weight: 850; color: #0f172a; letter-spacing: -0.02em; }
.node-location-group { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.15rem; }
.node-location { font-size: 0.725rem; font-weight: 800; color: #475569; text-transform: uppercase; letter-spacing: 0.03em; display: flex; align-items: center; gap: 4px; }
.loc-icon { color: var(--accent); font-size: 0.85rem; }
.node-last-seen { font-size: 0.625rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; }

.btn-maps { 
    background: #fff; 
    color: var(--accent); 
    border: 1px solid var(--accent); 
    padding: 0.25rem 0.5rem; 
    border-radius: 6px; 
    font-size: 0.6rem; 
    font-weight: 800; 
    text-decoration: none; 
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-maps:hover { background: var(--accent); color: #fff; }

.status-tag { 
    padding: 0.25rem 0.75rem; 
    border-radius: 12px; 
    font-weight: 900; 
    font-size: 0.65rem; 
    letter-spacing: 0.04em; 
}
.tag-online { background: #ecfdf5; color: #059669; border: 1px solid rgba(5, 150, 105, 0.2); }
.tag-offline { background: #fef2f2; color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.2); }

/* Status Metrics Row (Uptime / Availability) - More Compact */
.block-status-row { 
    display: grid; 
    grid-template-columns: 240px 1fr; 
    gap: 2rem; 
    background: #f8fafc; 
    padding: 1rem; 
    border-radius: 8px; 
    align-items: center;
}

.uptime-summary { display: flex; flex-direction: column; gap: 0.2rem; }
.uptime-label { font-size: 0.55rem; font-weight: 850; text-transform: uppercase; color: #64748b; letter-spacing: 0.04em; }
.uptime-duration { font-size: 1.1rem; font-weight: 1000; color: #000; }

.availability-grid { display: flex; gap: 2rem; flex-grow: 1; }
.avail-item { flex: 1; display: flex; flex-direction: column; gap: 0.4rem; }
.avail-label-wrapper { display: flex; justify-content: space-between; font-size: 0.6rem; font-weight: 850; color: #64748b; text-transform: uppercase; }

.avail-bar-bg { width: 100%; height: 7px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.avail-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.8s ease; }

/* Live Telemetry Grid (7-Columns) - More Compact */
.block-telemetry-grid { 
    display: grid; 
    grid-template-columns: repeat(7, 1fr); 
    gap: 0.75rem; 
}
.tele-point { 
    background: #fff; 
    border: 1px solid #f1f5f9; 
    padding: 1rem 0.5rem; 
    border-radius: 10px; 
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.01);
}
.tele-label { display: block; font-size: 0.55rem; font-weight: 850; text-transform: uppercase; color: #94a3b8; margin-bottom: 0.5rem; letter-spacing: 0.04em; }
.tele-val { font-size: 1.6rem; font-weight: 1000; color: #000; line-height: 1; height: 1.6rem; }
.tele-unit { font-size: 0.75rem; font-weight: 800; color: #94a3b8; margin-left: 0.15rem; }

@media (max-width: 1400px) {
    .block-telemetry-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 992px) {
    .block-status-row { grid-template-columns: 1fr; gap: 1.25rem; }
    .block-telemetry-grid { grid-template-columns: repeat(2, 1fr); }
    .availability-grid { flex-direction: column; gap: 1rem; }
}
@media (max-width: 576px) {
    .block-telemetry-grid { grid-template-columns: 1fr; }
}

/* Tables & Sticky Headers */
.table-card { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius); overflow: visible; box-shadow: var(--shadow); }
.table-card-header { 
    position: sticky; 
    top: 0; 
    z-index: 100; 
    padding: 1.5rem; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: #f8fafc; 
    border-top-left-radius: var(--radius); 
    border-top-right-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; }
tr:nth-child(even) { background: #fafafa; } /* Zebra striping for legibility */

th { 
    position: sticky; 
    top: 68px; /* Standardized offset below table-card-header */
    z-index: 90;
    background: #f8fafc; 
    padding: 1rem; 
    text-align: left; 
    font-size: 0.65rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    color: #64748b; 
    box-shadow: inset 0 -1px 0 var(--border-color);
}
td { padding: 1.125rem 1rem; font-size: 0.875rem; font-weight: 700; border-top: 1px solid var(--border-color); color: #000; }

.btn { padding: 0.625rem 1.5rem; border-radius: 8px; font-weight: 800; font-size: 0.75rem; cursor: pointer; border: 1px solid var(--border-color); transition: 0.2s; background: #fff; color: #334155; }
.btn-pro { background: var(--primary); color: #fff; border: none; }
.btn-pro:hover { filter: brightness(110%); }

.header-left { display: flex; align-items: center; gap: 1rem; }
.mobile-toggle { 
    display: none; position: fixed; top: 1.5rem; left: 1.5rem; 
    background: #fff; border: 1px solid var(--border-color); 
    padding: 1.125rem; border-radius: 50%; z-index: 1100; box-shadow: var(--shadow);
    cursor: pointer; min-width: 54px; min-height: 54px; align-items: center; justify-content: center;
}
.mobile-toggle:active { transform: scale(0.94); }

@media (max-width: 1200px) {
    .detailed-row { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .app-layout { overflow: hidden; display: block; position: relative; }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: calc(-1 * var(--sidebar-width));
        height: 100vh;
        z-index: 2000;
        box-shadow: 10px 0 30px rgba(0,0,0,0.15);
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--sidebar-width) !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        height: 100vh;
        overflow-y: auto;
    }

    .mobile-toggle { display: flex; }
    
    /* Reveal Sidebar on open */
    .mobile-nav-open .sidebar {
        left: 0 !important;
    }

    /* Stacking Telemetry Grids */
    .view-body { padding: 6rem 1.25rem 1.25rem 1.25rem; }
    .detailed-row { grid-template-columns: 1fr; gap: 1.25rem; }
    .detail-box { padding: 1.5rem; min-height: 120px; }
    .detail-val { font-size: 2.5rem; }

    /* Network Grid */
    .network-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .device-card { padding: 1.5rem; }

    /* Tables Mobile Optimization */
    .table-card { overflow: visible !important; }
    .table-card-header { 
        position: relative; /* Disable sticky on mobile */
        top: 0; 
        z-index: 100;
        padding: 1rem;
        border-radius: 0;
        margin: 0 -1.25rem;
        width: calc(100% + 2.5rem);
        background: #f8fafc;
    }
    th { 
        position: relative; /* Disable sticky on mobile */
        top: 0;
        padding: 0.85rem 0.5rem;
        font-size: 0.65rem;
        background: #f1f5f9;
    }
    td { padding: 0.85rem 0.5rem; font-size: 0.8rem; }

    .table-responsive {
        margin: 0 -1.25rem;
        padding: 0 1.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table { min-width: 600px; } /* Prevent squishing - force horizontal scroll if needed */

    /* Footer Marquee Logic / Stacking */
    .view-footer { 
        height: auto; 
        min-height: 80px;
        flex-direction: column; 
        padding: 1.25rem 1rem; 
        gap: 0.75rem;
        text-align: center;
    }
    .sponsor-logos { gap: 1.5rem; justify-content: center; flex-wrap: wrap; }
    .sponsor-img { height: 32px; }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        backdrop-filter: blur(6px);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: 0.3s;
    }
    .mobile-nav-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    /* Hide Desktop Toggle on Mobile */
    .sidebar-toggle-btn { display: none; }
}

/* Custom Responsive Utilities */
.mob-show { display: none; }
@media (max-width: 768px) {
    .mob-hide { display: none !important; }
    .mob-show { display: inline-block !important; }
}
