﻿﻿/* =========================================================
   1. SIDEBAR — DESKTOP BASE (expanded)
   ========================================================= */
.sidebar-width {
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
    max-width: var(--sidebar-width) !important;
    flex: 0 0 var(--sidebar-width) !important;
    background-color: var(--ku-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: width 0.25s ease;
    position: relative;
    z-index: 1200;
    will-change: width;
}

    /* =========================================================
   COLLAPSED MODE — icon-only strip on desktop
   ========================================================= */
    .sidebar-width.sidebar-collapsed {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        max-width: var(--sidebar-collapsed-width) !important;
        flex-basis: var(--sidebar-collapsed-width) !important;
    }

/* Nav text: fade + shrink instead of display:none snap */
.sidebar-nav-container .nav-text,
.sidebar-footer .nav-text {
    display: inline-block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 200px;
    opacity: 1;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    vertical-align: middle;
}

.sidebar-width.sidebar-collapsed .nav-text,
.sidebar-width.sidebar-collapsed .sidebar-logo-img {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}

/* Nav link alignment: smooth transition */
.sidebar-nav-container .nav-link,
.sidebar-footer .nav-link {
    color: #4B5563;
    font-weight: 500;
    padding: 12px 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    transition: padding 0.25s ease, background-color 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-width.sidebar-collapsed .nav-link {
    padding: 12px 0;
    justify-content: center;
}

    .sidebar-width.sidebar-collapsed .nav-link i {
        margin-right: 0;
        width: var(--sidebar-collapsed-width);
    }

.theme-switcher-nav {
    margin-top: 4px;
}

.theme-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--ku-border);
    border-radius: 8px;
    background: var(--ku-surface-muted);
}

.theme-switcher-option {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
    background: transparent;
    color: var(--ku-text-muted);
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.theme-switcher-option:hover {
    color: var(--primary-color);
}

.theme-switcher-option.is-active,
.theme-switcher-option[aria-pressed="true"] {
    background: var(--ku-surface);
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(15,23,42,0.12);
}

.theme-switcher-option i {
    flex-shrink: 0;
    font-size: 1rem;
}

.sidebar-width.sidebar-collapsed .theme-switcher {
    flex-direction: column;
    align-items: center;
    padding: 4px;
    border-color: transparent;
    background: transparent;
}

.sidebar-width.sidebar-collapsed .theme-switcher-option {
    width: 36px;
    height: 32px;
    flex: 0 0 auto;
    padding: 0;
}

/* Logo img smooth fade */
.sidebar-logo-img {
    max-width: 160px;
    opacity: 1;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    overflow: hidden;
    display: block;
}

.sidebar-width.sidebar-collapsed .sub-menu {
    display: none !important;
}

.sidebar-width.sidebar-collapsed .sidebar-logo-row {
    justify-content: center;
    padding: 0;
}

/* =========================================================
   LOGO ROW & COLLAPSE BUTTON
   ========================================================= */
.sidebar-logo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: var(--header-height);
    min-height: var(--header-height);
    max-height: var(--header-height);
    flex-shrink: 0;
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.sidebar-toggle-slot {
    position: relative;
    flex: 0 0 0;
    width: 0;
    z-index: 1300;
}

/* =========================================================
   FLOATING SIDEBAR TOGGLE BUTTON (desktop)
   — small circle sitting exactly on the border between sidebar and content
   ========================================================= */
.sidebar-toggle-float {
    position: absolute;
    left: 0;
    top: calc(var(--header-height) + 12px);
    z-index: 1300;
    width: 34px;
    height: 34px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
    border: 2px solid #1a73e8;
    box-shadow: 0 0 0 4px rgba(26,115,232,0.12), 0 5px 16px rgba(26,115,232,0.32);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #174ea6;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
    padding: 0;
    flex-shrink: 0;
}

    .sidebar-toggle-float:hover {
        background: #1a73e8;
        color: var(--ku-surface);
        border-color: #1a73e8;
        box-shadow: 0 0 0 5px rgba(26,115,232,0.18), 0 7px 20px rgba(26,115,232,0.48);
        transform: translateX(-50%) scale(1.06);
    }

    .sidebar-toggle-float i {
        font-size: 0.95rem;
        line-height: 1;
        transition: transform 0.25s ease;
    }

@media (max-width: 991.98px) {
    .sidebar-toggle-float {
        display: none !important;
    }
}

/* The flex slot follows the sidebar edge independently of menu scrolling. */

.sidebar-nav-container,
.menu-container,
.main-nav-group,
.sidebar-nav-container ul,
.sidebar-nav-container .nav-item,
.sidebar-nav-container .sub-menu,
.sidebar-nav-container .nav-link,
.sidebar-nav-container .nav-text {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Hide mobile close row on desktop */
.sidebar-mobile-close {
    display: none;
}

/* Mobile close button */
.sidebar-mobile-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ku-text-muted);
    font-size: 1.2rem;
    transition: background 0.15s;
    padding: 0;
}

    .sidebar-mobile-close-btn:hover {
        background: #F3F4F6;
    }

