/* ═══════════════════════════════════════════════════════════════
   Network Monitor v5.0 — Layout CSS
   Header, sidebar, page layout, grid system
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: rgba(12, 16, 24, .95);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--br0);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(.4, 0, .2, 1);
    overflow: hidden;
}

/* Mobile expanded toggle still works */
.sidebar.expanded {
    width: var(--sidebar-width);
}

/* Collapsed state — set via body.nm-sidebar-collapsed by JS */
body.nm-sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}
body.nm-sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-collapsed);
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid var(--br0);
    flex-shrink: 0;
    cursor: pointer;
    white-space: nowrap;
}

.sidebar-logo .logo-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.sidebar-logo .logo-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--t0);
    opacity: 1;
    transition: opacity 0.2s;
}

body.nm-sidebar-collapsed .sidebar .logo-text {
    opacity: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    padding: 8px 0;
}

.sidebar-section-title {
    padding: 4px 16px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--t3);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

body.nm-sidebar-collapsed .sidebar .sidebar-section-title {
    opacity: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    border-left: 3px solid transparent;
    color: var(--t2);
    font-size: 11px;
    font-weight: 500;
    position: relative;
}

.nav-item:hover {
    background: rgba(45, 140, 240, .05);
    color: var(--t1);
}

.nav-item.active {
    border-left-color: var(--cyan);
    background: rgba(0, 212, 170, .05);
    color: var(--cyan);
}

.nav-item .nav-icon {
    width: 28px;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: var(--rs);
}

.nav-item.active .nav-icon {
    background: rgba(0, 212, 170, .1);
}

.nav-item .nav-label {
    opacity: 1;
    transition: opacity 0.2s;
}

body.nm-sidebar-collapsed .sidebar .nav-label {
    opacity: 0;
}

.nav-item .nav-badge {
    position: absolute;
    right: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 8px;
    font-weight: 700;
    font-family: var(--m);
    background: var(--rd);
    color: var(--red);
    opacity: 1;
    transition: opacity 0.2s;
}

body.nm-sidebar-collapsed .sidebar .nav-badge:not(.dot) {
    opacity: 0;
}

.nav-item .nav-badge.dot {
    right: auto;
    left: 36px;
    top: 6px;
    width: 6px;
    height: 6px;
    padding: 0;
    border-radius: 50%;
    background: var(--red);
    opacity: 1;
}

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--br0);
    flex-shrink: 0;
}

/* ── Header ── */
.H {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    height: var(--header-height);
    background: rgba(12, 16, 24, .9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--br0);
    transition: left 0.3s cubic-bezier(.4, 0, .2, 1);
}

.Hl {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-search {
    position: relative;
    width: 320px;
}

.header-search input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border-radius: 20px;
    border: 1px solid var(--br0);
    background: var(--b2);
    color: var(--t1);
    font-family: var(--f);
    font-size: 11px;
    outline: none;
    transition: all 0.2s;
}

.header-search input:focus {
    border-color: var(--blue);
    background: var(--b3);
}

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

.Hr {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.Hb {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 14px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: var(--gd);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, .2);
}

.Hb .bl {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    animation: bl 2s infinite;
}

.Ht {
    font-family: var(--m);
    font-size: 10px;
    color: var(--t3);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border-radius: 12px;
    background: var(--b3);
    border: 1px solid var(--br0);
}

.theme-toggle button {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--t3);
    cursor: pointer;
    font-size: 12px;
    transition: all .2s;
}

.theme-toggle button.active { background: var(--blue); color: #fff; }
.theme-toggle button:hover:not(.active) { background: var(--b4); }

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: var(--rs);
    background: var(--b3);
    border: 1px solid var(--br0);
}

.user-menu .avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
}

.user-menu .info { font-size: 10px; }
.user-menu .info .name { font-weight: 500; }
.user-menu .info .role { font-size: 8px; color: var(--t3); text-transform: uppercase; }
.user-menu .logout {
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--br1);
    background: transparent;
    color: var(--t2);
    font-size: 9px;
    cursor: pointer;
    transition: all .2s;
}
.user-menu .logout:hover { border-color: var(--red); color: var(--red); }

