﻿body {
    overflow-x: hidden;
}

/* Sidebar base */
.sidebar {
    position: fixed;
    top: 62px; /* height of navbar */
    left: 0;
    width: auto; /* auto width based on text */
    min-width: 33px;
    max-width: 660px;
    background: #f8f9fa;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 62px);
}

    .sidebar.collapsed {
        width: 70px; /* Width for the icon-only view */
    }

    .sidebar .nav-link {
        display: flex;
        align-items: center;
        white-space: nowrap;
        transition: all 0.3s ease;
        padding: 10px 15px;
        color: #000;
    }

        /* 1. Base style for ALL icons (applies margin, size, and makes sure they are block elements) */
        .sidebar .nav-link .material-symbols-outlined {
            font-size: 24px;
            margin-right: 15px;
            min-width: 24px;
            text-align: center;
            /* Ensure it displays by default so top-level items show icons when expanded */
            display: block;
        }

    /* 2. Collapsed View: Top-Level Menu Items (Maintenance, Dealer Trans, etc.) */

    /* Target only the direct children of the main nav */
    .sidebar.collapsed .sidebar-menu > .nav > .nav-item > .nav-link {
        justify-content: center; /* Center the content (the icon) */
    }

        /* In Collapsed state, show icon, remove margin */
        .sidebar.collapsed .sidebar-menu > .nav > .nav-item > .nav-link .material-symbols-outlined {
            display: block; /* Show the icon */
            margin-right: 0;
        }

        /* In Collapsed state, hide label for top-level links */
        .sidebar.collapsed .sidebar-menu > .nav > .nav-item > .nav-link .label {
            display: none;
        }


    /* 3. Collapsed View: Submenu Items (like "Customer Master File") */

    /* When collapsed, we need to explicitly hide any icons on submenu links and ensure the text label is always visible. */
    .sidebar.collapsed .submenu .nav-link .material-symbols-outlined {
        display: none !important;
    }

    .sidebar.collapsed .submenu .nav-link .label {
        /* Ensure submenu text remains visible */
        display: inline !important;
    }


    /* --- Red Highlight Styles --- */
    .sidebar .nav-link:hover {
        background-color: #dc3545;
        color: #ffffff !important;
    }

    .sidebar .nav-link.active {
        background-color: #dc3545;
        color: #ffffff !important;
        font-weight: 500;
    }

        .sidebar .nav-link:hover .material-symbols-outlined,
        .sidebar .nav-link.active .material-symbols-outlined {
            color: #ffffff;
        }

    .sidebar .submenu .nav-link.active {
        background-color: #f8d7da;
        color: #721c24;
        font-weight: 500;
    }

    .sidebar .submenu .nav-link:hover {
        background-color: #dc3545;
        color: #ffffff !important;
    }


/* Submenu */
.submenu {
    display: none;
    padding-left: 40px;
}

    .submenu.show {
        display: block;
    }

.nav-item.has-sub > .nav-link::after {
    content: "expand_more";
    font-family: "Material Symbols Outlined";
    margin-left: auto;
    transition: transform 0.3s ease;
}

/* --- HIDE DROPDOWN ARROW WHEN COLLAPSED --- */
.sidebar.collapsed .nav-item.has-sub > .nav-link::after {
    display: none;
}


.nav-item.has-sub.open > .nav-link::after {
    transform: rotate(180deg);
}

/* Content area */
.content {
    /* *** NAV BAR OVERLAP FIX: Push content down by 62px (navbar height) *** */
    margin-top: 62px;
    /* ******************************************************************** */

    margin-left: 250px;
    transition: margin-left 0.3s ease;
    padding: 20px;
}

.sidebar.collapsed ~ .content {
    margin-left: 70px; /* Match the collapsed sidebar width */
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

    .sidebar-menu::-webkit-scrollbar {
        display: none;
    }

.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 1rem;
    background-color: #fff;
    position: relative;
}


.rotate-180 {
    transform: rotate(180deg);
    transition: transform 0.2s ease;
}


#sidebar.collapsed .profile-info,
#sidebar.collapsed .username,
#sidebar.collapsed small {
    display: none;
}



.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    cursor: pointer;
}

.sidebar-profile .avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    font-size: 28px;
    border-radius: 50%;
}

.sidebar-profile .username {
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar.collapsed .profile-info {
    display: none;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

    .content {
        margin-left: 0 !important;
    }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    width: 100%;
    height: calc(100% - 56px);
    background: rgba(0, 0, 0, 0);
    z-index: 1029;
}

    .sidebar-backdrop.show {
        display: block;
    }

body.few-sidebar-margin .content {
    margin-left: 188px;
    margin-right: 0px;
}

.navbar-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}
