/**
 * Advanced Mega Menu - Cameranu Style (Exact Match)
 * Sidebar categories on left, multi-column content on right, brands at bottom
 */


/* Advanced Mega Menu Container */


/* More specific selector to override base-navigation.css position: absolute */

.primary-menu>.menu-item.has-advanced-mega-menu>.advanced-mega-menu-wrapper,
.has-advanced-mega-menu>.advanced-mega-menu-wrapper {
    position: fixed !important;

    /* Top position will be set dynamically by JavaScript to navRect.bottom */

    /* Default top: 0 will be overridden by JavaScript inline styles */
    top: 0;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
    background: var(--hafo-color-snow);
    border-top: 0.5px solid var(--hafo-color-cool-grey);
    border-bottom: 0.5px solid var(--hafo-color-cool-grey);
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 0;
    box-shadow: 0 4px 40px rgb(39 80 136 / 8%);
    z-index: var(--mega-menu-z-index);
    display: none !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}


/* Show mega menu when data-visible="true" (controlled by JavaScript) */

.primary-menu>.menu-item.has-advanced-mega-menu>.advanced-mega-menu-wrapper[data-mega-menu="true"][data-visible="true"],
.has-advanced-mega-menu>.advanced-mega-menu-wrapper[data-mega-menu="true"][data-visible="true"],
.advanced-mega-menu-wrapper[data-mega-menu="true"][data-visible="true"] {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}


/* Legacy hover support (fallback) */

.primary-menu>.menu-item.has-advanced-mega-menu:hover>.advanced-mega-menu-wrapper,
.primary-menu>.menu-item.has-advanced-mega-menu.menu-open>.advanced-mega-menu-wrapper,
.has-advanced-mega-menu:hover>.advanced-mega-menu-wrapper,
.has-advanced-mega-menu.menu-open>.advanced-mega-menu-wrapper {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}


/* Mega Menu Inner Container - Two Column Layout */


/* Utilizes full available width of the mega menu wrapper */

.mega-menu-inner {
    display: flex;
    gap: 24px;
    min-height: 400px;

    /* Remove max-width constraint to utilize full available width */
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;

    /* Align left edge with header-wrapper content area (where first menu item starts) */

    /* On screens <= 1440px: 20px padding matches header-wrapper */

    /* On screens > 1440px: calculates offset to match centered header-wrapper left edge */
    padding: 0 max(20px, calc((100vw - 1440px) / 2 + 00px));

    /* Ensure content area expands to fill available space */
    box-sizing: border-box;
    align-items: start;
}


/* Left Sidebar - Main Categories */

.mega-menu-sidebar {
    width: 255px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #d2d6df;
    padding-bottom: 70px;
}

.sidebar-menu {
    margin: 0;
    display: flex !important;
    flex-direction: column;
    width: 100%;
    gap: .75rem;
    padding: 2rem 1rem;
}

.sidebar-menu>.menu-item {
    margin: 0;
    padding: 0;
    width: 100% !important;
    display: block !important;
    float: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
}

.sidebar-menu .menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 8px;
    height: 32px;
    color: var(--hafo-color-black);
    text-decoration: none;
    font-size: 16px;

    /* font-weight: 400; */
    font-family: var(--hafo-font-family);
    line-height: 32px;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-menu .menu-item.active>.menu-link {
    background-color: var(--hafo-color-primary-50);
    color: var(--hafo-color-brand);
    text-decoration: underline;
}

.sidebar-menu .menu-item:hover>.menu-link:not(.active) {
    background-color: transparent;
    color: var(--hafo-color-black);
}

.sidebar-arrow {
    display: inline-flex;
    margin-left: auto;
    font-size: 14px;
    color: currentcolor;
    text-align: right;
}

.sidebar-menu .menu-item.active .sidebar-arrow {
    opacity: 1;
}


/* Right Content Area - Multi-column layout */

.mega-menu-content {
    flex: 1 1 auto;
    min-width: 0;

    /* Allow flex item to shrink below content size */
    padding: 0 8px;
    position: relative;
    min-height: 400px;

    /* Ensure content expands to fill available space */
    width: 100%;
    max-width: none;
    overflow: visible;
}

