/* ==========================================================
   DevSecOps AI
   DCP-8.1 PT-2 — Enterprise Sidebar
   ========================================================== */

/* ----------------------------------------------------------
   Shell variables
   ---------------------------------------------------------- */

:root {
    --enterprise-sidebar-width: 252px;
    --enterprise-sidebar-collapsed-width: 72px;
    --enterprise-sidebar-background: #0b1220;
    --enterprise-sidebar-border: #243244;

    --enterprise-nav-text: #cbd5e1;
    --enterprise-nav-text-muted: #7f8da3;

    --enterprise-nav-hover: rgba(56, 189, 248, 0.08);
    --enterprise-nav-active: rgba(56, 189, 248, 0.12);
    --enterprise-nav-accent: #38bdf8;

    --enterprise-shell-gap: 20px;
}

/* ----------------------------------------------------------
   Safe box sizing
   ---------------------------------------------------------- */

.enterprise-sidebar,
.enterprise-sidebar *,
.enterprise-sidebar *::before,
.enterprise-sidebar *::after {
    box-sizing: border-box;
}

/* ----------------------------------------------------------
   Main page offset
   ----------------------------------------------------------
   The existing HTML structure stays unchanged.

   The sidebar is fixed, while all normal page content is
   shifted to the right through body padding.
   ---------------------------------------------------------- */

body {
    padding-left: calc(
        var(--enterprise-sidebar-width) +
        var(--enterprise-shell-gap)
    ) !important;

    transition:
        padding-left 0.25s ease;
}

body.sidebar-collapsed {
    padding-left: calc(
        var(--enterprise-sidebar-collapsed-width) +
        var(--enterprise-shell-gap)
    ) !important;
}

/* ----------------------------------------------------------
   Sidebar shell
   ---------------------------------------------------------- */

.enterprise-sidebar {
    position: fixed;

    top: 0;
    left: 0;
    bottom: 0;

    width: var(--enterprise-sidebar-width);
    height: 100vh;

    display: flex;
    flex-direction: column;

    padding: 20px 14px 14px;

    background: linear-gradient(
        180deg,
        #0b1220 0%,
        #0c1424 100%
    );

    border-right: 1px solid
        var(--enterprise-sidebar-border);

    box-shadow:
        8px 0 24px rgba(2, 6, 23, 0.22);

    overflow: hidden;

    z-index: 1100;

    transition:
        width 0.25s ease,
        padding 0.25s ease,
        box-shadow 0.25s ease;
}

/* ----------------------------------------------------------
   Brand
   ---------------------------------------------------------- */

.enterprise-brand {
    display: flex;
    align-items: center;
    gap: 11px;

    flex: 0 0 auto;

    min-height: 62px;

    padding: 5px 8px 17px;

    margin-bottom: 12px;

    border-bottom: 1px solid rgba(148, 163, 184, 0.14);

    transition:
        justify-content 0.25s ease,
        padding 0.25s ease;
}

.enterprise-sidebar.collapsed {
    width: var(--enterprise-sidebar-collapsed-width);

    padding-left: 10px;
    padding-right: 10px;
}

.enterprise-sidebar.collapsed .enterprise-brand {
    justify-content: center;
}

.enterprise-sidebar.collapsed .enterprise-brand-text {
    display: none;
}

.enterprise-sidebar.collapsed .enterprise-brand-logo {
    margin: 0;
}

.enterprise-sidebar.collapsed .enterprise-sidebar-footer {
    display: none;
}

.enterprise-brand-logo {
    width: 35px;
    height: 35px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 35px;

    border-radius: 9px;

    background:
        rgba(56, 189, 248, 0.11);

    border:
        1px solid
        rgba(56, 189, 248, 0.22);

    font-size: 18px;
    line-height: 1;
}

.enterprise-brand-text {
    min-width: 0;
}

.enterprise-brand-title {
    color: #f8fafc;

    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;

    letter-spacing: 0.01em;
}

.enterprise-brand-subtitle {
    margin-top: 3px;

    color: var(--enterprise-nav-text-muted);

    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;

    letter-spacing: 0.02em;
}

/* ----------------------------------------------------------
   Navigation viewport
   ---------------------------------------------------------- */

.enterprise-nav {
    flex: 1 1 auto;
    min-height: 0;

    overflow-y: auto;
    overflow-x: hidden;

    padding: 2px 0;
}

/* Override the old horizontal navigation presentation. */

