/* Advanced Sidebar with Enhanced Visual Design */

/* Base sidebar styles with improved aesthetics - Tablet Optimized */
.sidebar {
    width: 240px; /* Reduced from 260px for tablets */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1050;
    overflow: hidden;
    background: linear-gradient(135deg, #2c3e50 0%, #1a1d21 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border-radius: 0 20px 20px 0; /* Slightly reduced radius */
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
}

/* Tablet-specific optimizations */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px; /* Even smaller for tablets */
        border-radius: 0 15px 15px 0; /* Smaller radius */
    }
    
    /* Collapsed sidebar optimizations for tablets */
    .sidebar.collapsed {
        width: 50px; /* Ultra-compact for tablets */
    }
    
    .sidebar.collapsed .nav-link {
        padding: 0.4rem 0; /* More compact for tablets */
    }
    
    .sidebar.collapsed .nav-icon {
        width: 16px; /* Smaller for tablets */
        height: 16px;
        font-size: 0.8rem;
    }
}

/* Fix the sidebar structure - Proper Layout */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Fixed header at top */
.sidebar-header {
    flex-shrink: 0; /* Don't allow shrinking */
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #2c3e50 0%, #1a1d21 100%);
}

/* Scrollable navigation container - items packed from top */
.nav-container {
    flex: 1;
    overflow-y: auto;
    display: block; /* Changed from flex to block to prevent equal distribution */
    padding: 0.4rem 0.8rem 0.4rem 0.8rem; /* Start content from top */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
    /* Ensure content starts from top, not centered or distributed */
    min-height: 0; /* Allow shrinking */
    height: auto; /* Natural height */
}

/* Fixed footer at bottom */
.sidebar-footer {
    flex-shrink: 0; /* Don't allow shrinking */
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: linear-gradient(135deg, #2c3e50 0%, #1a1d21 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container::-webkit-scrollbar {
    width: 4px;
}

.nav-container::-webkit-scrollbar-track {
    background: transparent;
}

.nav-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

/* Improved visual styling for sidebar items with reduced font size */
.nav-item {
    margin-bottom: 0.3rem; /* Reduced from 0.4rem */
    position: relative;
    border-radius: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.nav-item:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(229, 57, 53, 0.2) 0%, rgba(211, 47, 47, 0.2) 100%); /* Red gradient */
    transition: all 0.4s ease;
    z-index: -1;
    border-radius: 12px;
}

.nav-item:hover:before {
    width: 100%;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem; /* Further reduced for tablets */
    padding: 0.5rem 0.9rem 0.5rem 0.9rem; /* Match active state left padding */
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 10px; /* Slightly smaller radius */
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    border: 1px solid transparent;
}

.nav-item:hover .nav-link {
    color: white;
    transform: translateX(5px);
    padding-left: 0.9rem; /* Maintain consistent left padding on hover */
}

.nav-item.active {
    background: linear-gradient(135deg, #e53935 0%, #d32f2f 100%); /* Red gradient instead of purple */
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.4); /* Updated shadow color */
    transform: translateZ(0);
}

.nav-item.active .nav-link {
    color: white;
    transform: translateX(0); /* Move the active link slightly to the left */

}

/* Ensure active nav-item has proper alignment */
.nav-item.active {
    margin-left: 0; /* Reset any inherited margins */
    margin-right: 0; /* Reset any inherited margins */
}

/* Enhanced icon styling - ensure icon size is consistent - Tablet Optimized */
.nav-icon {
    width: 18px; /* Reduced for tablets */
    height: 18px; /* Reduced for tablets */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 0.8rem; /* Further reduced for tablets */
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px; /* Smaller radius for tablets */
    flex-shrink: 0;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    color: white;
    transform: scale(1.1);
}

.nav-item.active .nav-icon {
    transform: scale(1.2);
}

/* Add subtle indicator for active item */
.nav-indicator {
    position: absolute;
    right: 1rem;
    width: 6px;
    height: 6px;
    background: #ffcdd2; /* Light red color for indicator dot */
    border-radius: 50%;
    opacity: 0;
    transition: all 0.3s ease;
}

