﻿/* ==========================================================================
   1. Global Styles & Variables
   ========================================================================== */
:root {
    /* Color Palette & Sizing */
    --header-height: 65px;
    --mainbackground: #f8f9fa; /* Light grey background for content area */
    --navsidebarbackground: #34495E; /* wet asphalt */
    --navsidebartext: #e0e1dd; /* light text color for sidebar */
    --navsidebaractive: #415a77; /* sidebar active/hover highlight */
    --navsidebartextmuted: #adb5bd; /* muted nav link text */
    --navsidebarhover: #1b263b; /* nav link hover background */
    --navsidebartexthover: #ffffff;
    --nav2background: #EAEAEA; /* darker defined gray */
    --sidebar-width: 100px;
    --sidebar-width-collapsed: 56px;
    --bottom-nav-height: 0px;
}

/* ==========================================================================
   2. Main Page Layout
   ========================================================================== */
.page-container {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
}

.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--mainbackground);
    border-left: 1px solid var(--bordergray);
    margin-left: var(--sidebar-width);
    transition: margin-left 0.25s ease;
}

.content-body {
    padding: 1.5rem;
    flex-grow: 1;
    min-width: 0;
    overflow-x: hidden;
}

/* Full-page mode: hide footer, remove padding, give content a fixed height.
   No overflow changes on page-container or main-content — keeps sidebar intact. */
.page-container:has(.content-full) .footer,
.page-container:has(.no-footer) .footer {
    display: none;
}

.content-body.content-full {
    padding: 0;
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
    overflow: auto;
}

/* Adjust component sidebar height to account for the top nav */
.content-body.content-full .ps-designer-sidebar {
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
}

.chart-container-full {
    width: 100%;
    height: 100%;
}

.workbench-icon {
    font-size: 1.3rem;
}

.nav-text {
    white-space: pre-line;
    font-size: 0.75rem;
    text-align: center;
    transition: font-size 0.25s ease;
}

.ots-sidebar-nav-wrapper {
    width: 95%;
    padding-top: 1rem;
}

.ots-sidebar-nav {
    gap: 0.5rem;
}

/* ==========================================================================
   3. Top Navigation Bar
   ========================================================================== */
.ots-breadcrumb {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.15rem;
}

.ots-breadcrumb-link {
    color: #6c757d;
    text-decoration: none;
}

.ots-breadcrumb-link:hover {
    color: var(--bs-body-color);
    text-decoration: underline;
}

.ots-breadcrumb-sep {
    color: #adb5bd;
    margin: 0 0.3rem;
}

.ots-breadcrumb-current {
    color: var(--bs-body-color);
    font-weight: 500;
}

.ots-breadcrumb-powered {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: 0.75rem;
}

.ots-breadcrumb-powered a {
    color: #6c757d;
    text-decoration: none;
}

.ots-breadcrumb-powered a:hover {
    color: var(--bs-body-color);
    text-decoration: underline;
}

.top-nav .nav-link .bi,
.top-nav .btn .bi {
    font-size: 1.15rem;
    vertical-align: middle;
}

.units-toggle {
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.units-toggle span {
    font-size: 0.85rem;
    font-weight: 600;
}

.units-toggle:hover {
    background-color: rgba(0,0,0,0.08);
}

[data-bs-theme="dark"] .units-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

.ots-logo {
    height: 50px;
}

.top-nav {
    height: var(--header-height);
    padding: 0 1.5rem;
    border-bottom: 1px solid #dee2e6;
    border-top: 1px solid var(--bordergray);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    background-color: var(--nav2background) !important; /* Override default bg-light */
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
}

.custom-menu-btn {
    background-color: var(--OTS-Blue); /* Primary blue */
    border: hidden;
}

    .custom-menu-btn .bi-list {
        color: var(--OTS-Green); /* Green icon lines */
        font-size: 1.5rem;
    }

/* ==========================================================================
   4. Sidebar (Desktop)
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--navsidebarbackground);
    color: var(--navsidebartext);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    overflow-y: auto;
    transition: width 0.25s ease;
}

.sidebar-header {
    height: var(--header-height);
    background: var(--navsidebarbackground);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    flex-shrink: 0;
}

.sidebar .navbar-brand {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar .nav-item {
    padding: 0.25rem 0;
}

.sidebar .nav-link {
    color: var(--navsidebartextmuted);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    border-radius: 0.375rem;
    margin: 0.1rem 0.5rem;
    transition: background-color 0.2s, color 0.2s;
}

    .sidebar .nav-link .bi {
        font-size: 1.2rem; /* Icon size */
    }

    .sidebar .nav-link:hover {
        background-color: var(--navsidebarhover);
        color: var(--navsidebartexthover);
    }

    .sidebar .nav-link.active {
        background-color: var(--navsidebaractive);
        color: var(--navsidebartexthover);
        font-weight: 500;
    }