#dashboardV2Nav.dashboard-v2-nav {
    position: static;

    width: 100%;
    height: auto;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 3px;

    margin: 0;
    padding: 0;

    background: transparent;
    border: 0;
    box-shadow: none;

    overflow: visible;
}

/* ----------------------------------------------------------
   Thin enterprise navigation links
   ---------------------------------------------------------- */

#dashboardV2Nav.dashboard-v2-nav > button {
    position: relative;

    width: 100%;
    min-height: 42px;

    display: flex;
    align-items: center;

    margin: 0;
    padding: 9px 12px;

    background: transparent !important;

    border: 0 !important;
    border-radius: 8px;

    box-shadow: none !important;

    color: var(--enterprise-nav-text) !important;

    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;

    text-align: left;

    cursor: pointer;

    overflow: hidden;
    white-space: nowrap;

    user-select: none;

    transition:
        background-color 160ms ease,
        color 160ms ease,
        transform 160ms ease,
        box-shadow 160ms ease,
        border-color 160ms ease;
}

.enterprise-sidebar.collapsed #dashboardV2Nav.dashboard-v2-nav > button {
    justify-content: center;
    align-items: center;

    min-height: 46px;

    padding: 0;

    text-indent: -9999px;

    border-radius: 10px;

    overflow: visible;

    position: relative;
}

.enterprise-sidebar.collapsed #dashboardV2Nav > button::before {
    text-indent: 0;

    margin-right: 0;

    width: auto;

    font-size: 18px;

    justify-content: center;
}

/* Icons added without modifying navigation.js or data attributes. */

#dashboardV2Nav > button::before {

    width: 22px;

    display: inline-flex;

    align-items: center;

    justify-content: center;

    flex: 0 0 22px;

    margin-right: 8px;

    font-size: 16px;

    line-height: 1;

    opacity: 0.95;

    transform: scale(1);

    transition:
        transform 160ms ease,
        opacity 160ms ease,
        filter 160ms ease;
}

#dashboardV2Nav
> button[data-dashboard-tab="soc"]::before {
    content: "🛡";
}

#dashboardV2Nav
> button[data-dashboard-tab="governance"]::before {
    content: "⚖";
}

#dashboardV2Nav
> button[data-dashboard-tab="executive"]::before {
    content: "📊";
}

#dashboardV2Nav
> button[data-dashboard-tab="intelligence"]::before {
    content: "🧠";
}

#dashboardV2Nav
> button[data-dashboard-tab="administration"]::before {
    content: "⚙";
}

#dashboardV2Nav
> button[data-dashboard-tab="pipeline-studio"]::before {
    content: "🚀";
}

#dashboardV2Nav
> button[data-dashboard-tab="enterprise-reporting"]::before {
    content: "📑";
}

#dashboardV2Nav
> button[data-dashboard-tab="legacy"]::before {
    content: "🏢";
}

/* ----------------------------------------------------------
   Hover and keyboard focus
   ---------------------------------------------------------- */

#dashboardV2Nav.dashboard-v2-nav > button:hover {

    background:
        var(--enterprise-nav-hover)
        !important;

    color: #f8fafc !important;

    transform: translateX(2px);

    box-shadow:
        inset 3px 0 0
        rgba(56,189,248,.75);
}

#dashboardV2Nav.dashboard-v2-nav > button:hover::before {

    transform: scale(1.12);

    filter: brightness(1.15);

    opacity: 1;
}

#dashboardV2Nav.dashboard-v2-nav > button:focus-visible {

    outline:
        2px solid
        rgba(56,189,248,.9);

    outline-offset: -2px;

    background:
        var(--enterprise-nav-hover)
        !important;

    box-shadow:
        inset 3px 0 0
        var(--enterprise-nav-accent);
}

/* ----------------------------------------------------------
   Active navigation item
   ---------------------------------------------------------- */

#dashboardV2Nav.dashboard-v2-nav > button.active {

    background:
        var(--enterprise-nav-active)
        !important;

    color:
        #e0f2fe
        !important;

    font-weight: 650;

    box-shadow:
        inset 4px 0 0
        var(--enterprise-nav-accent)
        !important;
}

#dashboardV2Nav.dashboard-v2-nav > button.active::after {
    content: "";

    position: absolute;

    top: 50%;
    right: 10px;

    width: 5px;
    height: 5px;

    border-radius: 999px;

    background:
        var(--enterprise-nav-accent);

    transform: translateY(-50%);

    box-shadow:
        0 0 8px
        rgba(56, 189, 248, 0.6);
}