.nav-item.active .nav-indicator {
    opacity: 1;
}

/* Styling for Bengali text */
.nav-text-container {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow text truncation */
    flex: 1;
}

.nav-text-primary {
    font-size: 0.75rem; /* Further reduced for tablets */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2; /* Tighter line height for tablets */
}

.nav-text-secondary {
    font-size: 0.65rem; /* Further reduced for tablets */
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400; /* Lighter weight for secondary text */
    line-height: 1.1; /* Tighter line height */
}

/* Collapsed sidebar styles - improved display of icons */
.sidebar.collapsed {
    width: 60px; /* Reduced width for better alignment */
}

.sidebar.collapsed .nav-text-container,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .user-info,
.sidebar.collapsed .sidebar-header .logo-img {
    opacity: 0;
    visibility: hidden;
}

.sidebar.collapsed .sidebar-header {
    padding: 0.5rem 0; /* Reduced padding */
    height: auto; /* Auto height for flexibility */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Perfect center alignment for collapsed icons */
.sidebar.collapsed .nav-item {
    width: 100%;
    margin-bottom: 0.2rem; /* Consistent spacing */
}

.sidebar.collapsed .nav-link {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.6rem 0; /* Reduced padding */
    width: 100%;
    position: relative;
    margin: 0 auto; /* Center the entire link */
}

.sidebar.collapsed .nav-icon {
    margin: 0; /* Remove auto margin */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px; /* Fixed width for consistency */
    height: 20px; /* Fixed height for consistency */
    font-size: 0.9rem; /* Optimal size for collapsed state */
    color: rgba(255, 255, 255, 0.9); /* Brighter color when collapsed */
    margin-left: 5px;
}

/* Hide nav-indicator in collapsed state */
.sidebar.collapsed .nav-indicator {
    display: none;
}

/* Proper spacing for nav sections in collapsed state */
.sidebar.collapsed .nav-section {
    margin-bottom: 0.5rem; /* Consistent section spacing */
}

.sidebar.collapsed .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Enhanced hover effect for collapsed sidebar on desktop */
@media (min-width: 1025px) {
    .sidebar.collapsed:hover {
        width: 240px; /* Match the normal sidebar width */
    }
    
    .sidebar.collapsed:hover .nav-text-container,
    .sidebar.collapsed:hover .nav-section-title,
    .sidebar.collapsed:hover .user-info,
    .sidebar.collapsed:hover .sidebar-header .logo-img {
        opacity: 1;
        visibility: visible;
        transition-delay: 0.1s;
    }
    
    .sidebar.collapsed:hover .nav-link {
        justify-content: flex-start;
        padding: 0.7rem 0.8rem;
    }
    
    .sidebar.collapsed:hover .nav-icon {
        margin: 0;
        color: rgba(255, 255, 255, 0.7); /* Return to normal color */
    }
}

/* Mobile sidebar styles - improved behavior */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
        border-radius: 0;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.3);
        z-index: 1200; /* Higher z-index to ensure it appears above other elements */
        transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        position: fixed; /* Ensure fixed positioning */
        top: 0;
        left: 0;
        height: 100%;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    /* When sidebar is open, prevent body scrolling */
    body.sidebar-open {
        overflow: hidden;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1100; /* Below sidebar but above other content */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        backdrop-filter: blur(2px);
        cursor: pointer; /* Add pointer cursor to indicate it's clickable */
    }
    
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    /* Add some animation to improve UX */
    .sidebar-toggle .fas {
        transition: transform 0.3s ease;
    }
    
    .sidebar-toggle.active .fas {
        transform: rotate(-90deg);
    }
}

/* Improved toggle button styling */
.sidebar-toggle {
    cursor: pointer;
    border: none;
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0; /* Remove padding that might interfere with centering */
    margin: 0; /* Reset any margins */
    outline: none; /* Remove outline on focus */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    background: rgba(102, 126, 234, 0.25);
}

