/**
 * Mega Menu & Mobile Drawer Navigation
 * Breakpoint: 992px (mega menu desktop / drawer mobile)
 * Brand: deep blue #044D84, white accents
 */

:root {
    --nav-deep-blue: #044D84;
    --nav-deep-blue-hover: #0672C4;
    --nav-white: #fff;
    --nav-divider: rgba(255, 255, 255, 0.2);
    --mega-bg: #F8F8F8;
    --mega-heading: #3F3844;
    --mega-text: #3F3844;
    --mega-link: #044D84;
    --mega-featured-bg: #E8E8E8;
    --drawer-overlay: rgba(0, 0, 0, 0.4);
    --drawer-width: 85%;
    --drawer-max-width: 360px;
}

/* ----- Desktop: Nav bar (full width, centered content) ----- */
.desktop-nav {
    background-color: var(--nav-deep-blue);
    height: 40px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 80px;
    z-index: 200;
}

.desktop-nav .nav-container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Override global ul/li so nav doesn’t get extra padding/margin */
.desktop-nav .menu,
.desktop-nav ul.menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    flex-wrap: nowrap;
    gap: 0;
}

.desktop-nav .menu > li {
    margin: 0;
    margin-bottom: 0;
    padding: 0 0.75rem;
    color: var(--nav-white);
    position: static; /* mega panel uses fixed positioning for full width */
    flex-shrink: 0;
}

.desktop-nav .menu > li:last-child {
    padding-right: 0;
}

.desktop-nav .menu > li:not(.nav-cta) > a,
.desktop-nav .menu > li .mega-trigger {
    color: var(--nav-white);
    font-family: "Roboto", sans-serif;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    height: 40px;
    cursor: pointer;
    background: none;
    border: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: background-color 0.2s ease, border-bottom-color 0.2s ease;
}

/* Hover state for main menu items */
.desktop-nav .menu > li:not(.nav-cta) > a:hover,
.desktop-nav .menu > li .mega-trigger:hover {
    color: var(--nav-white);
    background-color: rgba(255, 255, 255, 0.12);
    border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* Active state when mega menu is open */
.desktop-nav .menu > li.has-mega.is-open .mega-trigger {
    color: var(--nav-white);
    background-color: rgba(255, 255, 255, 0.18);
    border-bottom-color: var(--nav-white);
    font-weight: 600;
}

.desktop-nav .dropdown-arrow {
    width: 10px;
    height: 10px;
    transition: transform 0.2s ease;
}

.desktop-nav .menu > li.has-mega.is-open .dropdown-arrow {
    transform: rotate(180deg);
}

/* ----- Mega Menu Panel (max 1024px wide, centered below nav) ----- */
.mega-menu-wrapper {
    position: fixed;
    top: 120px; /* 80px header + 40px nav */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1024px;
    z-index: 1001;
    background: var(--mega-bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: none;
    min-height: 200px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Force dark text in mega panel – override global .menu li a { color: #fff } */
.desktop-nav .mega-menu-wrapper,
.desktop-nav .mega-menu-wrapper * {
    color: #3F3844;
}
.desktop-nav .menu li .mega-menu-wrapper a,
.mega-menu-wrapper .mega-menu-col a,
.mega-menu-wrapper .mega-featured-card,
.mega-menu-wrapper .mega-featured-card-link {
    color: #3F3844 !important;
}
.desktop-nav .menu li .mega-menu-wrapper a:hover,
.mega-menu-wrapper .mega-menu-col a:hover,
.mega-menu-wrapper .mega-featured-card:hover .mega-featured-card-link {
    color: #044D84 !important;
}
.mega-menu-wrapper .mega-menu-col h3 {
    color: #044D84 !important;
}
.mega-menu-wrapper .mega-menu-featured h3,
.mega-menu-wrapper .mega-featured-card-title {
    color: #3F3844 !important;
}
.mega-menu-wrapper .mega-featured-card-desc {
    color: #3F3844 !important;
}
.mega-menu-wrapper .mega-featured-card-link {
    color: #044D84 !important;
}
.mega-menu-wrapper .mega-menu-close {
    color: #3F3844 !important;
}
.mega-menu-wrapper .mega-menu-close:hover {
    color: #044D84 !important;
}

.mega-menu-wrapper.is-open {
    display: block;
}

.mega-menu-panel {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    padding: 24px 32px 32px;
    box-sizing: border-box;
}

.mega-menu-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 16px;
}

.mega-menu-close {
    background: none;
    border: none;
    color: var(--mega-heading);
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-family: "Roboto", sans-serif;
}

.mega-menu-close:hover {
    color: var(--nav-deep-blue);
}

.mega-menu-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 32px;
    padding: 0 0 24px;
    border-bottom: 1px solid #ddd;
    min-width: 0;
}

.mega-menu-columns--two {
    grid-template-columns: 1fr 1fr;
}

.mega-menu-columns--one {
    grid-template-columns: 1fr;
}

.mega-menu-columns--getintouch {
    grid-template-columns: 1fr;
    border-bottom: none;
    padding-bottom: 0;
}

/* Vertical separator between columns (2- or 3-column layouts) */
.mega-menu-columns .mega-menu-col:not(:last-child) {
    border-right: 1px solid #d0d0d0;
    padding-right: 24px;
}

.mega-menu-col {
    min-width: 0;
}

.mega-menu-col h3 {
    font-family: "Roboto", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #044D84;
    margin: 0 0 12px 0;
}

.mega-menu-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-col ul li {
    margin: 0 0 8px 0;
}

.mega-menu-col a {
    color: #3F3844 !important;
    text-decoration: none;
    font-size: 15px;
    font-family: "Roboto", sans-serif;
    display: block;
    padding: 4px 0;
    word-wrap: break-word;
}

.mega-menu-col a:hover {
    color: #044D84 !important;
    text-decoration: underline;
}

/* Featured / Highlighted Offers section */
.mega-menu-featured {
    padding-top: 24px;
}

.mega-menu-featured h3 {
    font-family: "Roboto", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--mega-heading);
    margin: 0 0 16px 0;
}

.mega-featured-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.mega-featured-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--mega-featured-bg);
    border-radius: 8px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}

