/* /css/menu-style.css */

/* --- Global Header & Menu Styles --- */

#masthead {
    position: relative;
    z-index: 1035;
}

.navbar-brand .custom-logo {
    height: 55px;
    width: auto;
    max-width: 200px;
    transition: height 0.3s ease-in-out;
}

header#masthead .navbar.scrolled .navbar-brand .custom-logo {
    height: 45px;
}

/* --- Request a Quote Button Styling (Corrected) --- */
@media (min-width: 992px) {
    /* Add spacing between the menu and the hamburger icon on desktop */
    .navbar-nav.d-lg-flex {
        margin-right: 1.5rem;
    }

    /* Hide all top-level menu items on desktop except for the quote button */
    .navbar-nav.d-lg-flex > li:not(.request-quote-btn) {
        display: none;
    }
}

.navbar .request-quote-btn a {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid #55409b;
    color: #55409b !important;
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    border-radius: 15px;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-decoration: none;
}

.navbar .request-quote-btn a:hover {
    background-color: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

header#masthead .navbar.scrolled .request-quote-btn a {
    background-color: #55409b;
    border-color: #ffffff;
    color: #ffffff !important;
}

header#masthead .navbar.scrolled .request-quote-btn a:hover {
    background-color: #44337a;
    border-color: #ffffff;
}

/* --- Custom Animated Hamburger Icon --- */
.navbar-toggler {
    border: none;
    padding: 0;
    width: 30px; 
    height: 30px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    transition: all 0.3s ease;
}
.navbar-toggler:focus {
    box-shadow: none;
}
.navbar-toggler span {
    display: block;
    height: 4px;
    background-color: #55409b;
    margin: 3px 0;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}
.navbar-toggler span:nth-of-type(1) { width: 100%; }
.navbar-toggler span:nth-of-type(2) { width: 70%; }
.navbar-toggler span:nth-of-type(3) { width: 130%; }

.navbar-toggler:hover span:nth-of-type(1) {
    width: 15px; 
    transform: translateX(-25px) translateY(10px) rotate(-40deg);
    transform-origin: left; 
}
.navbar-toggler:hover span:nth-of-type(2) {
    transform: translateX(-10px);
}
.navbar-toggler:hover span:nth-of-type(3) {
    width: 15px;
    transform: translateX(-25px) translateY(-10px) rotate(40deg);
    transform-origin: left;
}

.navbar-toggler[aria-expanded="true"] span:nth-of-type(1) {
    transform: translateY(8px) rotate(45deg);
}
.navbar-toggler[aria-expanded="true"] span:nth-of-type(2) {
    opacity: 0;
}
.navbar-toggler[aria-expanded="true"] span:nth-of-type(3) {
    transform: translateY(-8px) rotate(-45deg);
}


/* --- Desktop Mega Menu Styles --- */
.navbar-nav .menu-item {
    position: relative;
}

.navbar-nav > li > a {
    color: #55409b !important;
    font-weight: bold;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

header#masthead .navbar.scrolled .navbar-nav > li > a {
    color: #ffffff !important;
}

.navbar-nav > li:not(.has-megamenu) > a:hover {
    background-color: rgba(85, 64, 155, 0.1);
}

/* Mega Menu Dropdown Container - Scoped to Desktop */
.d-lg-flex .has-megamenu .sub-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 800px; /* Increased width */
    background-color: var(--navbar-bg, rgba(255, 255, 255, 0.7));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 1.5rem;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

/* Show on Hover - Scoped to Desktop */
.d-lg-flex .has-megamenu:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(10px);
}

/* Mega Menu Sub-Items */
.has-megamenu .sub-menu .menu-item a {
    display: block; /* The link itself is a block */
    padding: 1rem;
    border-radius: 10px;
    transition: background-color 0.3s ease;
    text-decoration: none;
}

.has-megamenu .sub-menu .menu-item a:hover {
    background-color: rgba(85, 64, 155, 0.1);
}

/* This is the flex container for the icon and text */
.megamenu-item-content {
    display: flex;
    align-items: flex-start; /* Aligns icon to the top of the text block */
    text-align: left;
}

.megamenu-icon {
    flex-shrink: 0;
    margin-right: 1rem;
    color: #55409b;
    margin-top: 0.1em; /* Better vertical alignment */
}

.megamenu-icon svg {
    width: 24px; /* Fixed size for consistency */
    height: 24px;
}

.megamenu-text {
    color: #343a40;
    font-weight: bold;
}

/* =================================================================== */
/* --- UPDATED MEGA MENU DESCRIPTION LOGIC --- */
/* =================================================================== */

/* 1. By default (mobile-first), hide the description. */
.megamenu-description {
    display: none;
    font-size: 0.9rem;
    font-weight: normal;
    color: #000000;
    white-space: normal;
    margin-top: 0.25rem;
}