.content-panel {
    display: none;
    animation: fade-in 0.3s ease;
}

.content-panel.active,
.content-panel:not([hidden]) {
    display: block;
}

.content-panel[hidden] {
    display: none !important;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Content Columns Grid - Dynamic Layout */


/* Each header group is its own column */

/* Grid layout: 5 columns minimum, wraps to 2 rows */

.content-columns {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 2rem;
    padding: var(--hafo-spacing-4);
    align-items: start;
    align-content: start;
    padding-bottom: 10px;
    width: auto;
    max-width: 100%;
    height: auto;
    grid-auto-rows: auto;
    grid-auto-flow: row;
    box-sizing: border-box;
}

/* Each menu item with children = 1x1 grid cell */
.content-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: max-content;
    width: auto;
    height: auto;
    overflow: visible;
    grid-column: span 1;
    grid-row: span 1;
    box-sizing: border-box;
    padding: 2rem;
}

.column-header-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
}

.column-header-group:not(:last-child) {
    margin-bottom: 0;
}

.column-header {
    font-size: 16px;
    font-weight: 400;
    font-family: var(--hafo-font-family);
    color: var(--hafo-color-brand);
    margin: 0;
    padding: 0;
    line-height: 32px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.column-menu {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-weight: 300 !important;
    font-family: var(--hafo-font-family);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
}

.column-menu .menu-item {
    margin: 0;
    padding: 0;
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
}

.column-menu .menu-item.has-children {
    margin-bottom: 0;
}

.column-menu .menu-item.menu-item-child {
    margin-left: 0;
    margin-bottom: 0;
}

.column-menu .menu-link {
    display: block;
    padding: 0;
    color: var(--hafo-color-black);
    text-decoration: none;
    transition: color 0.2s;
    line-height: 1rem;
    font-size: 1rem;
    font-weight: 300;
    font-family: var(--hafo-font-family);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.column-menu .menu-item-child>.menu-link {
    color: var(--hafo-color-black);
    padding-left: 0;
    position: relative;
}

.column-menu .menu-item-child>.menu-link::before {
    display: none;
}

.column-menu .menu-link.view-all-link {
    color: var(--hafo-color-brand);
    text-decoration: underline;
}

.column-menu .menu-link:hover {
    color: var(--hafo-color-brand);
    padding-left: 0;
    text-decoration: underline;
}


/* Show More/Less functionality */

.column-show-more-wrapper {
    margin: 0;
    padding: 0;
    border: 0;
    min-height: 1.2rem;
}

.column-show-more {
    display: block;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    font: inherit;
    line-height: inherit;
    appearance: none;
    min-inline-size: 11ch;
    white-space: nowrap;
}

.column-hidden-item[hidden] {
    display: none !important;
}

.column-menu .menu-item-child>.menu-link:hover {
    padding-left: 24px;
}


/* Category arrow indicator for items with children */

.category-arrow {
    display: inline-block;
    margin-left: 6px;
    color: var(--hafo-color-neutral-400);
    font-size: 12px;
    transition: transform 0.2s, color 0.2s;
}

.column-menu .menu-link:hover .category-arrow {
    color: var(--hafo-color-brand) !important;
}


/* Nested children container */

.category-children {
    margin-top: 6px;
    margin-left: 0;
    padding-left: 0;
}

.column-menu .menu-item-child .category-children {
    border-left-color: var(--hafo-color-neutral-300);
    margin-left: 8px;
    padding-left: 8px;
}

.no-items {
    color: var(--hafo-color-neutral-400);
    font-style: italic;
    margin: 0;
}

/* Featured page rows for empty submenu states */
.mega-menu-featured-cards {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: var(--hafo-spacing-4);
    align-items: start;
    width: 100%;
}

.content-columns + .mega-menu-featured-cards {
    padding-top: 0;
}

.mega-menu-featured-cards.is-single {
    width: 100%;
}

.mega-menu-featured-card {
    min-width: 0;
}

.mega-menu-featured-card__link {
    color: inherit;
    display: flex;
    align-items: stretch;
    gap: 1.25rem;
    padding: 1rem 0;
    min-height: 180px;
    border-bottom: 1px solid #e3e8f0;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.mega-menu-featured-card:last-child .mega-menu-featured-card__link {
    border-bottom: 0;
}

.mega-menu-featured-card__link:hover,
.mega-menu-featured-card__link:focus {
    background-color: #f8fbff;
}

.mega-menu-featured-card__media {
    flex: 0 0 280px;
    background: #eff3f8;
    display: block;
    overflow: hidden;
    width: 280px;
    border-radius: 6px;
    border: 1px solid #dbe3ef;
}

.mega-menu-featured-card__image {
    display: block;
    height: 100%;
    object-fit: scale-down;
    object-position: center;
    width: 100%;
}

.mega-menu-featured-card__placeholder {
    background: linear-gradient(135deg, #ecf3fa 0%, #d8e3f1 100%);
    display: block;
    height: 100%;
    width: 100%;
}

.mega-menu-featured-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: center;
    min-width: 0;
    padding: 0.25rem 0;
}

.mega-menu-featured-card__title {
    color: var(--hafo-color-black);
    font-family: var(--hafo-font-family);
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.35;
}

.mega-menu-featured-card__description {
    color: #586174;
    font-family: var(--hafo-font-family);
    font-size: 0.9375rem;
    font-weight: 300;
    line-height: 1.45;
    max-width: 44ch;
}

.mega-menu-featured-card__cta {
    align-self: flex-start;
    background: var(--hafo-color-brand);
    border: 1px solid var(--hafo-color-brand);
    border-radius: 999px;
    color: var(--hafo-color-brand-white);
    font-family: var(--hafo-font-family);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    margin-top: 0.5rem;
    padding: 0.375rem 0.875rem;
    text-decoration: none;
}


/* Brand Logos Section */


/* Aligns with inner container - matches mega-menu-inner padding */

.mega-menu-brands {
    padding: 30px max(20px, calc((100vw - 1440px) / 2 + 20px));
    border-top: 1px solid var(--hafo-color-neutral-200);
    background: #fafafa;

    /* Match mega-menu-inner width and padding for alignment */
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.brands-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--hafo-color-neutral-500);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 20px;
}

.brand-logos {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    background: #fff;
    border: 1px solid var(--hafo-color-neutral-200);
    border-radius: 8px;
    transition: border-color 0.2s, transform 0.2s;
    text-decoration: none;
    min-height: 50px;
}

.brand-logo:hover {
    border-color: #6b46c1;
    transform: translateY(-2px);
}

.brand-logo img {
    max-width: 100%;
    height: auto;
    max-height: 40px;
    object-fit: contain;
    filter: grayscale(100%);
    transition: filter 0.2s;
}

.brand-logo:hover img {
    filter: grayscale(0%);
}

.brand-text {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
}


/* Elementor Editor Mode - Mega menu behavior removed to prevent forced opening */


/* Responsive */

@media (width <=1400px) {
    .content-columns {
        /* Maintain 5 columns but reduce gap */
        grid-template-columns: repeat(5, auto);
        gap: 2rem;
    }
}

@media (width <=1200px) {
    .content-columns {
        /* Reduce to 4 columns on smaller screens */
        grid-template-columns: repeat(4, auto);
        gap: 2rem;
    }
}

@media (width <=992px) {
    .content-columns {
        /* Reduce to 3 columns on tablet */
        grid-template-columns: repeat(3, auto);
        gap: 2rem;
    }

    .mega-menu-featured-cards {
        width: 100%;
    }

    .mega-menu-featured-card__link {
        min-height: 0;
    }

    .mega-menu-featured-card__media {
        flex-basis: 220px;
        width: 220px;
    }
}


/* Hide desktop mega menu on mobile */

@media (width <=1023px) {
    .has-advanced-mega-menu>.advanced-mega-menu-wrapper:not(.mobile-mega-menu) {
        display: none !important;

        /* Use mobile menu instead */
    }
}


/* Hide mobile mega menu on desktop */

@media (width >=1024px) {
    .advanced-mega-menu-wrapper.mobile-mega-menu {
        display: none !important;
    }
}
