/* Advanced SaaS Mega Menu Styles */
.am-5c5ac961-nav {
    position: relative;
    width: 100%;
    z-index: 999;
    font-family: inherit;
}

.am-5c5ac961-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
    align-items: center;
}

.am-5c5ac961-item {
    position: relative;
}

.am-5c5ac961-item-header {
    display: flex;
    align-items: center;
    border-radius: 999px;
    transition: background-color 0.3s ease;
}

.am-5c5ac961-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    font-size: 15px;
    transition: color 0.3s ease, transform 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background-color: transparent;
    border-radius: 999px; /* keep roundedness for hover effects if they apply to link only */
}

/* Base states if unset */
.am-5c5ac961-link:hover,
.am-5c5ac961-item.active .am-5c5ac961-link {
    color: #111827;
}

/* Hover Animations - applies to the link specifically */
.am-hover-anim-underline .am-5c5ac961-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s ease;
}
.am-hover-anim-underline .am-5c5ac961-link:hover::after,
.am-hover-anim-underline .am-5c5ac961-item.active .am-5c5ac961-link::after {
    transform: scaleX(1);
}

.am-hover-anim-bg-shift .am-5c5ac961-item-header {
    position: relative;
    overflow: hidden;
}
.am-hover-anim-bg-shift .am-5c5ac961-item-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    z-index: -1;
    transform: translateY(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-radius: 999px;
}
.am-hover-anim-bg-shift .am-5c5ac961-item-header:hover::before,
.am-hover-anim-bg-shift .am-5c5ac961-item.active .am-5c5ac961-item-header::before {
    transform: translateY(0);
    opacity: 0.1;
}

.am-hover-anim-scale .am-5c5ac961-item-header:hover,
.am-hover-anim-scale .am-5c5ac961-item.active .am-5c5ac961-item-header {
    transform: scale(1.05);
}

.am-5c5ac961-caret-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    border-radius: 50%;
    margin-right: 4px;
    transition: background-color 0.2s ease;
}

/* Only show the separate button behavior clearly on mobile, but keep it structured for desktop */
@media (min-width: 1025px) {
    .am-5c5ac961-caret-btn {
        pointer-events: none; /* Let desktop hover handle it, button isn't clickable */
        padding: 0 8px 0 0; /* Adjust spacing to look like it's part of the link */
        margin-right: 8px;
    }
    .am-5c5ac961-item-header {
        cursor: pointer; /* Desktop hover over the whole header */
    }
}

.am-5c5ac961-caret {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
}

.am-5c5ac961-item:hover .am-5c5ac961-caret,
.am-5c5ac961-item.active .am-5c5ac961-caret {
    transform: rotate(180deg);
}

