/*
Menu CSS based on Live Site's Styles, consolidated and cleaned.
Includes Base (Mobile), Larger Mobile, and Desktop styles for the menu.
*/

/* --- BASE (MOBILE) SIZE - Applies by default, overridden by media queries --- */

/* MAIN MENU TOGGLE (Hamburger Button) */
.menu-toggle {
    display: block; /* Visible by default on mobile */
    padding: 10px;
    margin: 20px 0 0;
    background: #0150B7; /* PassMaster Blue */
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 20px;
}
.menu-toggle.toggled-on {
    background: #0150B7; /* Stays same background when toggled on */
}

/* MAIN NAVIGATION (.srt-menu) for Mobile */
.srt-menu {
    display: none; /* Hidden by default on mobile */
}
.srt-menu.toggled-on {
    display: block; /* Becomes visible when 'toggled-on' class is added by JS */
    position: relative; /* Important for stacking context */
    z-index: 10;
}

.srt-menu { /* General menu styling, acts as base for mobile */
    clear: both;
    margin-bottom: 60px; /* Space below the menu */
}
.srt-menu li a { /* General link styles for main menu items on mobile */
    color: #333333;
    background: #F8F8F8;
    display: block;
    margin: 1px 0;
    padding: 10px;
    text-decoration: none;
    font-size: .9em;
}
.srt-menu li a:hover { /* Hover state for mobile links */
    background: #0150B7;
    color: #fff;
}
.srt-menu li li a { /* First sub-level links (traditional dropdown) */
    background: #F8F8F8;
    color: #333333;
    padding-left: 40px;
}
.srt-menu li li li a { /* Second sub-level links */
    background: #F8F8F8;
    color: #333333;
    padding-left: 80px;
}


/* --- LARGER MOBILE DEVICES (@media min-width: 481px) --- */
@media only screen and (min-width: 481px) {
    .menu-toggle { /* Adjust toggle positioning for larger mobile */
        margin-top: 10px; /* Adjust margin */
        float: right; /* Float to the right */
    }
}

