/* Mobile Responsive Enhancements for Two-Level Sidebar */

/* Mobile Toggle Button */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 6px;
    left: 8px;
    z-index: 1010;
    background: #1a1a2e;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-sidebar-toggle:hover {
    background: #16213e;
    transform: scale(1.05);
}

.mobile-sidebar-toggle i,
.mobile-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* Mobile Overlay - NO TRANSITIONS */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    /* Removed transition completely */
}

.mobile-overlay.active {
    opacity: 1;
}

/* Desktop: Remove ALL layout-affecting transitions */
@media (min-width: 1024px) {
    /* CRITICAL: Remove all main content transitions */
    body.two-level-sidebar .main-content-wrapper,
    .main-content-wrapper,
    .content-page,
    .topbar-custom {
        transition: none !important;
        animation: none !important;
    }

    /* Remove ALL sidebar transitions */
    .sidebar-two-level-container,
    .sidebar-two-level-container *,
    .primary-sidebar,
    .secondary-sidebar,
    .category-btn,
    .menu-link {
        transition: none !important;
        animation: none !important;
    }

    /* Force stable states */
    .sidebar-two-level-container.collapsed,
    .sidebar-two-level-container.hidden {
        opacity: 1 !important;
        transform: translateX(0) !important;
    }

    /* Override any transform transitions */
    body.two-level-sidebar *[style*="transform"],
    body.two-level-sidebar *[style*="margin"],
    body.two-level-sidebar *[style*="width"] {
        transition: none !important;
    }
}

/* Mobile Responsive Breakpoints */
@media (max-width: 1024px) {
    /* Adjust sidebar for tablet */
    .secondary-sidebar {
        width: 260px;
    }

    body.two-level-sidebar {
        margin-left: 320px; /* 60px + 260px */
    }
}

@media (max-width: 768px) {
    /* NO transitions for mobile - instant response */
    body.two-level-sidebar .main-content-wrapper {
        transition: none !important;
    }

    /* Hide sidebar by default on mobile - NO TRANSITION */
    .sidebar-two-level-container {
        transform: translateX(-100%);
        transition: none !important;
        z-index: 1000;
    }

    /* Remove ALL mobile transitions */
    .sidebar-two-level-container *,
    .mobile-overlay,
    .mobile-sidebar-toggle {
        transition: none !important;
        animation: none !important;
    }

    /* Show toggle button */
    .mobile-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Show sidebar when active */
    .sidebar-two-level-container.mobile-active {
        transform: translateX(0);
    }

    /* Remove body margin on mobile */
    body.two-level-sidebar {
        margin-left: 0;
    }

    /* Show overlay when sidebar is open */
    body.sidebar-mobile-open .mobile-overlay {
        display: block;
    }

    /* Adjust sidebar width for mobile */
    .secondary-sidebar {
        width: 240px;
    }

    /* Ensure topbar doesn't interfere */
    .topbar-custom {
        margin-left: 0 !important;
    }

    /* Content adjustments */
    .content-page {
        margin-left: 0 !important;
    }
}

@media (max-width: 576px) {
    /* Further adjustments for small mobile */
    .sidebar-two-level-container {
        width: 100vw;
    }

    .primary-sidebar {
        width: 56px;
    }

    .secondary-sidebar {
        width: calc(100vw - 56px);
        max-width: 280px;
    }

    .category-btn {
        width: 40px;
        height: 40px;
    }

    .category-btn i,
    .category-btn svg {
        width: 18px;
        height: 18px;
    }

    .category-header h3 {
        font-size: 1rem;
    }

    .menu-link {
        padding: 14px 12px;
        font-size: 0.9rem;
    }

    .menu-link i,
    .menu-link svg {
        width: 16px;
        height: 16px;
        margin-right: 10px;
    }
}

/* Smooth animations */
@media (prefers-reduced-motion: no-preference) {
    .sidebar-two-level-container,
    .category-content,
    .menu-link,
    .category-btn {
        transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .primary-sidebar {
        border-right: 2px solid currentColor;
    }

    .secondary-sidebar {
        border-right: 2px solid currentColor;
    }

    .category-btn.active {
        outline: 2px solid currentColor;
        outline-offset: 2px;
    }
}

/* Dark mode forçado para modo claro */
@media (prefers-color-scheme: dark) {
    .secondary-sidebar {
        background: #ffffff !important;
        color: #212529 !important;
    }

    .category-header h3 {
        color: #212529 !important;
    }

    .menu-link {
        color: #212529 !important;
    }

    .menu-link:hover {
        background-color: rgba(13, 110, 253, 0.1) !important;
    }

    .menu-link.active {
        background-color: rgba(13, 110, 253, 0.2) !important;
    }

    .category-header {
        border-bottom-color: #dee2e6 !important;
    }
}

/* Focus management for accessibility */
.sidebar-two-level-container:focus-within {
    outline: none;
}

.category-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.menu-link:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Print styles */
@media print {
    .sidebar-two-level-container,
    .mobile-sidebar-toggle,
    .mobile-overlay {
        display: none !important;
    }

    body.two-level-sidebar {
        margin-left: 0 !important;
    }
}