/* ==========================================================================
   4b. Sidebar Flyout Submenu
   ========================================================================== */
.ots-sidebar-flyout {
    display: none;
    position: fixed;
    min-width: 200px;
    background-color: var(--navsidebarbackground);
    border: 1px solid var(--navsidebaractive);
    border-radius: 0.375rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    padding: 0.35rem 0;
    z-index: 99999;
}

.ots-sidebar-flyout.open {
    display: block;
}

.ots-sidebar-flyout-item,
[data-bs-theme="dark"] .ots-sidebar-flyout-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--navsidebartext);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}

.ots-sidebar-flyout-item:hover,
[data-bs-theme="dark"] .ots-sidebar-flyout-item:hover {
    background-color: var(--navsidebaractive);
    color: var(--navsidebartexthover);
}

.ots-sidebar-flyout-item i {
    font-size: 1rem;
    width: 1.5rem;
    text-align: center;
}

.ots-sidebar-flyout-divider {
    margin: 0.25rem 0.75rem;
    border-color: var(--navsidebaractive);
    opacity: 0.5;
}

/* ==========================================================================
   4c. Sidebar Collapsed State
   ========================================================================== */
[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-width-collapsed);
}

[data-sidebar="collapsed"] .main-content {
    margin-left: var(--sidebar-width-collapsed);
}

[data-sidebar="collapsed"] .ots-sidebar-nav-wrapper {
    width: 100%;
    padding-top: 0.5rem;
}

[data-sidebar="collapsed"] .ots-sidebar-nav {
    gap: 0.25rem;
}

[data-sidebar="collapsed"] .sidebar .nav-link {
    padding: 0.4rem 0.25rem;
    margin: 0.1rem 0.15rem;
}

[data-sidebar="collapsed"] .sidebar .nav-link .bi {
    font-size: 1rem;
}

[data-sidebar="collapsed"] .nav-text {
    font-size: 0.55rem;
}

[data-sidebar="collapsed"] .sidebar .nav-item {
    padding: 0.1rem 0;
}

/* Sidebar toggle button */
.ots-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    margin-top: auto;
    background: transparent;
    border: none;
    color: var(--navsidebartextmuted);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.ots-sidebar-toggle:hover {
    color: var(--navsidebartexthover);
    background-color: var(--navsidebarhover);
}

.ots-sidebar-toggle .bi {
    font-size: 1rem;
    transition: transform 0.25s ease;
}

[data-sidebar="collapsed"] .ots-sidebar-toggle .bi {
    transform: rotate(180deg);
}

/* ==========================================================================
   5. Off-canvas Mobile Menu
   ========================================================================== */
.offcanvas-sidebar-dark {
    --bs-offcanvas-width: 150px;
    background-color: var(--navsidebarbackground); /* Match the main sidebar color */
    color: var(--navsidebartext);
}

    .offcanvas-sidebar-dark .offcanvas-header {
        background: var(--navsidebarbackground);
        border-bottom: 5px solid #1b263b;
        height: 65px;
    }

    .offcanvas-sidebar-dark .offcanvas-title {
        color: #ffffff;
    }

    .offcanvas-sidebar-dark .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
    }