.enterprise-sidebar.collapsed
#dashboardV2Nav.dashboard-v2-nav > button::after {

    content: attr(data-tooltip);

    position: absolute;

    left: calc(100% + 14px);

    top: 50%;

    transform: translateY(-50%) translateX(-6px);

    padding: 8px 12px;

    border-radius: 8px;

    background: #111827;

    color: #f8fafc;

    font-size: 12px;

    font-weight: 600;

    line-height: 1;

    white-space: nowrap;

    border: 1px solid rgba(56,189,248,.35);

    box-shadow:
        0 10px 24px rgba(2,6,23,.28);

    opacity: 0;

    visibility: hidden;

    pointer-events: none;

    z-index: 5000;

    transition:
        opacity 150ms ease,
        transform 150ms ease,
        visibility 150ms ease;
}

.enterprise-sidebar.collapsed
#dashboardV2Nav.dashboard-v2-nav > button:hover::after,
.enterprise-sidebar.collapsed
#dashboardV2Nav.dashboard-v2-nav > button:focus-visible::after {

    opacity: 1;

    visibility: visible;

    transform: translateY(-50%) translateX(0);
}

/* ----------------------------------------------------------
   Sidebar footer
   ---------------------------------------------------------- */

.enterprise-sidebar-footer {
    flex: 0 0 auto;

    margin-top: 12px;
    padding: 12px 8px 2px;

    border-top:
        1px solid
        rgba(148, 163, 184, 0.14);
}

.sidebar-version {
    color: var(--enterprise-nav-text-muted);

    font-size: 10px;
    font-weight: 600;
    line-height: 1.3;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------
   Sidebar scrollbar
   ---------------------------------------------------------- */

.enterprise-nav::-webkit-scrollbar {
    width: 5px;
}

.enterprise-nav::-webkit-scrollbar-track {
    background: transparent;
}

.enterprise-nav::-webkit-scrollbar-thumb {
    background:
        rgba(100, 116, 139, 0.45);

    border-radius: 999px;
}

.enterprise-nav::-webkit-scrollbar-thumb:hover {
    background:
        rgba(100, 116, 139, 0.7);
}

.enterprise-nav {
    scrollbar-width: thin;
    scrollbar-color:
        rgba(100, 116, 139, 0.45)
        transparent;
}

/* ----------------------------------------------------------
   Workspace safety
   ---------------------------------------------------------- */

.topbar,
.dashboard-v2-panel {
    box-sizing: border-box;
    max-width: 100%;
}

/* Prevent wide dashboard grids or tables from expanding the
   browser viewport beneath the fixed sidebar. */

.dashboard-v2-panel {
    min-width: 0;
    overflow-x: hidden;
}

.dashboard-v2-panel table {
    max-width: 100%;
}

/* ----------------------------------------------------------
   Initial responsive safety fallback
   ----------------------------------------------------------
   Full collapse behavior will be added in PT-4.

   For now, small screens receive a stacked layout so the
   platform remains usable instead of being hidden behind the
   fixed sidebar.
   ---------------------------------------------------------- */

@media (max-width: 900px) {

    body {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .enterprise-sidebar {
        position: relative;

        top: auto;
        right: auto;
        bottom: auto;
        left: auto;

        width: 100%;
        height: auto;
        max-height: none;

        margin-bottom: 18px;
        padding: 14px;

        border-right: 0;
        border-bottom:
            1px solid
            var(--enterprise-sidebar-border);

        box-shadow:
            0 8px 22px
            rgba(2, 6, 23, 0.22);

        overflow: visible;
    }

    .enterprise-brand {
        min-height: auto;
        padding-bottom: 13px;
    }

    .enterprise-nav {
        overflow: visible;
    }

    #dashboardV2Nav.dashboard-v2-nav {
        display: grid;

        grid-template-columns:
            repeat(
                auto-fit,
                minmax(180px, 1fr)
            );

        gap: 5px;
    }

    .enterprise-sidebar-footer {
        margin-top: 10px;
    }
}
/* Preserve the existing collapsed rail when the older stacked fallback applies. */
@media (max-width: 900px) {
    .enterprise-sidebar.collapsed {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        margin-bottom: 0;
    }
    .enterprise-sidebar.collapsed .enterprise-nav { overflow-y: auto; overflow-x: hidden; }
    .enterprise-sidebar.collapsed #dashboardV2Nav.dashboard-v2-nav {
        display: flex;
        flex-direction: column;
    }
}