/* Notification Bell */
.notif-bell {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--b3);
    border: 1px solid var(--br0);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.notif-bell:hover { border-color: var(--br1); background: var(--b4); }

.notif-bell .notif-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    background: var(--red);
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    position: relative;
    z-index: 1;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left 0.3s cubic-bezier(.4, 0, .2, 1);
}

/* Collapsed state adjustments via body class */
body.nm-sidebar-collapsed .H {
    left: var(--sidebar-collapsed);
}
body.nm-sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.P {
    padding: 14px 18px;
    max-width: 1640px;
    margin: 0 auto;
}

/* Warning bar */
.W {
    padding: 5px 18px;
    text-align: center;
    font-size: 10px;
    color: var(--yel);
    background: rgba(251, 191, 36, .03);
    border-bottom: 1px solid rgba(251, 191, 36, .07);
}

.W code {
    background: rgba(251, 191, 36, .1);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--m);
    font-size: 9px;
}

/* ── Grid System ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 9px; }

.G { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }

/* Agent bar */
.AB {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.ac {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid var(--br0);
    background: var(--b2);
    cursor: pointer;
    transition: all .2s;
}

.ac:hover { border-color: var(--br2); }
.ac.on { border-color: var(--cyan); background: var(--cd); color: var(--cyan); }
.ad { width: 5px; height: 5px; border-radius: 50%; }
.adon { background: var(--green); }
.adoff { background: var(--red); }

/* View container */
.view-container {
    animation: fadeIn 0.3s ease;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.page-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--t3);
}

.breadcrumb span { color: var(--t2); }
.breadcrumb .current { color: var(--t0); font-weight: 500; }

/* ═══════════════════════════ LIGHT THEME OVERRIDES ═══════════════════ */
html[data-theme="light"] .sidebar { background: rgba(241, 245, 249, .97); border-right-color: var(--br0); }
html[data-theme="light"] .H { background: rgba(241, 245, 249, .95); }
html[data-theme="light"] .login-overlay { background: rgba(241, 245, 249, .98); }
html[data-theme="light"] .nav-item:hover { background: rgba(0,0,0,.04); }
html[data-theme="light"] .nav-item.active { background: rgba(45,140,240,.08); }
html[data-theme="light"] .header-search input { background: var(--b2); color: var(--t0); border-color: var(--br0); }

/* ═══════════════════════════ NOTIFICATION PANEL ══════════════════════ */
.notification-panel {
    position: fixed; top: var(--header-height); right: 0; bottom: 0;
    width: 380px; background: var(--b1); border-left: 1px solid var(--br0);
    z-index: 250; overflow-y: auto; box-shadow: -4px 0 20px rgba(0,0,0,.2);
    transform: translateX(100%); transition: transform 0.3s ease;
}
.notification-panel.open { transform: translateX(0); }
.notif-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--br0); }
.notif-header h3 { font-size:14px; font-weight:600; }
.notif-item { padding:12px 16px; border-bottom:1px solid var(--br0); cursor:pointer; transition:background .2s; }
.notif-item:hover { background:var(--bh); }
.notif-item.unread { border-left:3px solid var(--blue); }
.notif-item .notif-title { font-size:12px; font-weight:500; margin-bottom:4px; }
.notif-item .notif-msg { font-size:10px; color:var(--t2); line-height:1.4; }
.notif-item .notif-time { font-size:9px; color:var(--t3); margin-top:6px; }
.notif-empty { padding:40px 16px; text-align:center; color:var(--t3); font-size:11px; }

/* ═══════════════════════════ INCIDENT BADGE ═══════════════════════════ */
.incident-status { display:inline-block; padding:2px 8px; border-radius:10px; font-size:9px; font-weight:600; text-transform:uppercase; }
.incident-status.open { background:var(--rd); color:var(--red); }
.incident-status.investigating { background:var(--od); color:var(--ora); }
.incident-status.contained { background:var(--yd); color:var(--yel); }
.incident-status.resolved { background:var(--gd); color:var(--green); }
.incident-status.closed { background:var(--b3); color:var(--t3); }