.sidebar-toggle.active {
    background: rgba(102, 126, 234, 0.3);
}

/* Smaller mobile optimizations */
@media (max-width: 480px) {
    .sidebar {
        width: 230px;
    }
    
    .nav-link {
        padding: 0.8rem 0.75rem;
    }
    
    .sidebar-header {
        padding: 10px 0;
    }
    
    .logo-img {
        max-height: 40px;
    }
    
    .sidebar-footer {
        padding: 10px;
    }
}

/* Content wrapper styles - smooth transitions */
.content-wrapper {
    margin-left: 260px;
    transition: margin-left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.content-wrapper.expanded {
    margin-left: 70px;
}

@media (max-width: 1024px) {
    .content-wrapper {
        margin-left: 0;
    }
    
    .content-wrapper.expanded {
        margin-left: 0;
    }
}

/* Enhanced logo styling */
.sidebar .logo-container {
    position: relative;
    padding: 5px 10px; /* Reduced padding */
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar .logo-img {
    max-width: 80%; /* Slightly smaller logo */
    max-height: 40px; /* Reduced from 45px */
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.sidebar .logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Compact sidebar footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 0.8rem; /* Reduced padding for compact layout */
    background: rgba(0, 0, 0, 0.15); /* Slightly lighter background */
    margin-top: auto;
    position: relative;
}

/* User profile container - compact layout */
.user-profile-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem; /* Compact gap between profile and actions */
}

/* Compact profile info layout */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem; /* Very tight gap between name and role */
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.sidebar-footer:before {
    content: '';
    position: absolute;
    top: -1px;
    left: 15px;
    right: 15px;
    height: 1px;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        rgba(255, 255, 255, 0) 100%);
}

/* Compact user profile for tablets */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Reduced gap for compact layout */
    padding: 0.25rem 0; /* Reduced padding for compact footer */
}

.user-avatar-sidebar {
    min-width: 32px; /* Smaller avatar */
    width: 32px;
    height: 32px;
    border-radius: 8px; /* Smaller radius */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem; /* Smaller font */
    font-weight: 600;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* Reduced shadow */
    border: 1px solid rgba(255, 255, 255, 0.1); /* Thinner border */
}

.user-name {
    font-size: 0.7rem; /* Further reduced for compact footer */
    font-weight: 600;
    color: white;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.1px; /* Tighter letter spacing */
    line-height: 1.2; /* Tighter line height */
}

.user-role {
    font-size: 0.55rem; /* Further reduced for compact footer */
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1; /* Tighter line height */
}

/* Tablet optimizations for user profile - Compact */
@media (max-width: 1200px) {
    .user-avatar-sidebar {
        min-width: 28px; /* Even smaller for tablets */
        width: 28px;
        height: 28px;
        font-size: 0.7rem; /* Smaller font */
        border-radius: 6px; /* Smaller radius */
    }
    
    .user-name {
        font-size: 0.65rem; /* Compact for tablets */
        line-height: 1.1;
    }
    
    .user-role {
        font-size: 0.5rem; /* Very compact for tablets */
        line-height: 1.0;
    }
    
    .user-actions {
        gap: 0.2rem; /* Very tight gap */
        margin-top: 0.25rem; /* Minimal margin */
    }
    
    .user-action-btn {
        padding: 0.25rem; /* Compact padding */
        font-size: 0.65rem; /* Smaller icons */
        min-height: 22px; /* Compact touch target */
    }
    
    .sidebar-footer {
        padding: 0.3rem 0.6rem; /* Very compact footer */
    }
    
    /* Collapsed sidebar optimizations for tablets */
    .sidebar.collapsed .user-avatar-sidebar {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
    }
    
    .sidebar.collapsed .user-action-btn {
        width: 24px;
        min-height: 18px;
        font-size: 0.55rem;
    }
}

/* Compact action buttons for footer */
.user-actions {
    display: flex;
    gap: 0.3rem; /* Reduced gap for compact layout */
    margin-top: 0.3rem; /* Reduced margin */
}