/* ==========================================================================
   6. Footer
   ========================================================================== */
.footer {
    background-color: var(--nav2background);
    flex-shrink: 0;
    padding: 1rem;
    border-top: 1px solid var(--bordergray);
    text-align: center;
    color: #6c757d;
}

.footer-link {
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

    .footer-link:hover {
        color: #0d6efd !important;
        text-decoration: underline;
    }

    .footer-link[href*="github.com"] svg {
        color: #181717;
        transition: color 0.2s ease-in-out;
    }

    .footer-link[href*="linkedin.com"] svg {
        color: #0A66C2;
        transition: color 0.2s ease-in-out;
    }

    .footer-link[href*="github.com"]:hover svg {
        color: #444;
    }

    .footer-link[href*="linkedin.com"]:hover svg {
        color: #004182;
    }

/* ==========================================================================
   7. Mobile Bottom Navbar
   ========================================================================== */
.bottom-nav {
    background-color: var(--navsidebarbackground);
    border-top: 1px solid #1b263b;
    height: var(--bottom-nav-height);
    max-height: var(--bottom-nav-height);
    padding: 0;
    overflow: hidden;
}

    .bottom-nav .d-flex {
        padding: 0.15rem 0;
    }

    .bottom-nav .nav-link {
        color: #adb5bd;
        transition: color 0.2s ease-in-out;
        padding: 0.1rem 0.25rem;
        line-height: 1;
    }

    .bottom-nav .nav-link .bi {
        font-size: 1.1rem;
    }

    .bottom-nav .nav-text {
        font-size: 0.6rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60px;
    }

        /* Style for the active or hovered link */
        .bottom-nav .nav-link:hover,
        .bottom-nav .nav-link.active {
            color: #ffffff; /* Bright white, matching your desktop sidebar's active state */
        }

/* ==========================================================================
   8. Responsive Design
   ========================================================================== */
/* Hide sidebar on smaller screens */
@media (max-width: 991.98px) {
    :root {
        --bottom-nav-height: 55px;
    }

    .page-container > .sidebar {
        display: none;
    }

    .main-content,
    [data-sidebar="collapsed"] .main-content {
        margin-left: 0;
        padding-bottom: var(--bottom-nav-height);
    }

    .ots-sidebar-toggle {
        display: none;
    }

    .content-body.content-full {
        height: auto;
        overflow: auto;
    }

    /* Undo the fixed 100vh sidebar height from the desktop rule above. The component
       stacks to block flow at this width, so a forced viewport height leaves its taller
       content overflowing down over the perf cards that follow it. */
    .content-body.content-full .ps-designer-sidebar {
        height: auto;
    }

    .chart-container-full {
        height: auto;
        min-height: 80vh;
    }

    .ots-logo {
        height: 28px;
    }

    .top-nav {
        padding: 0 0.5rem;
    }

    .navbar-brand {
        margin-left: 0.5rem !important;
    }
}

/* ==========================================================================
   9. Dark Mode Overrides
   ========================================================================== */

[data-bs-theme="dark"] {
    --mainbackground: #212529;
    --nav2background: #2b3035;
    --navsidebarbackground: #2b3035;
    --navsidebartext: #dee2e6;
    --navsidebaractive: #3d444b;
    --navsidebartextmuted: #9ca3af;
    --navsidebarhover: #212529;
    --navsidebartexthover: #ffffff;
}

[data-bs-theme="dark"] .top-nav {
    border-bottom-color: #373b3f;
    border-top-color: #373b3f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .footer {
    color: #adb5bd;
    border-top-color: #373b3f;
}

[data-bs-theme="dark"] .footer-link[href*="github.com"] svg {
    color: #dee2e6;
}

[data-bs-theme="dark"] .footer-link[href*="github.com"]:hover svg {
    color: #ffffff;
}

[data-bs-theme="dark"] .bottom-nav {
    border-top-color: #373b3f;
}