.am-5c5ac961-badge {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Dropdown Wrapper */
.am-5c5ac961-dropdown-wrapper {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding-top: 16px; 
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1000;
}

.am-5c5ac961-dropdown {
    background-color: #ffffff; /* This can now be safely overridden by the new dropdown_bg_color control */
    border-radius: 20px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    transform: translateY(10px) scale(0.98);
    transform-origin: top center;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden; 
}

.am-5c5ac961-dropdown-inner {
    padding: 24px;
    width: 100%;
}

/* Hover & Active States */
.am-5c5ac961-item:hover .am-5c5ac961-dropdown-wrapper,
.am-5c5ac961-item:focus-within .am-5c5ac961-dropdown-wrapper,
.am-5c5ac961-item.active .am-5c5ac961-dropdown-wrapper {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.am-5c5ac961-item:hover .am-5c5ac961-dropdown,
.am-5c5ac961-item:focus-within .am-5c5ac961-dropdown,
.am-5c5ac961-item.active .am-5c5ac961-dropdown {
    transform: translateY(0) scale(1);
}

/* Custom Submenu Styles */
.am-5c5ac961-custom-menu {
    display: flex;
    gap: 16px; /* Can be overridden by widget controls */
}

/* Stacked Layout (Vertically layered) */
.am-5c5ac961-custom-menu.layout-stacked {
    flex-direction: column; 
    width: 100%;
}

/* Inline Layout (Horizontally side-by-side) */
.am-5c5ac961-custom-menu.layout-inline {
    flex-direction: row;
    flex-wrap: wrap;
}

.am-5c5ac961-sub-item {
    display: flex;
    gap: 16px;
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Alignment for Stacked */
.am-5c5ac961-custom-menu.layout-stacked .am-5c5ac961-sub-item {
    width: 100%;
    align-items: flex-start;
}

/* Alignment for Inline */
.am-5c5ac961-custom-menu.layout-inline .am-5c5ac961-sub-item {
    flex: 1 1 calc(50% - 16px); 
    min-width: 250px;
    align-items: center; 
}


.am-5c5ac961-sub-item:hover {
    background-color: #f9fafb;
}

.am-5c5ac961-sub-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f3f4f6;
    border-radius: 8px;
    color: #4b5563;
    font-size: 20px;
    flex-shrink: 0;
}
.am-5c5ac961-sub-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.am-5c5ac961-sub-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.am-5c5ac961-custom-menu.layout-inline .am-5c5ac961-sub-content {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.am-5c5ac961-sub-title {
    color: #111827;
    font-weight: 600;
    font-size: 14px;
}

.am-5c5ac961-sub-desc {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.4;
}

/* Mobile Toggle */
.am-5c5ac961-mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    align-items: center;
    justify-content: center;
}

.am-5c5ac961-burger {
    display: block;
    width: 20px;
    height: 2px;
    background: #111827;
    position: relative;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.am-5c5ac961-burger::before,
.am-5c5ac961-burger::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: inherit;
    left: 0;
    border-radius: 2px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), top 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease;
}

.am-5c5ac961-burger::before { top: -6px; }
.am-5c5ac961-burger::after { top: 6px; }

.am-5c5ac961-nav.is-mobile-open .am-5c5ac961-burger { background: transparent !important; }
.am-5c5ac961-nav.is-mobile-open .am-5c5ac961-burger::before { top: 0; transform: rotate(45deg); }
.am-5c5ac961-nav.is-mobile-open .am-5c5ac961-burger::after { top: 0; transform: rotate(-45deg); }


/* Mobile Styles */
@media (max-width: 1024px) {
    .am-5c5ac961-mobile-toggle {
        display: flex;
    }
    
    .am-5c5ac961-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #ffffff;
        padding: 16px;
        box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        border-radius: 16px;
        margin-top: 10px;
        gap: 4px;
        z-index: 1001; /* Ensure mobile menu layers nicely */
        box-sizing: border-box;
    }
    
    .am-5c5ac961-menu.is-open {
        display: flex;
        animation: slideDownMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .am-5c5ac961-item {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .am-5c5ac961-item-header {
        width: 100%;
        justify-content: space-between;
        padding: 4px;
        border-radius: 12px;
    }

    .am-5c5ac961-item-header:hover {
        background-color: #f3f4f6; /* slight grey highlight on mobile when interacting */
    }
    
    .am-5c5ac961-link {
        flex-grow: 1;
        padding: 12px;
        border-radius: 8px;
    }

    .am-5c5ac961-caret-btn {
        padding: 12px; /* Bigger touch target on mobile */
        pointer-events: auto; /* Re-enable clicking the button directly on mobile */
    }

    .am-5c5ac961-caret-btn:hover, .am-5c5ac961-caret-btn:focus {
        background-color: #e5e7eb;
    }
    
    .am-5c5ac961-dropdown-wrapper {
        position: static;
        transform: none;
        padding: 0;
        display: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        width: 100%;
        box-sizing: border-box;
        /* Will be overridden by the mobile alignment control via flex */
    }
    
    .am-5c5ac961-item.active .am-5c5ac961-dropdown-wrapper {
        display: flex; /* Changed from block so alignment controls can apply */
    }
    
    .am-5c5ac961-dropdown {
        min-width: auto !important;
        width: 100% !important; 
        max-width: 100%;
        transform: none; /* Will be overridden by offset control */
        box-shadow: none;
        border: none;
        background: #f9fafb;
        border-radius: 12px;
        margin-top: 8px;
        box-sizing: border-box;
    }
    
    .am-5c5ac961-dropdown-inner {
        padding: 16px;
        box-sizing: border-box;
    }

    .am-5c5ac961-custom-menu {
        flex-direction: column !important; /* Stack on mobile */
        width: 100%;
    }

    .am-5c5ac961-custom-menu.layout-inline .am-5c5ac961-sub-item,
    .am-5c5ac961-custom-menu.layout-stacked .am-5c5ac961-sub-item {
        width: 100%;
        box-sizing: border-box;
    }

    .am-5c5ac961-custom-menu.layout-inline .am-5c5ac961-sub-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

@keyframes slideDownMobile {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}