.user-action-btn {
    flex: 1;
    padding: 0.3rem; /* Reduced padding for compact footer */
    background: rgba(255, 255, 255, 0.08); /* Slightly more subtle */
    border-radius: 6px; /* Smaller radius */
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.7rem; /* Smaller icon size */
    min-height: 24px; /* Minimum touch target */
}

.user-action-btn:hover {
    background: rgba(255, 255, 255, 0.15); /* Subtle hover */
    color: white;
    transform: translateY(-1px); /* Reduced transform */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); /* Smaller shadow */
}

.user-action-btn.logout:hover {
    background: rgba(255, 71, 87, 0.2); /* Reduced opacity */
    color: #ff4757;
    border-color: rgba(255, 71, 87, 0.2);
}

/* Collapsed sidebar footer adjustments - Compact & Optimized */
.sidebar.collapsed .sidebar-footer {
    padding: 0.4rem 0; /* Reduced padding for compact collapsed view */
    text-align: center; /* Center everything in collapsed mode */
}

.sidebar.collapsed .user-profile-container {
    align-items: center; /* Center align in collapsed mode */
    gap: 0.2rem; /* Very tight spacing */
}

.sidebar.collapsed .user-profile {
    flex-direction: column; /* Stack avatar above info */
    align-items: center;
    gap: 0.2rem;
}

.sidebar.collapsed .user-avatar-sidebar {
    margin: 0 auto;
    width: 28px; /* Smaller in collapsed state */
    height: 28px;
    font-size: 0.7rem; /* Smaller font */
    border-radius: 6px; /* Smaller radius */
}

.sidebar.collapsed .user-info {
    display: none; /* Hide user info in collapsed mode to save space */
}

.sidebar.collapsed .user-actions {
    justify-content: center;
    margin-top: 0.3rem; /* Reduced margin */
    gap: 0.15rem; /* Tighter gap in collapsed mode */
    flex-direction: column; /* Stack vertically in collapsed mode */
}

.sidebar.collapsed .user-action-btn {
    padding: 0.25rem; /* Even more compact */
    font-size: 0.6rem; /* Smaller icons */
    min-height: 20px; /* Smaller touch target in collapsed mode */
    width: 28px; /* Fixed width for consistency */
    margin: 0 auto; /* Center the buttons */
}

/* Fixed sidebar header at top */
.sidebar-header {
    padding: 0.4rem 0; /* Further reduced for tablets */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
    text-align: center;
    background: inherit; /* Inherit background from sidebar */
    position: relative;
    z-index: 10;
}

/* Logo optimizations for tablets */
.logo-container {
    padding: 0 0.5rem;
}

.logo-img {
    max-width: 120px; /* Reduced logo size */
    height: auto;
    transition: all 0.3s ease;
}

/* Tablet-specific header and logo optimizations */
@media (max-width: 1200px) {
    .sidebar-header {
        padding: 0.3rem 0; /* Even smaller for tablets */
    }
    
    .logo-img {
        max-width: 100px; /* Smaller logo for tablets */
    }
    
    .sidebar-footer {
        padding: 0.5rem 0.8rem; /* Reduced footer padding */
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    /* Ensure nav sections stay top-aligned on tablets */
    .nav-container {
        padding-top: 0.2rem; /* Start closer to top */
        align-content: flex-start; /* Align content to start */
    }
    
    .nav-section {
        margin-bottom: 0.8rem; /* Tighter spacing on tablets */
    }
    
    /* Tablet-specific nav-link alignment for all items */
    .nav-link {
        padding-left: 0.8rem; /* Consistent left padding for tablets */
        padding-right: 0.6rem; /* Adjusted right padding for tablets */
    }
    
    /* Tablet-specific hover state */
    .nav-item:hover .nav-link {
        padding-left: 0.8rem; /* Maintain consistent padding on hover */
    }
    
    /* Tablet-specific active state alignment */
    .nav-item.active .nav-link {
        transform: translateX(-2px); /* Slightly less movement on tablets */
        padding-left: 0.8rem; /* Adjusted for tablet spacing */
    }
}
