/* ========================================
   ServiceNow-Style Mobile Menu
   Pure CSS implementation with smooth animations
   ======================================== */

/* Mobile Menu - Only visible on mobile/tablet */
.mobile-menu-overlay,
.mobile-menu-drawer {
    display: none;
}

@media (max-width: 1024px) {
    /* Overlay - Semi-transparent background */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Main Drawer - Left sliding panel */
    .mobile-menu-drawer {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 400px;
        height: 100%;
        background: #ffffff;
        z-index: 9999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
    }

    .mobile-menu-drawer.active {
        transform: translateX(0);
    }

    /* Menu Header */
    .mobile-menu-header {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
        min-height: 60px;
    }

    .mobile-menu-close {
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        color: #374151;
        border-radius: 6px;
        transition: background-color 0.2s ease;
    }

    .mobile-menu-close:hover {
        background-color: #f3f4f6;
    }

    .mobile-menu-close:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
    }

    /* Menu Container - Houses all panels */
    .mobile-menu-container {
        flex: 1;
        overflow: hidden;
        position: relative;
    }

    /* Menu Panels - Main and submenus */
    .mobile-menu-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #ffffff;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        padding: 1rem 0;
    }

    .mobile-menu-panel.active {
        transform: translateX(0);
    }

    /* Back button container */
    .mobile-menu-back {
        display: flex;
        align-items: center;
        padding: 0 1rem 1rem 1rem;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 1rem;
    }

    .mobile-menu-back-btn {
        background: none;
        border: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 0;
        color: #3b82f6;
        font-size: 1rem;
        font-weight: 500;
        cursor: pointer;
        transition: color 0.2s ease;
    }

    .mobile-menu-back-btn:hover {
        color: #1d4ed8;
    }

    .mobile-menu-back-btn:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
        border-radius: 4px;
    }

    .mobile-menu-panel-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: #111827;
        margin-left: auto;
        margin-right: 1rem;
    }

    /* Menu Lists */
    .mobile-menu-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .mobile-menu-item {
        border-bottom: 1px solid #f3f4f6;
    }

    .mobile-menu-item:last-child {
        border-bottom: none;
    }

    /* Menu Links and Buttons */
    .mobile-menu-link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 1rem 1.5rem;
        color: #111827;
        font-size: 1rem;
        font-weight: 500;
        text-decoration: none;
        background: none;
        border: none;
        cursor: pointer;
        transition: background-color 0.2s ease, color 0.2s ease;
        text-align: left;
    }

    .mobile-menu-link:hover {
        background-color: #f9fafb;
        color: #3b82f6;
    }

    .mobile-menu-link:focus {
        outline: 2px solid #3b82f6;
        outline-offset: -2px;
        background-color: #eff6ff;
    }

    /* Arrow icons for submenu items */
    .mobile-menu-arrow {
        color: #9ca3af;
        display: flex;
        align-items: center;
        transition: color 0.2s ease;
    }

    .mobile-menu-link:hover .mobile-menu-arrow {
        color: #3b82f6;
    }

    /* Action buttons at bottom */
    .mobile-menu-actions {
        padding: 1.5rem;
        border-top: 1px solid #e5e7eb;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin-top: auto;
    }

    .mobile-menu-btn {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 600;
        text-align: center;
        text-decoration: none;
        transition: all 0.2s ease;
        border: 1px solid transparent;
    }

    .mobile-menu-btn-primary {
        background-color: #3b82f6;
        color: #ffffff;
        border-color: #3b82f6;
    }

    .mobile-menu-btn-primary:hover {
        background-color: #1d4ed8;
        border-color: #1d4ed8;
    }

    .mobile-menu-btn-secondary {
        background-color: transparent;
        color: #374151;
        border-color: #d1d5db;
    }

    .mobile-menu-btn-secondary:hover {
        background-color: #f9fafb;
        border-color: #9ca3af;
    }

    .mobile-menu-btn:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
    }

    /* Hide mobile menu button on desktop */
    .mobile-menu-btn:not(.mobile-menu-close) {
        display: flex;
        align-items: end;
        width: auto;
    }
}

/* Ensure body scroll is disabled when menu is open */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Additional styles for smooth panel transitions */
@media (max-width: 1024px) {
    /* Ensure smooth transitions for all panels */
    .mobile-menu-panel {
        will-change: transform;
    }

    /* Focus styles for better accessibility */
    .mobile-menu-panel:focus-within {
        outline: none;
    }

    /* Ensure proper stacking of panels */
    .mobile-menu-panel.active {
        z-index: 1;
    }

    .mobile-menu-panel:not(.active) {
        z-index: 0;
    }

    /* Smooth scrolling for long menus */
    .mobile-menu-panel {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .mobile-menu-panel::-webkit-scrollbar {
        display: none;
    }
}

/* Dark theme support (if needed) */
@media (prefers-color-scheme: dark) {
    @media (max-width: 1024px) {
        .mobile-menu-drawer {
            background: #1f2937;
        }

        .mobile-menu-header {
            border-bottom-color: #374151;
        }

        .mobile-menu-close {
            color: #d1d5db;
        }

        .mobile-menu-close:hover {
            background-color: #374151;
        }

        .mobile-menu-panel {
            background: #1f2937;
        }

        .mobile-menu-back {
            border-bottom-color: #374151;
        }

        .mobile-menu-panel-title {
            color: #f9fafb;
        }

        .mobile-menu-item {
            border-bottom-color: #374151;
        }

        .mobile-menu-link {
            color: #f9fafb;
        }

        .mobile-menu-link:hover {
            background-color: #374151;
        }

        .mobile-menu-actions {
            border-top-color: #374151;
        }

        .mobile-menu-btn-secondary {
            color: #d1d5db;
            border-color: #4b5563;
        }

        .mobile-menu-btn-secondary:hover {
            background-color: #374151;
            border-color: #6b7280;
        }
    }
}