/**
 * Mobile Menu Styles for Elementor Dashboard Widget
 * Responsive hamburger menu for organizer dashboard navigation
 * UPDATED VERSION - Fixes menu not expanding
 */

/* =================================================================
   MOBILE MENU - HORIZONTAL NAV
   ================================================================= */

/* Mobile Toggle Button (Hidden by default) */
.ctod-mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.ctod-mobile-menu-toggle:hover {
    background: #f9f9f9;
    border-color: #0073aa;
}

.ctod-mobile-menu-toggle.active {
    border-radius: 8px 8px 0 0;
    border-bottom-color: transparent;
    margin-bottom: 0;
}

/* Active Page Display in Toggle */
.ctod-active-page {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ctod-active-page .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #0073aa;
}

.ctod-active-page-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ctod-active-page-title {
    font-size: 16px;
    font-weight: 600;
    color: #23282d;
    line-height: 1.2;
}

.ctod-active-page-subtitle {
    font-size: 12px;
    color: #7e8993;
}

/* Hamburger Icon Animation */
.ctod-hamburger {
    width: 24px;
    height: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ctod-hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #23282d;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.ctod-mobile-menu-toggle.active .ctod-hamburger span:nth-child(1) {
    transform: translateY(8.5px) rotate(45deg);
}

.ctod-mobile-menu-toggle.active .ctod-hamburger span:nth-child(2) {
    opacity: 0;
}

.ctod-mobile-menu-toggle.active .ctod-hamburger span:nth-child(3) {
    transform: translateY(-8.5px) rotate(-45deg);
}

/* =================================================================
   MOBILE RESPONSIVE RULES
   ================================================================= */

@media (max-width: 768px) {
    
    /* Show mobile toggle button */
    .ctod-nav-horizontal .ctod-mobile-menu-toggle,
    .ctod-nav-vertical .ctod-mobile-menu-toggle {
        display: flex !important;
    }
    
    /* Hide menu by default on mobile */
    .ctod-nav-horizontal ul,
    .ctod-nav-vertical ul {
        display: none !important;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #fff;
        border: 1px solid #ddd;
        border-top: none;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        max-height: 70vh;
       overflow-y: auto;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Show menu when active - IMPORTANT: Highest specificity */
    .ctod-nav-horizontal.menu-open > ul,
    .ctod-nav-vertical.menu-open > ul {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
		overflow: y;
    }
    
    /* Convert horizontal nav to vertical on mobile */
    .ctod-nav-horizontal {
        position: relative;
    }
    
    .ctod-nav-horizontal ul {
        flex-direction: column;
    }
    
    .ctod-nav-horizontal ul li {
        width: 100%;
        margin: 0;
        display: block !important;
    }
    
    .ctod-nav-horizontal ul li a {
        padding: 15px 20px;
        border-bottom: none !important;
        border-left: 3px solid transparent;
        display: flex !important;
        align-items: center;
        gap: 12px;
    }
    
    .ctod-nav-horizontal ul li a.active {
        border-bottom: none !important;
        border-left-color: #0073aa;
        background: #f9f9f9;
    }
    
    .ctod-nav-horizontal ul li a:hover {
        background: #f5f5f5;
    }
    
    /* Vertical nav adjustments */
    .ctod-nav-vertical {
        width: 100%;
        float: none;
        margin-right: 0;
        position: relative;
    }
    
    .ctod-nav-vertical ul li {
        display: block !important;
    }
    
    .ctod-nav-vertical + .ctod-dashboard-content {
        margin-left: 0;
    }
    
    /* Dropdown doesn't need mobile treatment - it's already mobile-friendly */
    .ctod-nav-dropdown {
        width: 100%;
    }
    
    /* Ensure menu items have proper spacing on mobile */
    .ctod-nav-horizontal ul li:last-child a,
    .ctod-nav-vertical ul li:last-child a {
        border-radius: 0 0 8px 8px;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Optionally adjust horizontal nav for tablets */
    .ctod-nav-horizontal ul li a {
        padding: 15px 18px;
        font-size: 14px;
    }
    
    .ctod-nav-horizontal ul li a .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
}

/* =================================================================
   ANIMATION & TRANSITIONS
   ================================================================= */

/* Smooth menu slide-in animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ctod-nav-horizontal.menu-open ul,
.ctod-nav-vertical.menu-open ul {
    animation: slideDown 0.3s ease-out;
}

/* Loading state for menu items */
.ctod-nav-item.loading a {
    opacity: 0.5;
    pointer-events: none;
}

/* =================================================================
   DEBUG HELPER (Remove after testing)
   ================================================================= */

/* Uncomment these to debug menu visibility issues */
/*
.menu-open {
    border: 3px solid red !important;
}

.ctod-nav-horizontal.menu-open ul,
.ctod-nav-vertical.menu-open ul {
    border: 3px solid green !important;
    background: yellow !important;
}
*/

/* =================================================================
   ACCESSIBILITY IMPROVEMENTS
   ================================================================= */

/* Focus states */
.ctod-mobile-menu-toggle:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.ctod-nav-horizontal ul li a:focus,
.ctod-nav-vertical ul li a:focus {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* Screen reader only text */
.ctod-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* =================================================================
   PRINT STYLES
   ================================================================= */

@media print {
    .ctod-mobile-menu-toggle {
        display: none;
    }
    
    .ctod-nav-horizontal ul,
    .ctod-nav-vertical ul {
        display: none !important;
    }
}