/* Enhanced Sidebar Styles with Modern UI/UX Improvements */

/* ===== Main Sidebar Configuration ===== */
.main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    overflow: visible !important;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #2b3a4a 0%, #1f2a36 100%);
}

/* ===== Brand Section ===== */
.brand-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    height: 57px;
}

.brand-image {
    width: 33px;
    height: 33px;
    margin-right: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 600;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ===== Sidebar Search ===== */
.sidebar-search-wrapper {
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    position: relative;
}

.form-control-sidebar {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e9ecef;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0.375rem;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    font-size: 0.875rem;
}

.form-control-sidebar:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: #007bff;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control-sidebar::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.btn-sidebar-search {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    z-index: 10;
}

.btn-sidebar-search:hover {
    color: #fff;
}

/* ===== Navigation Items ===== */
.nav-sidebar {
    padding: 0.5rem 0;
    margin-top: 0.25rem;
}

.nav-sidebar > .nav-item {
    margin-bottom: 3px;
    border-radius: 0.375rem;
    margin: 0 0.5rem 3px 0.5rem;
    transition: all 0.2s ease;
}

.nav-sidebar > .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    transform: translateY(-1px);
}

.nav-sidebar .nav-link {
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 46px;
    display: flex;
    align-items: center;
    color: #c2c7d0;
    position: relative;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.nav-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transform: translateX(2px);
}

