/**
 * @name sidebar.css
 * @category CSS
 * @author Ruben Mercado <ruben.mercado@uconn.edu>
 * @copyright Copyright (c) 2026, ITS – Applications and Technology Solutions
 * @version 2.0
 */

::after,
::before {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
}

li {
    list-style: none;
}

.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar-backdrop {
    display: none;
}

.mobile-sidebar-trigger {
    display: none;
}

.main {
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    transition: all 0.35s ease-in-out;
    background-color: #f9f9f9;
}

#sidebar {
    width: 140px;
    min-width: 140px;
    z-index: 1000;
    transition: all 0.25s ease-in-out;
    background-color: #0f1938;
    display: flex;
    flex-direction: column;
}

#sidebar.expand {
    width: 220px;
    min-width: 220px;
}

#toggle-btn {
    background-color: transparent;
    cursor: pointer;
    border: 0;
    padding: 1rem 1.5rem;
}

#toggle-btn i {
    font-size: 1.5rem;
    color: #fff;
}

.sidebar-logo {
    margin: auto 0;
}

.sidebar-logo a {
    color: #fff;
    font-weight: 600;
    font-size: 1.5rem;
}

#sidebar:not(.expand) .sidebar-logo {
    display: none;
}

.sidebar-nav {
    padding: 2rem 0;
    flex: 1 1 auto;
}

a.sidebar-link {
    padding: 0.625rem 1.625rem;
    color: #fff;
    display: block;
    font-size: 0.9rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1.1rem;
    margin-right: 0.75rem;
}

a.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.057);
    border-left: 3px solid #3b7ddd;
}

.sidebar-item {
    position: relative;
}

/* Collapsed desktop flyout submenu */
#sidebar:not(.expand) .sidebar-item .sidebar-dropdown {
    position: absolute;
    top: 0;
    left: 140px;
    background-color: #0e2238;
    min-width: 15rem;
    z-index: 2000;
    display: none;
    padding: 0.5rem 0;
    overflow-y: auto;
    max-height: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#sidebar:not(.expand) .sidebar-item .sidebar-dropdown.show {
    display: block;
    max-height: 15rem;
    width: 100%;
    opacity: 1;
}

/* Keep hover behavior on desktop/laptop only */
@media (hover: hover) and (pointer: fine) and (min-width: 992px) {
    #sidebar:not(.expand) .sidebar-item:hover .has-dropdown + .sidebar-dropdown {
        display: block;
        max-height: 15rem;
        width: 100%;
        opacity: 1;
    }
}

#sidebar.expand .sidebar-link[data-bs-toggle="collapse"]::after {
    border: solid;
    border-width: 0 0.075rem 0.075rem 0;
    content: "";
    display: inline-block;
    padding: 2px;
    position: absolute;
    right: 1.5rem;
    top: 1.4rem;
    transform: rotate(-135deg);
    transition: all 0.2s ease-out;
}

#sidebar.expand .sidebar-link[data-bs-toggle="collapse"].collapsed::after {
    transform: rotate(45deg);
    transition: all 0.2s ease-out;
}

#sidebar button:hover {
    background-color: rgba(255, 255, 255, 0.057);
    border-left: 3px solid #3b7ddd;
}

#sidebar button:hover .bi-chevron-right::before,
#sidebar button:hover .bi-chevron-left::before {
    margin-left: -3px;
}

#sidebar:not(.expand) a.sidebar-link {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.5rem;
    font-size: 0.7rem;
}

#sidebar:not(.expand) a.sidebar-link i {
    margin-right: 0;
    margin-bottom: 0.25rem;
    font-size: 1.2rem;
}

#sidebar:not(.expand) a.sidebar-link span {
    display: block;
    margin: 0;
}

/* Mobile / tablet drawer mode — matches JS breakpoint */
@media (max-width: 991.98px) {
    .wrapper {
        position: relative;
    }

    .mobile-sidebar-trigger {
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 1042;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 0.5rem;
        background-color: #0f1938;
        color: #fff;
        box-shadow: 0 8px 18px rgba(15, 25, 56, 0.25);
    }

    .mobile-sidebar-trigger i {
        font-size: 1.5rem;
        line-height: 1;
    }

    .wrapper.sidebar-mobile-open .mobile-sidebar-trigger {
        display: none;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 25, 56, 0.45);
        z-index: 1039;
    }

    .wrapper.sidebar-mobile-open .sidebar-backdrop {
        display: block;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1041;
        width: min(280px, 82vw);
        min-width: min(280px, 82vw);
        transform: translateX(-100%);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.2);
        overflow-y: auto;
    }

    #sidebar.expand,
    .wrapper.sidebar-mobile-open #sidebar {
        width: min(280px, 82vw);
        min-width: min(280px, 82vw);
        transform: translateX(0);
    }

    #sidebar .sidebar-logo,
    #sidebar:not(.expand) .sidebar-logo {
        display: block;
    }

    #sidebar a.sidebar-link,
    #sidebar:not(.expand) a.sidebar-link {
        text-align: left;
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
    }

    #sidebar a.sidebar-link i,
    #sidebar:not(.expand) a.sidebar-link i {
        margin-right: 0.75rem;
        margin-bottom: 0;
        font-size: 1.1rem;
    }

    #sidebar:not(.expand) .sidebar-item .sidebar-dropdown {
        position: static;
        left: auto;
        min-width: 0;
        max-height: none;
        box-shadow: none;
        display: none;
    }

    #sidebar:not(.expand) .sidebar-item .sidebar-dropdown.show,
    #sidebar .sidebar-item .sidebar-dropdown.show {
        width: auto;
        max-height: none;
        display: block;
    }

    .main {
        width: 100%;
    }
}