/* =========================================================
   BACKDROP (mobile overlay)
   ========================================================= */

/* sidebar-nav-container .nav-text and .nav-link base styles are defined
   in the COLLAPSED MODE section above for smooth transition support */

.sidebar-nav-container .nav-link:hover {
    background-color: #F9FAFB;
    color: var(--primary-color);
}

.sidebar-nav-container .nav-link i {
    font-size: 1.2rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: margin 0.25s ease, width 0.25s ease;
}

/* Sub-menu */
.sidebar-nav-container .sub-menu {
    padding-left: 0;
    list-style: none;
    background-color: #F0F2F6;
    border-left: 0;
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    display: none;
    overflow: hidden;
}

.sidebar-nav-container .nav-item.is-active-branch > .sub-menu,
.sidebar-nav-container .nav-item.active > .sub-menu {
    display: block;
}

.sidebar-nav-container .sub-menu .nav-link {
    position: relative;
    padding: 8px 10px 8px 25px;
    font-size: 13.5px;
}

/* Continue the parent's active indicator with a quieter tree guide. */
.sidebar-nav-container .sub-menu > .nav-item {
    position: relative;
    --submenu-guide-color: color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.sidebar-nav-container .sub-menu > .nav-item::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--primary-color);
    z-index: 1;
    pointer-events: none;
}

.sidebar-nav-container .sub-menu > .nav-item > .nav-link::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0;
    height: 50%;
    width: 14px;
    border-left: 1px solid var(--submenu-guide-color);
    border-bottom: 1px solid var(--submenu-guide-color);
    border-bottom-left-radius: 6px;
    pointer-events: none;
}

.sidebar-nav-container .sub-menu > .nav-item > .nav-link.active::before,
.sidebar-nav-container .sub-menu > .nav-item > .nav-link:hover::before,
.sidebar-nav-container .sub-menu > .nav-item > .nav-link:focus-visible::before {
    border-color: var(--primary-color);
}

.sidebar-nav-container .sub-menu .nav-link i {
    font-size: 1rem;
    width: 20px;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/Timesheet"],
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/SessionNotes"],
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/TakeNotes"],
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/DOEForms"] {
    justify-content: flex-start;
    box-sizing: border-box;
    width: calc(100% - 34px);
    min-height: 38px;
    min-width: 0;
    margin: 4px 17px;
    padding: 6px 9px !important;
    border-radius: 6px;
    color: #fff !important;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.15;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
    overflow: visible;
}