.nav-sidebar .nav-link.active {
    background: linear-gradient(90deg, #007bff 0%, #0069d9 100%);
    color: #fff;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.nav-sidebar .nav-link p {
    margin: 0;
    margin-left: 0.85rem;
    white-space: nowrap;
    transition: opacity 0.3s ease;
    font-size: 0.95rem;
}

/* ===== Navigation Icons ===== */
.nav-icon {
    font-size: 1.15rem;
    width: 26px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.nav-link:hover .nav-icon {
    transform: scale(1.15) rotate(5deg);
    filter: brightness(1.2) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* ===== Treeview (Dropdown Menus) ===== */
.nav-treeview {
    padding-left: 1.25rem;
    display: none;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
    margin-top: 0.25rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-open > .nav-treeview {
    display: block;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-treeview .nav-link {
    padding: 0.6rem 1rem 0.6rem 2.75rem;
    font-size: 0.92rem;
    font-weight: 400;
    background: transparent;
    color: #adb5bd;
    border-left: 2px solid transparent;
}

.nav-treeview .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
    transform: translateX(3px);
}

.nav-treeview .nav-link.active {
    background-color: rgba(0, 123, 255, 0.15);
    color: #007bff;
    border-left: 2px solid #007bff;
    box-shadow: none;
}

.nav-treeview .nav-icon {
    font-size: 0.9rem;
    width: 22px;
}

/* ===== Right Arrow for Expandable Items ===== */
.right.fas {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: auto;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

.menu-open > .nav-link .right.fas {
    transform: rotate(90deg);
    color: #fff;
}

.nav-link:hover .right.fas {
    color: #fff;
}

/* ===== Sidebar Collapsed State ===== */
.sidebar-collapse .main-sidebar {
    width: 70px;
}

.sidebar-collapse .brand-text,
.sidebar-collapse .user-panel .info,
.sidebar-collapse .sidebar-search-wrapper,
.sidebar-collapse .nav-link p,
.sidebar-collapse .right.fas {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-collapse .brand-link {
    justify-content: center;
    padding: 0.875rem 0;
}

.sidebar-collapse .brand-image {
    margin-right: 0;
}

.sidebar-collapse .nav-sidebar .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapse .nav-icon {
    margin-left: 0;
    margin-right: 0;
}

.sidebar-collapse .nav-treeview {
    display: none !important;
}

.sidebar-collapse .sidebar {
    overflow: visible;
}

.sidebar-collapse .nav-sidebar {
    overflow: visible;
}

.sidebar-collapse .nav-item {
    overflow: visible;
}

/* ===== Tooltip for Collapsed Sidebar ===== */
.sidebar-collapse .nav-link:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    left: 70px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #343a40;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    min-width: 150px;
    text-align: left;
}

.sidebar-collapse .nav-link:hover::before {
    opacity: 1;
    visibility: visible;
    left: 75px;
}

/* ===== Fix for z-index issues ===== */
.sidebar-collapse .main-sidebar {
    z-index: 1040;
}

.sidebar-collapse .nav-link {
    z-index: 10;
    position: relative;
}

/* ===== Toggle Button ===== */
.sidebar-toggle-btn {
    position: fixed;
    top: 12px;
    left: 210px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #007bff;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1041;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4);
}

.sidebar-toggle-btn:hover {
    background-color: #0056b3;
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.5);
}

.sidebar-collapse .sidebar-toggle-btn {
    left: 30px;
}

.sidebar-toggle-btn i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* ===== Scrollbar Styling ===== */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Fix for Collapsed State Overflow ===== */
.sidebar-collapse .sidebar::-webkit-scrollbar {
    width: 0;
}

/* ===== Responsive Design ===== */
@media (max-width: 991.98px) {
    .main-sidebar {
        margin-left: -250px;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar-open .main-sidebar {
        margin-left: 0;
    }
    
    .sidebar-toggle-btn {
        left: 10px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar-open .sidebar-toggle-btn {
        left: 210px;
    }
}

/* ===== Additional Enhancements ===== */
.sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 57px);
    scroll-behavior: smooth;
    padding-bottom: 1rem;
    position: relative;
    z-index: 10;
}

/* Smooth entrance animation for menu items */
.nav-sidebar > .nav-item {
    animation: fadeInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.nav-sidebar > .nav-item:nth-child(1) { animation-delay: 0.05s; }
.nav-sidebar > .nav-item:nth-child(2) { animation-delay: 0.1s; }
.nav-sidebar > .nav-item:nth-child(3) { animation-delay: 0.15s; }
.nav-sidebar > .nav-item:nth-child(4) { animation-delay: 0.2s; }
.nav-sidebar > .nav-item:nth-child(5) { animation-delay: 0.25s; }
.nav-sidebar > .nav-item:nth-child(6) { animation-delay: 0.3s; }
.nav-sidebar > .nav-item:nth-child(7) { animation-delay: 0.35s; }
.nav-sidebar > .nav-item:nth-child(8) { animation-delay: 0.4s; }
.nav-sidebar > .nav-item:nth-child(9) { animation-delay: 0.45s; }
.nav-sidebar > .nav-item:nth-child(10) { animation-delay: 0.5s; }
.nav-sidebar > .nav-item:nth-child(11) { animation-delay: 0.55s; }
.nav-sidebar > .nav-item:nth-child(12) { animation-delay: 0.6s; }
.nav-sidebar > .nav-item:nth-child(13) { animation-delay: 0.65s; }
.nav-sidebar > .nav-item:nth-child(14) { animation-delay: 0.7s; }
.nav-sidebar > .nav-item:nth-child(15) { animation-delay: 0.75s; }

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== Additional Fix for Treeview Overflow ===== */
.sidebar-collapse .nav-treeview {
    overflow: hidden;
}

/* Active parent menu highlight */
.nav-item.menu-open > .nav-link:not(.active) {
    background-color: rgba(255, 255, 255, 0.05);
    color: #e9ecef;
}

/* Color preservation for icons */
.nav-link .text-primary { color: #007bff !important; }
.nav-link .text-success { color: #28a745 !important; }
.nav-link .text-info { color: #17a2b8 !important; }
.nav-link .text-warning { color: #ffc107 !important; }
.nav-link .text-danger { color: #dc3545 !important; }
.nav-link .text-secondary { color: #6c757d !important; }
.nav-link .text-dark { color: #495057 !important; }

/* Ensure icons maintain color on hover/active */
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    opacity: 1;
    filter: brightness(1.2) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

/* Focus states for accessibility */
.nav-link:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    z-index: 100;
}

/* Loading state */
.sidebar-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Print styles */
@media print {
    .main-sidebar {
        display: none;
    }
}

/* ===== Modern Enhancements ===== */

/* Subtle hover effect for all navigation items */
.nav-sidebar .nav-item {
    position: relative;
}

.nav-sidebar .nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 0.375rem;
    z-index: -1;
}

.nav-sidebar .nav-item:hover::before {
    opacity: 1;
}

/* Enhanced active state with glow effect */
.nav-sidebar .nav-link.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0.375rem;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.4);
    z-index: -1;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

/* Improved treeview item styling */
.nav-treeview .nav-link::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.nav-treeview .nav-link:hover::before {
    background-color: #007bff;
    transform: translateY(-50%) scale(1.3);
}

.nav-treeview .nav-link.active::before {
    background-color: #007bff;
}

/* Better spacing for nested items */
.nav-treeview .nav-item {
    margin: 2px 0;
}

/* Enhanced brand section */
.brand-link:hover {
    background: rgba(0, 0, 0, 0.2);
}

.brand-link:hover .brand-text {
    color: #fff;
}

/* Improved scrollbar */
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Smooth transitions for all interactive elements */
* {
    transition-property: background-color, color, border-color, box-shadow;
    transition-duration: 0.2s;
    transition-timing-function: ease-out;
}