/**
 * Giperplan Language Switcher Fix
 * Mobile standalone language switcher next to burger menu
 * BEM notation
 */

/* Language Accordion - positioned next to burger */
.lang-accordion {
    display: inline-flex;
    align-items: center;
    position: relative;
    z-index: 1000;
    flex-shrink: 0;
}

@media (max-width: 1260px) {
    .lang-accordion {
        display: inline-block;
        vertical-align: middle;
        align-self: center;
        margin-right: 12px;
        width: auto;
    }
    
    /* Hide original switcher in mobile menu */
    .wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu {
        display: none !important;
    }
}

/* Desktop submenu styling to match mobile dropdown */
.wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu .wp-block-navigation__submenu-container {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 4px;    
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-width: 160px !important;
}

.wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu .wp-block-navigation__submenu-container li {
    margin: 0;
}

.wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu .wp-block-navigation__submenu-container li a {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu .wp-block-navigation__submenu-container li a:hover {
    background-color: #f5f5f5;
}

.wp-block-polylang-navigation-language-switcher.wp-block-navigation-submenu .wp-block-navigation__submenu-container li.current-lang a {
    background-color: #e8e8f8;
    font-weight: 600;
}

/* Accordion Header */
/* Wrapper list item for accordion */
.lang-accordion-item {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
}

.lang-accordion-item--mobile {
    display: inline-block;
}

.lang-accordion__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0px;            
    
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
    min-height: 44px;
    box-sizing: border-box;
}

/* Language code in header */
.lang-accordion__lang-code {
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
}
@media (min-width: 500px) {
    .lang-accordion__lang-code {
        font-size: 18px;
    }
}

/* Accordion Arrow */
.lang-accordion__arrow {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.lang-accordion--open .lang-accordion__arrow {
    transform: rotate(180deg);
}

/* Accordion Content - absolute positioned dropdown */
.lang-accordion__content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    min-width: 130px;
}

@media (max-width: 500px) { 
    .lang-accordion__content {
        left: -32px;
    }
}

.lang-accordion--open .lang-accordion__content {
    max-height: 1000px;
    opacity: 1;
}

/* Accordion List */
.lang-accordion__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lang-accordion__list li {
    margin: 0;
    padding: 0;
    display: block !important;
}

.lang-accordion__list li a {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    padding: 6px 16px !important;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.lang-accordion__list li a .wp-block-navigation-item__label {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

.lang-accordion__list li a:hover {
    background-color: #f5f5f5;
}

.lang-accordion__list li.current-lang a {
    background-color: #e8e8f8;
    font-weight: bold;
}

@media (max-width: 500px) {
    .wp-block-navigation.items-justified-right {
        gap: 10px;
    }
}

.wp-block-polylang-navigation-language-switcher.has-base-background-color {
    background-color: #fff !important;
}

@media (min-width: 1260px) {
    .wp-block-polylang-navigation-language-switcher a {
        cursor: pointer;
        padding: 7px 0;
    }
}

.wp-block-navigation .has-child .wp-block-navigation__submenu-container {
    top: 95%;
}

.wp-block-navigation__responsive-container {
    /* comments in English */
    --lang-accordion-overlay-color: rgba(12, 20, 28, 0.72);
}

.wp-block-navigation__responsive-container.is-menu-open::before,
.wp-block-navigation__responsive-container.is-menu-open::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    background-color: var(--lang-accordion-overlay-color);
    pointer-events: none;
    z-index: 0;
}

.wp-block-navigation__responsive-container.is-menu-open::before {
    top: 0;
    height: env(safe-area-inset-top, 0);
    height: constant(safe-area-inset-top, 0);
}

.wp-block-navigation__responsive-container.is-menu-open::after {
    bottom: 0;
    height: env(safe-area-inset-bottom, 0);
    height: constant(safe-area-inset-bottom, 0);
}

.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
    position: relative;
    z-index: 1;
}

@media (max-width: 1260px) {
    .wp-block-navigation__responsive-container {
        position: fixed;
        inset: 0;
        width: 100vw;
        max-width: 100vw;
        padding: 0;
        margin: 0;
    }

    .wp-block-navigation__responsive-container .wp-block-navigation__responsive-container-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
}

.site-header__link {
    font-size: clamp(1rem, calc(1rem + (((100vw - 350px) / 1px) * 0.015rem)), 1.75rem);
}

.wp-block-polylang-navigation-language-switcher ul .wp-block-navigation-item__label {
    overflow-wrap: break-word;
    font-size: 16px;
    font-weight: 400;
}

.wp-block-polylang-navigation-language-switcher ul .current-lang .wp-block-navigation-item__label {
    font-weight: 700;
}

.wp-block-polylang-navigation-language-switcher {
    display: none !important;
}