/**
 * Sidebar Responsive Styles
 * Mobile and responsive behavior for the sidebar component
 */

/* Mobile Header */
.mobile-header {
    display: none;
    background-color: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

.mobile-menu-toggle {
    padding: 0.5rem;
    border-radius: 0.375rem;
    color: #4b5563;
    transition: background-color 0.15s ease;
}

.mobile-menu-toggle:hover {
    background-color: #f3f4f6;
}

.mobile-menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Sidebar Wrapper */
.sidebar-wrapper {
    position: relative;
    z-index: 40;
}

/* Tablet helper (desktop begins at 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-header { display: block; }
}

/* Desktop (>=1024px) */
@media (min-width: 1024px) {
    .sidebar-wrapper {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        bottom: auto !important;
        width: 280px !important;
        transform: none !important;
        box-shadow: none;
    }
    .app-layout { display: flex; }
    .main-content { flex: 1; min-width: 0; }
}

/* Mobile + Tablet (<=1024px) */
@media (max-width: 1024px) {
    .mobile-header {
        display: block;
    }
    
    .sidebar-wrapper {
        position: fixed;
        top: 64px;
        left: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 40;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        height: calc(100dvh - 64px);
    }
    
    .sidebar-wrapper.mobile-open {
        transform: translateX(0);
    }
    
    .main-content { margin-left: 0; padding: 1rem; }
    
    /* Mobile overlay */
    .sidebar-wrapper.mobile-open::before {
        content: '';
        position: fixed;
        top: -64px;
        left: 280px;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

/* Tablet adjustments removed; covered by off-canvas rules above */

/* Small mobile screens */
@media (max-width: 480px) {
    .sidebar-wrapper {
    width: 100%;
    }
    
    .sidebar-wrapper.mobile-open::before {
        left: 100%;
    }
    
    .sidebar { width: 100%; min-width: 100%; height: calc(100dvh - 64px); }
}

/* Layout utilities */
.app-layout { display:flex; min-height:100vh; width:100%; }

.main-content { flex:1; overflow-x:auto; min-width:0; }

/* Ensure proper stacking */
.sidebar-wrapper {
    z-index: 40;
}

.mobile-header {
    z-index: 50;
}

/* Animation improvements */
.sidebar-wrapper {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-wrapper {
        transition: none;
    }
}

/* Focus trap for mobile sidebar */
.sidebar-wrapper.mobile-open {
    overflow: hidden;
}

.sidebar-wrapper.mobile-open .sidebar {
    overflow-y: auto;
}

/* Backdrop styling */
@media (max-width: 768px) {
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 30;
    }
    
    .sidebar-wrapper.mobile-open ~ .sidebar-backdrop,
    .sidebar-wrapper.mobile-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }
}

/* Print styles */
@media print {
    .sidebar-wrapper,
    .mobile-header {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}
