﻿/* NavItem.razor.css */

/* Make nav container the positioning context */
nav, .navbar, .nav-container {
    position: relative;
}

/* Reset menu-item positioning */
.menu-item {
    position: static !important;
    overflow: visible;
}

/* Main menu button */
.menu-button {
    background: none;
    border: none;
    font-size: 1rem;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.1rem;
    padding: 0.2rem 0.4rem;
}

/* Chevron icon */
.icon-chevron {
    transition: transform 0.15s ease;
}

    .icon-chevron.rotated {
        transform: rotate(180deg);
    }

/* Mega-menu: aligned to the right edge of nav */
.mega-menu {
    height: auto !important;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    width: 50vw;
    height: 50vh;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    overflow-y: auto; /* <-- ADDED for scrolling */
    max-height: calc(100vh - 150px); /* <-- ADDED to prevent full screen overflow */
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateY(-4px);
    transform-origin: top right;
    pointer-events: none;
    z-index: 2000;
}


    /* Reveal on open */
    .mega-menu.pointer-events-auto {
        opacity: 1;
        transform: translateY(0px); /* remove extra push on reveal */
        pointer-events: auto;
    }


    /* Layout columns: links + preview */
    .mega-menu .menu-section {
        flex: 3;
        padding: 0.5rem;
        overflow-y: visible !important;
    }

    .mega-menu .preview-column {
        flex: 1.5;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        /* Preview image */
        .mega-menu .preview-column img {
            max-width: 100%;
            max-height: 100%;
            object-fit: cover;
            border-radius: 2px;
        }

    /* Submenu header */
    .mega-menu .menu-section h3 {
        margin: 0 0 0.5rem;
        font-size: 1rem;
        font-weight: 600;
        color: #222;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Submenu items */
    .mega-menu .menu-section > ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

        .mega-menu .menu-section > ul li a {
            display: block;
            padding: 0.3rem 0.6rem;
            color: #333;
            text-decoration: none;
            font-size: 0.9rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: background 0.15s ease, color 0.15s ease;
            border-radius: 2px;
        }

        .mega-menu .menu-section > ul li + li a {
            border-top: 1px solid #e1e1e1;
            padding-top: 0.3rem;
        }

        .mega-menu .menu-section > ul li a:hover,
        .mega-menu .menu-section > ul li a:focus {
            background: rgba(0, 71, 171, 0.06);
            color: #0047ab;
        }

/* Responsive: full width, auto height on mobile */
@media (max-width: 768px) {
    .menu-item {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .menu-button {
        justify-content: center;
    }

    .mega-menu {

        position: static !important;
        width: 100%;
        height: auto;
        top: 100%;
        transform: none;
        flex-direction: row;
        box-shadow: none;
    }

  

    .mega-menu.pointer-events-auto {
        transform: translateY(0); /* prevent extra push */
    }
        .mega-menu .menu-section {
            flex: 1;
            padding: 0.5rem;
            overflow-y: visible !important;
        }

        .mega-menu .preview-column {
            flex: 2;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0.5rem;
        }
}

.mega-menu .preview-column img {
    max-width: 100%;
    max-height: 300px; /* You can adjust this as needed */
    object-fit: cover;
    border-radius: 2px;
}

.lock-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@media (min-width: 1024px) {
    .mega-menu {
        top: calc(100% - 10px); /* reduce gap below parent button */
        margin-right: 20px; /* add margin to the right edge */
    }
}

@media (max-width: 768px) {
    .mega-menu:not(.pointer-events-auto) {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .mega-menu.is-hidden {
        display: none !important;
    }
}