/* 2. On large screens (992px and up), force it to be visible. */
/* This works regardless of where the JS moves the menu. */
@media (min-width: 992px) {
    .megamenu-description {
        display: block !important;
    }
}


/* --- Offcanvas Slide-out Menu --- */
.offcanvas-backdrop {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    background-color: rgba(0, 0, 0, 0.25);
}
.offcanvas.offcanvas-end {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.offcanvas.offcanvas-end:after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../img/menu-side-bg.png");
    background-size: 70%;
    background-repeat: no-repeat;
    background-position: center right;
    filter: blur(4px);
    opacity: 0.5;
    transform: scale(1);
    z-index: -1;
}
.offcanvas .btn-close {
    transform: scale(1.2);
    filter: invert(28%) sepia(45%) saturate(1451%) hue-rotate(224deg) brightness(93%) contrast(92%);
    transition: transform 0.2s ease;
}
.offcanvas .btn-close:hover {
    transform: scale(1.4);
}
.offcanvas.offcanvas-end {
    width: 30vw;
    min-width: 400px;
}
@media (max-width: 768px) {
    .offcanvas.offcanvas-end {
        width: 80vw;
        min-width: 0;
    }
}

.offcanvas-body .navbar-nav .menu-item {
    margin-bottom: 1rem;
}

.offcanvas-body .navbar-nav .menu-item a {
    font-size: 1.26rem;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    color: #55409b !important;
    text-decoration: none !important;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    position: relative; /* For arrow positioning */
}

.offcanvas-body .navbar-nav .menu-item a:hover {
    background-color: #ffffff;
    transform: translateX(10px);
}

/* Offcanvas "Request a Quote" button style (UPDATED) */
.offcanvas-body .request-quote-btn a {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid #55409b;
    color: #55409b !important;
    font-weight: bold;
    padding: 0.75rem 1.5rem;
    border-radius: 15px;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-decoration: none;
}

.offcanvas-body .request-quote-btn a:hover {
    background-color: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}


/* --- Offcanvas Sub-Menu Styles --- */
.offcanvas .menu-item-has-children > a::after {
    content: '';
    position: absolute;
    right: 1.5rem;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #55409b;
    border-bottom: 2px solid #55409b;
    transform: translateY(-75%) rotate(45deg);
    transition: transform 0.3s ease;
}

.offcanvas .submenu-open > a::after {
    transform: translateY(-50%) rotate(225deg);
}

.offcanvas .sub-menu {
    list-style: none;
    padding-left: 1.5rem; /* Indent sub-items */
    margin-top: 1rem;
    display: none; /* Hide by default */
    flex-direction: column;
    gap: 1rem;
}

.offcanvas .submenu-open .sub-menu {
    display: flex; /* Show when parent is open */
}

.offcanvas .sub-menu .menu-item {
    margin-bottom: 0;
}

.offcanvas .sub-menu .menu-item a {
    font-size: 1rem; /* Smaller font for sub-items */
    font-weight: 400;
    padding: 0.5rem 1rem;
}

/* --- Generic Menu Icon Styles --- */
.menu-icon {
    margin-right: 0.75rem;
    flex-shrink: 0;
    color: inherit;
    font-size: 1.26rem;
    line-height: 1;
}
.menu-icon svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

/* --- Header Background Styling --- */
header#masthead .navbar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background-color 0.5s ease-in-out;
}
header#masthead .navbar.scrolled {
    background-color: inherit;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* --- Account Menu Button Styles (Updated Method) --- */

/* General styling for the new menu item link */
.account-menu-btn > a {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Space between icon and text */
    overflow: hidden; /* Prevents text from pushing layout on transition */
}

/* Add the icon using a ::before pseudo-element */
.account-menu-btn > a::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background-color: #55409b; /* Your theme's primary purple color */
}

/* Target the text part of the account link */
.account-menu-btn .account-text {
    font-weight: bold;
    white-space: nowrap;
    transition: max-width 0.4s ease-out, opacity 0.3s ease-in-out;
}

/* On desktop (screens >= 992px), hide the text by default */
@media (min-width: 992px) {
    /* We need to re-wrap the text in a span for this to work */
    .d-lg-flex .account-menu-btn .account-text {
        max-width: 0;
        opacity: 0;
    }

    /* On hover, reveal the text */
    .d-lg-flex .account-menu-btn:hover .account-text {
        max-width: 100px; /* Adjust as needed */
        opacity: 1;
    }
}

/* In the offcanvas menu, ensure the text is always visible */
.offcanvas .account-menu-btn .account-text {
    max-width: 100px; /* Ensure it has space to be visible */
    opacity: 1;
}
