/* =========================================
   1. BASE STYLES & RESETS
========================================= */
.ce-menu-wrapper {
    position: relative;
    width: 100%;
}

.ce-menu-wrapper ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ce-menu-wrapper a {
    text-decoration: none;
    display: block;
    padding: 12px 15px;
    transition: color 0.3s ease, background 0.3s ease;
}

.ce-menu-wrapper .menu-item {
    position: relative;
}

/* =========================================
   2. DESKTOP STYLES (Min-width: 992px)
========================================= */
@media (min-width: 992px) {
    /* Hide Mobile UI Elements */
    .ce-menu-toggle,
    .ce-submenu-btn {
        display: none !important;
    }

    /* Horizontal Layout */
    .ce-menu {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px; /* Spacing between main menu items */
    }

    /* Desktop Dropdown Arrow Indicator */
    .ce-menu > .menu-item-has-children > a {
        padding-right: 25px;
    }
    .ce-menu .menu-item-has-children > a::after {
        content: '';
        border: solid currentColor;
        border-width: 0 2px 2px 0;
        display: inline-block;
        padding: 2.5px;
        transform: rotate(45deg);
        position: absolute;
        right: 10px;
        top: 50%;
        margin-top: -4px;
        transition: transform 0.3s ease;
    }

    /* Sub-dropdown Arrow (Points Right) */
    .ce-menu .sub-menu .menu-item-has-children > a::after {
        transform: rotate(-45deg);
        right: 15px;
    }

    /* Dropdown Container Styling */
    .ce-menu .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 220px;
        background: #ffffff;
        box-shadow: 0 8px 25px rgba(0,0,0,0.08);
        border: 1px solid #f0f0f0;
        border-radius: 4px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(15px);
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        z-index: 999;
    }

    /* Nested Dropdowns (3rd level +) */
    .ce-menu .sub-menu .sub-menu {
        top: 0;
        left: 100%;
        margin-left: 2px;
    }

    /* Show Dropdown on Hover */
    .ce-menu .menu-item-has-children:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    /* Flip Arrow on Hover */
    .ce-menu > .menu-item-has-children:hover > a::after {
        transform: rotate(-135deg);
        margin-top: -1px;
    }
}

/* =========================================
   3. MOBILE & TABLET STYLES (Max-width: 991px)
========================================= */
@media (max-width: 991px) {
    
    /* Hamburger Button */
    .ce-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 6px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 10px;
        width: 45px;
        height: 45px;
        margin-left: auto; /* Pushes hamburger to the right */
    }
    
    .ce-menu-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: #333; /* Default color */
        border-radius: 3px;
        transition: all 0.3s ease-in-out;
    }

    /* Hamburger Animation to 'X' */
    .ce-menu-toggle.is-active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    .ce-menu-toggle.is-active span:nth-child(2) {
        opacity: 0;
    }
    .ce-menu-toggle.is-active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    /* Mobile Menu Wrapper */
    .ce-menu-container {
        display: none;
        width: 100%;
        background: #ffffff;
        position: absolute;
        left: 0;
        top: calc(100% + 10px);
        z-index: 999;
        box-shadow: 0 10px 20px rgba(0,0,0,0.08);
        border: 1px solid #f0f0f0;
        border-radius: 4px;
        overflow: hidden;
    }

    /* Fade In Animation for Mobile Menu */
    .ce-menu-container.is-active {
        display: block;
        animation: ce-fade-in 0.3s ease forwards;
    }
    
    @keyframes ce-fade-in {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Mobile Menu Items List */
    .ce-menu {
        display: flex;
        flex-direction: column;
    }

    .ce-menu li {
        border-bottom: 1px solid #f5f5f5;
        width: 100%;
    }
    .ce-menu li:last-child {
        border-bottom: none;
    }

    /* Mobile Submenu Styling */
    .ce-menu .sub-menu {
        display: none;
        background: #fcfcfc;
        border-top: 1px solid #f5f5f5;
    }

    /* Mobile Submenu Indentation (Multi-level) */
    .ce-menu .sub-menu a { padding-left: 30px; }
    .ce-menu .sub-menu .sub-menu a { padding-left: 45px; }
    .ce-menu .sub-menu .sub-menu .sub-menu a { padding-left: 60px; }

    /* Show Submenu when Toggled */
    .ce-menu .menu-item-has-children.submenu-open > .sub-menu {
        display: block;
    }

    /* JS Mobile Submenu Button (The '▼') */
    .ce-submenu-btn {
        background: rgba(0,0,0,0.02);
        border: none;
        border-left: 1px solid #f0f0f0;
        position: absolute;
        right: 0;
        top: 0;
        width: 48px;     /* Large touch target for accessibility */
        height: 44px;    /* Matches typical link height */
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 12px;
        z-index: 10;
        transition: transform 0.3s ease, background 0.3s ease;
    }

    .ce-submenu-btn:hover {
        background: rgba(0,0,0,0.05);
    }

    /* Rotate arrow when mobile submenu is open */
    .ce-menu .menu-item-has-children.submenu-open > .ce-submenu-btn {
        transform: rotate(180deg);
        background: rgba(0,0,0,0.05);
    }
}