/**
 * Custom CSS for J-Directory Template
 * @package J-Directory
 */

/* === Modification: language-switcher position styling begin === */

/**
 * User menu - float right, appears after the main menu
 */
nav.sp-megamenu-wrapper > .jn-user-menu {
    float: right !important;
    margin-left: 20px !important;
}

/**
 * Language switcher - float right, appears before hamburger icon
 * Increased left margin for more spacing from user menu
 */
nav.sp-megamenu-wrapper > .jn-language-switcher {
    float: right !important;
    margin-right: 20px !important;
    margin-left: 15px !important;
}

/**
 * Ensure modules display inline and align properly
 */
.jn-user-menu .sp-module,
.jn-language-switcher .sp-module {
    margin: 0 !important;
    display: inline-block !important;
    vertical-align: middle !important;
    line-height: normal !important;
}

/**
 * Remove full-height gray background from active language item
 * Apply background only to the flag/link itself
 */
.jn-language-switcher .mod-languages ul.lang-inline li.lang-active,
.jn-language-switcher .mod-languages ul.lang-inline li.lang-active:hover,
.jn-language-switcher .mod-languages ul li.lang-active {
    background-color: transparent !important;
    background: transparent !important;
    padding: 0 !important;
    line-height: 90px !important;
}

/**
 * Add compact background to active language link/flag
 */
.jn-language-switcher .mod-languages ul.lang-inline li.lang-active a,
.jn-language-switcher .mod-languages ul li.lang-active a {
    background-color: #82828280 !important;
    background: #82828280 !important;
    padding: 8px !important;
    border-radius: 3px !important;
    display: inline-block !important;
    line-height: 0 !important;
    vertical-align: middle !important;
}

/**
 * Fix flag image alignment inside the link
 */
.jn-language-switcher .mod-languages ul.lang-inline li.lang-active a img,
.jn-language-switcher .mod-languages ul li.lang-active a img {
    display: block !important;
    margin: 0 !important;
    vertical-align: middle !important;
}

/**
 * Ensure language flags display inline with proper spacing
 */
.jn-language-switcher .mod-languages ul.lang-inline {
    line-height: 90px !important;
}

.jn-language-switcher .mod-languages ul.lang-inline li {
    vertical-align: middle !important;
}

/**
 * Responsive: Stack vertically on mobile devices
 */
@media (max-width: 768px) {
    nav.sp-megamenu-wrapper > .jn-user-menu,
    nav.sp-megamenu-wrapper > .jn-language-switcher {
        float: none !important;
        display: block !important;
        margin: 0 !important;
    }
}

/* === Modification: language-switcher position styling end === */

/* === Modification: Top bar vertical spacing between social icons and contact info begin === */

/**
 * Top bar background color and opacity
 */
#sp-top-bar {
    background-color: #244977 !important;
    opacity: 1 !important;
}

/**
 * Add 30px top margin to contact info to create vertical spacing
 * between social icons line and contact info line
 */
#sp-top1 .sp-contact-info {
    margin-top: 30px;
    display: block;
}

/**
 * Make top1 column stack items vertically
 */
#sp-top1 .sp-column {
    display: block;
}

/**
 * Set 3px bottom padding for top bar
 * to create minimal gap between top bar and header
 */
#sp-top-bar {
    padding-bottom: 3px !important;
}

#sp-top-bar .container-inner {
    padding-bottom: 3px !important;
}

/**
 * Remove margins from modules in top2 (especially paragraph tags)
 */
#sp-top2 .sp-module-content p {
    margin-bottom: 0 !important;
}

#sp-top2 .sp-module {
    margin-bottom: 0 !important;
}

/* === Modification: Top bar vertical spacing between social icons and contact info end === */

/* === Modification: User menu dropdown protection begin === */

/**
 * Solution: Move dropdown DOWN + fill gap with invisible bridge
 * 1. Move dropdown 38px down (like BLOG submenu)
 * 2. Add invisible ::after element to fill the 38px gap
 * 3. This keeps hover active when moving through the gap
 * 4. Add 500ms transition delay as backup protection
 */

/* Move dropdown down by 38px */
.jbd-user-menu .user-menu .dropdown.dropdown-main {
    top: calc(100% + 38px) !important;
}

/* Create invisible bridge in the 38px gap */
.jbd-user-menu .user-menu .has-child::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 38px;
    background: transparent;
    z-index: 98;
    display: none; /* Hidden by default */
}

/* Show bridge when hovering parent */
.jbd-user-menu .user-menu .has-child:hover::after {
    display: block !important;
}

/* Add transition delay for smooth UX */
.jbd-user-menu .user-menu .dropdown {
    display: block !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease 0s, visibility 0s linear 0.5s, pointer-events 0s linear 0.5s !important;
}

/* Show immediately when hovering parent */
.jbd-user-menu .user-menu .has-child:hover > .dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: opacity 0.2s ease 0s, visibility 0s linear 0s, pointer-events 0s linear 0s !important;
}

/* Keep visible when hovering dropdown itself */
.jbd-user-menu .user-menu .dropdown:hover {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: opacity 0.2s ease 0s, visibility 0s linear 0s, pointer-events 0s linear 0s !important;
}

/* Ensure dropdown has higher z-index */
.jbd-user-menu .dropdown {
    z-index: 9999 !important;
}

/* === Modification: User menu dropdown protection end === */