.mega-featured-card:hover {
    background: #e0e0e0;
}

.mega-featured-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.mega-featured-card-content {
    flex: 1;
    min-width: 0;
}

.mega-featured-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--mega-heading);
    margin: 0 0 6px 0;
}

.mega-featured-card-desc {
    font-size: 14px;
    color: var(--mega-text);
    line-height: 1.4;
    margin: 0 0 8px 0;
}

.mega-featured-card-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--mega-link);
}

.mega-featured-card-link:hover {
    text-decoration: underline;
}

/* Advisor Login button in nav – compact, stands out */
.desktop-nav .menu > li.nav-cta {
    margin-left: 8px;
    padding-left: 8px;
}

.desktop-nav .menu .nav-cta a {
    height: 28px !important;
    min-height: 28px;
    line-height: 1;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    background-color: #fff;
    color: #044D84;
    border: 1px solid #fff;
    text-decoration: none;
    box-sizing: border-box;
}

.desktop-nav .menu .nav-cta a:hover {
    background-color: #f0f9ff;
    color: #044D84;
    border-color: #fff;
    text-decoration: none;
}

/* ----- Mobile: Hamburger + Drawer ----- */
.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--drawer-overlay);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--drawer-width);
    max-width: var(--drawer-max-width);
    height: 100vh;
    max-height: 100vh;
    background: var(--nav-white);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

.mobile-drawer.is-open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #eee;
    background: var(--nav-deep-blue);
    color: var(--nav-white);
    flex-shrink: 0;
    min-width: 0;
}

.drawer-close {
    background: none;
    border: none;
    color: var(--nav-white);
    padding: 8px;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.drawer-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.drawer-logo img {
    height: 32px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

.drawer-nav {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 0;
}

.drawer-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 100%;
}

.drawer-nav > ul > li {
    border-bottom: 1px solid #eee;
}

.drawer-nav .drawer-item-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    color: var(--mega-heading);
    text-decoration: none;
    font-family: "Roboto", sans-serif;
    font-size: 16px;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.drawer-nav .drawer-item-link:hover {
    background: #f0f9ff;
    color: var(--nav-deep-blue);
}

.drawer-nav .drawer-item-link .drawer-chevron {
    flex-shrink: 0;
    margin-left: 8px;
    transition: transform 0.2s ease;
    color: #666;
}

.drawer-nav .drawer-item.expanded .drawer-chevron {
    transform: rotate(90deg);
}

.drawer-sub {
    display: none;
    background: #f8f8f8;
    padding: 8px 0 8px 16px;
}

.drawer-sub.is-open {
    display: block;
}

.drawer-sub a {
    display: block;
    padding: 10px 16px;
    color: var(--mega-text);
    text-decoration: none;
    overflow-wrap: break-word;
    word-wrap: break-word;
    font-size: 15px;
    font-family: "Roboto", sans-serif;
}

.drawer-sub a:hover {
    color: var(--nav-deep-blue);
}

.drawer-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: var(--nav-deep-blue);
    font-weight: 500;
    cursor: pointer;
    font-size: 15px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: "Roboto", sans-serif;
}

.drawer-back:hover {
    background: #f0f9ff;
}

.drawer-utilities {
    padding: 20px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.drawer-utility {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--nav-deep-blue);
    text-decoration: none;
    font-size: 14px;
    font-family: "Roboto", sans-serif;
    font-weight: 500;
}

.drawer-utility:hover {
    text-decoration: underline;
}

.drawer-utility svg {
    width: 24px;
    height: 24px;
}

/* Mobile: hamburger button (tap target and visibility) */
.menu-icon {
    cursor: pointer;
    padding: 12px;
    margin: -12px 0 -12px 0;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    -webkit-tap-highlight-color: transparent;
}
.menu-icon img {
    display: block;
    width: 24px;
    height: 24px;
}

/* ----- Responsive: show/hide desktop vs mobile (breakpoint 992px) ----- */
@media (max-width: 991px) {
    .desktop-header-bg {
        display: none !important;
    }

    .mobile-header {
        display: block !important;
        position: relative;
        z-index: 200;
    }

    .desktop-nav,
    .mega-menu-wrapper {
        display: none !important;
    }

    .mobile-drawer-container {
        display: block;
    }
}

@media (min-width: 992px) {
    .desktop-header-bg {
        display: block !important;
    }

    .mobile-header {
        display: none !important;
    }

    .mobile-drawer-container {
        display: none;
    }

    .desktop-nav {
        display: flex;
    }
}