/* --- TABLET & SMALLER LAPTOPS / DESKTOP (@media min-width: 1000px) --- */
@media only screen and (min-width: 1000px) { /* BREAKPOINT CHANGED TO 1000PX */

    /* --- FLEXBOX FOR RIGHT-ALIGNMENT --- */
    /* This rule will only apply if the wrapping div in your HTML has align="right" */
    div[align="right"] {
        display: flex;
        justify-content: flex-end; /* Pushes content to the far right */
        align-items: flex-start; /* Aligns content to the top */
        width: auto;
    }

    /*** MAIN MENU - ESSENTIAL DESKTOP STYLES ***/
    .menu-toggle {
        display: none; /* Hide hamburger button on desktop */
    }
    #menu-main-navigation {
        display: block; /* Ensures it's NOT flex on desktop, allowing child LIs to float */
        width: auto; /* Allows content to determine width, or flex parent to size */
        text-align: left; /* Keeps text aligned left within the nav */
        background-color: transparent; /* Changed to transparent */
    }

    /* Adjustment for #topnav to work with flex parent or general layout */
    #topnav {
        float: none; /* Clear any floats that might conflict with flexbox or modern layout */
        width: auto; /* Ensure it takes width based on content/flex */
        margin-left: 0;
        margin-right: 0;
    }

    /* Reset basic menu list styles for desktop */
    .srt-menu, .srt-menu * {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    /* Main navigation items container for desktop */
    .srt-menu {
        display: inline-block; /* Allows width to shrink to content, compatible with floated LIs */
        float: none; /* Remove float from the main menu UL to work with flex parent */
        margin: .35em 0 0 0; /* Adjust top margin for vertical alignment */
    }

    /* Main Menu List Item (LI) Styling for Desktop */
    .srt-menu li {
        float: left; /* Keeps main menu items horizontal */
        position: relative; /* For absolute positioning of dropdowns (critical for mega menu) */
        margin-left: 1px; /* Small gap between main menu items */
        height: 42px; /* Set height for main nav items (prioritising 42px from your first 920px block) */
    }
    .srt-menu li li { /* Nested LI items (in dropdowns) */
        width: 100%; /* Take full width of parent ul */
        margin-left: 0px; /* Remove margin for nested items */
        height: auto; /* Auto height for dropdown items */
    }

    /* Link (A) Styling for Desktop - Main Level - ADJUSTED SELECTOR */
    .srt-menu li a {
        display: block;
        position: relative;
        text-decoration: none;
        background: transparent;
        margin: 0;
        padding: 10px 20px;
        height: 42px;
        line-height: 22px;
        color: #333333; /* Main menu item text is a dark grey */
        transition: all 0.3s ease;
    }

    /* Hover and Current State for Desktop Main Menu */
    .srt-menu li:hover > a,
    .srt-menu li.current a {
        color: #ffffff;
        background: #0150B7; /* PassMaster Blue background for hover/active */
    }

    /* Traditional Dropdown (Sub-menu) Styling for Desktop */
    .srt-menu ul {
        position: absolute;
        width: 12em;
        left: 0; /* Align with parent li */
        top: 42px; /* Position below parent li */
        z-index: 99;
        box-shadow: 2px 3px 2px 0px rgba(0, 0, 0, .3);
        background: #F8F8F8; /* Light grey background for the dropdown container */
        transition: opacity 0.5s ease, visibility 0.5s ease;
        opacity: 0;
        visibility: hidden;
    }
    /* Show dropdown on hover */
    .srt-menu li:hover > ul,
    .srt-menu li.sfHover ul {
        opacity: 1; /* Fade in */
        visibility: visible; /* Become visible */
    }

    /* Traditional Dropdown (Sub-menu) Link Styling for Desktop */
    .srt-menu li ul li a {
        color: #333333 !important; /* Force a dark text colour for contrast */
        padding-left: 20px;
        background: #F8F8F8 !important; /* Force a light grey background */
        text-align: left;
        line-height: normal;
        height: auto;
        padding-top: 8px;
        padding-bottom: 8px;
        transition: background 0.2s ease, color 0.2s ease;
    }
    .srt-menu li ul li a:hover {
        background: #0150B7 !important; /* Force a blue background on hover */
        color: #fff !important; /* Force white text on hover */
    }

    /* Multi-level Traditional Dropdown Positioning for Desktop */
    ul.srt-menu li:hover li ul,
    ul.srt-menu li.sfHover li ul {
        top: -999em; /* Hide deeper levels by default */
    }
    ul.srt-menu li li:hover ul,
    ul.srt-menu li li.sfHover ul {
        left: 12em; /* Position next level to the right of parent */
        top: 0;
    }
    ul.srt-menu li li:hover li ul,
    ul.srt-menu li li.sfHover li ul {
        top: -999em;
    }
    ul.srt-menu li li li:hover ul,
    ul.srt-menu li li li.sfHover li ul {
        left: 10em;
        top: 0;
    }

    /* Mega Menu Specific Styles - UPDATED BLOCK */
    .has-mega-menu {
        position: relative;
    }

    .mega-menu-content {
        display: none;
        position: fixed;
        left: 20px;
        right: 20px;
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
        padding: 20px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        z-index: 100;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        background: #F8F8F8;
        color: #333333;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.5s ease, visibility 0.5s ease;
    }

    /* Show Mega Menu on hover of parent li */
    .has-mega-menu:hover .mega-menu-content {
        display: flex;
        opacity: 1;
        visibility: visible;
    }

    /* Mega Menu Column - Explicit Properties */
    .mega-menu-column {
        width: auto !important;
        float: none;
        display: block;
        flex: 1;
        min-width: 200px;
        padding: 0 15px;
        border-right: 1px solid #333333;
    }

    .mega-menu-column:last-child {
        border-right: none;
    }

    .mega-menu-column h3 {
        color: #0150B7;
        font-size: 0.9em;
        margin-top: 0;
        margin-bottom: 10px;
        border-bottom: 1px solid #0150B7;
        padding-bottom: 5px;
    }

    .mega-menu-column ul {
        list-style: none;
        padding: 0;
        margin: 0;
        position: static;
    }

    /* Ensure the ul within mega menu columns is visible when mega menu is active */
    .has-mega-menu:hover .mega-menu-content .mega-menu-column ul {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .mega-menu-column ul li a {
        color: #333333;
        padding: 5px 0;
        background: transparent !important;
        display: block;
        text-decoration: none;
        transition: color 0.2s ease;
        height: auto;
        line-height: normal;
    }

    .mega-menu-column ul li a:hover {
        color: #ffffff;
        background: #0150B7 !important;
    }

    /* NEW: Rule to handle focus/active states for mega menu links */
    .mega-menu-column ul li a:focus,
    .mega-menu-column ul li a:active {
        background: #0150B7;
        color: #ffffff;
    }

    /* Adjustments for potential conflicts with existing traditional dropdown rules */
    /* Ensure traditional dropdowns don't interfere with mega menu visibility */
    .srt-menu li:not(.has-mega-menu):hover > ul {
        display: block;
    }
}