/* Keep guides outside the inset action buttons, aligned with the tree. */
.sidebar-nav-container .sub-menu .nav-link:is(
    [href$="/Views/Timesheet"], [href$="/Views/SessionNotes"],
    [href$="/Views/TakeNotes"], [href$="/Views/DOEForms"])::before {
    left: -16px;
    top: -5px;
    height: calc(50% + 5px);
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/Timesheet"],
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/SessionNotes"] {
    background: linear-gradient(180deg, #1f7bf2 0%, #0d6efd 100%) !important;
    border: 1px solid #0b5ed7;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/TakeNotes"],
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/DOEForms"] {
    background: linear-gradient(180deg, #249b61 0%, #198754 100%) !important;
    border: 1px solid #157347;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/Timesheet"]:hover,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/SessionNotes"]:hover {
    background: linear-gradient(180deg, #3189ff 0%, #176fe4 100%) !important;
    color: #fff !important;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/TakeNotes"]:hover,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/DOEForms"]:hover {
    background: linear-gradient(180deg, #2aa76a 0%, #1d915b 100%) !important;
    color: #fff !important;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/Timesheet"] i,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/SessionNotes"] i,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/TakeNotes"] i,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/DOEForms"] i {
    color: #fff !important;
    margin-right: 7px !important;
    width: 18px;
    font-size: 0.95rem;
    text-align: center;
}

.sidebar-nav-container .sub-menu .nav-link[href$="/Views/Timesheet"] .nav-text,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/SessionNotes"] .nav-text,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/TakeNotes"] .nav-text,
.sidebar-nav-container .sub-menu .nav-link[href$="/Views/DOEForms"] .nav-text {
    display: block;
    text-overflow: ellipsis;
}

/* Active states */
.sidebar-nav-container .nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

.sidebar-nav-container .nav-level-0 > .nav-link.active {
    background-color: #FFF1F2;
    border-left: 3px solid var(--primary-color);
}

.sidebar-backdrop {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1299;
}

.sidebar-backdrop.show {
    visibility: visible;
    opacity: 1;
}

.header-height {
    display: flex;
}

.sidebar-hamburger-btn {
    display: none;
}

/* =========================================================
   2. MOBILE STYLES (< 768px)
   ========================================================= */
@media (max-width: 991px) {
    /* Sidebar hidden off-screen by default on mobile */
    .sidebar-width {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100vw !important;
        min-width: 0 !important;
        max-width: 100vw !important;
        height: 100vh !important;
        z-index: 1300;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        flex-direction: column;
    }

        .sidebar-width.sidebar-mobile-open {
            transform: translateX(0);
        }
    /* =========================================================
   HAMBURGER BUTTON (mobile, shown in header)
   ========================================================= */
    .sidebar-hamburger-btn {
        display: flex;
        background: #1a73e8;
        border: none;
        cursor: pointer;
        color: var(--ku-surface);
        width: 38px;
        height: 38px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        box-shadow: 0 2px 8px rgba(26,115,232,0.30);
        transition: background 0.15s, box-shadow 0.15s;
    }

        .sidebar-hamburger-btn:hover {
            background: #1558b0;
            box-shadow: 0 4px 12px rgba(26,115,232,0.40);
        }
    /* Show mobile close button row */
    .sidebar-mobile-close {
        display: flex !important;
        border-bottom: 1px solid var(--border-color);
    }
    /* Hide desktop collapse btn on mobile */
    .sidebar-collapse-btn {
        display: none !important;
    }
    /* Logo row takes full width */
    .sidebar-logo-row {
        justify-content: flex-start;
    }
    /* Nav links full-width left-aligned */
    .sidebar-nav-container .nav-link {
        justify-content: flex-start;
        padding: 12px 20px;
    }

        .sidebar-nav-container .nav-link i {
            margin-right: 12px;
            width: 24px;
        }
    /* Sub-menus visible when active on mobile */
    .sidebar-nav-container .sub-menu {
        display: none;
        position: static;
        width: 100%;
        background-color: #F0F2F6;
        margin: 0;
        padding-left: 0;
        border-left: 0;
    }

    .sidebar-nav-container .nav-item.active > .sub-menu,
    .sidebar-nav-container .nav-item.is-active-branch > .sub-menu {
        display: block;
    }

    .sidebar-nav-container .nav-level-1 > .nav-link {
        padding-left: 45px;
        font-size: 13.5px;
    }

    .sidebar-nav-container .nav-level-2 > .nav-link {
        padding-left: 65px;
        font-size: 13px;
    }

    .sidebar-nav-container .nav-level-3 > .nav-link {
        padding-left: 85px;
        font-size: 12.5px;
    }

    .sidebar-nav-container .nav-link.active {
        background-color: #FFF1F2;
    }
    /* Footer scrolls with sidebar on mobile */
    .sidebar-footer {
        flex-shrink: 0;
    }
    /* Collapsed class has no effect on mobile — handled by JS */
    .sidebar-width.sidebar-collapsed {
        width: 100vw !important;
        transform: translateX(-100%);
    }

        .sidebar-width.sidebar-collapsed.sidebar-mobile-open {
            transform: translateX(0);
        }
}

/* =========================================================
   TABLET AUTO-COLLAPSE (768px – 991px): collapsed by default, toggle available
   ========================================================= */
@media (min-width: 992px) and (max-width: 1199px) {
    .sidebar-width:not(.sidebar-collapsed) {
        /* Force collapsed on tablet unless user explicitly expanded */
    }
    /* On tablets auto-apply collapsed appearance at first load via JS */
}
