/**
 * Polylang Language Switcher for FSE - Frontend Styles
 * 
 * @package PLL_Switcher_FSE
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

.pll-switcher-fse {
    display: inline-block;
    font-size: inherit;
    line-height: inherit;
}

/* ==========================================================================
   List Styles
   ========================================================================== */

.pll-switcher-fse__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5em;
}

.pll-switcher-fse--vertical .pll-switcher-fse__list {
    flex-direction: column;
    align-items: flex-start;
}

.pll-switcher-fse__item {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
}

.pll-switcher-fse__item a {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s ease;
}

.pll-switcher-fse__item a:hover {
    opacity: 0.8;
}

.pll-switcher-fse__item.current-lang a {
    font-weight: 600;
}

/* ==========================================================================
   Flag Styles
   ========================================================================== */

.pll-switcher-fse__flag {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.pll-switcher-fse__flag img {
    display: block;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Flag Sizes */
.pll-switcher-fse--flag-small .pll-switcher-fse__flag img {
    width: 16px;
}

.pll-switcher-fse--flag-medium .pll-switcher-fse__flag img {
    width: 24px;
}

.pll-switcher-fse--flag-large .pll-switcher-fse__flag img {
    width: 32px;
}

/* ==========================================================================
   Name Styles
   ========================================================================== */

.pll-switcher-fse__name {
    white-space: nowrap;
}

/* ==========================================================================
   Separator Styles
   ========================================================================== */

.pll-switcher-fse__separator {
    opacity: 0.5;
    margin: 0 0.25em;
}

/* ==========================================================================
   Dropdown Styles
   ========================================================================== */

.pll-switcher-fse--dropdown {
    display: inline-block;
}

.pll-switcher-fse--dropdown select,
.pll-switcher-fse select {
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
    color: inherit;
    background-color: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 0.4em 2em 0.4em 0.6em;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='currentColor' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5em center;
    background-size: 10px;
    min-width: 100px;
}

.pll-switcher-fse--dropdown select:hover,
.pll-switcher-fse select:hover {
    border-color: currentColor;
}

.pll-switcher-fse--dropdown select:focus,
.pll-switcher-fse select:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ==========================================================================
   Navigation Block Integration
   ========================================================================== */

/* When inside navigation block */
.wp-block-navigation .pll-switcher-fse {
    display: flex;
    align-items: center;
}

.wp-block-navigation .pll-switcher-fse__list {
    gap: 0.75em;
}

.wp-block-navigation .pll-switcher-fse__item a {
    padding: 0.25em 0;
}

/* Responsive - Mobile Navigation */
.wp-block-navigation__responsive-container.is-menu-open .pll-switcher-fse__list {
    flex-direction: column;
    align-items: flex-start;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.pll-switcher-fse__item a:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.pll-switcher-fse__item a:focus:not(:focus-visible) {
    outline: none;
}

.pll-switcher-fse__item a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Screen reader text */
.pll-switcher-fse .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .pll-switcher-fse__list {
    flex-direction: row-reverse;
}

[dir="rtl"] .pll-switcher-fse--vertical .pll-switcher-fse__list {
    flex-direction: column;
    align-items: flex-end;
}

[dir="rtl"] .pll-switcher-fse--dropdown select,
[dir="rtl"] .pll-switcher-fse select {
    padding: 0.4em 0.6em 0.4em 2em;
    background-position: left 0.5em center;
}

/* ==========================================================================
   Theme Compatibility - Common Patterns
   ========================================================================== */

/* Twenty Twenty-Three */
.wp-block-navigation.has-background .pll-switcher-fse__item a {
    padding: 0.5em;
}

/* Light and dark themes */
.has-text-color .pll-switcher-fse__item a {
    color: inherit;
}

/* Ensure proper stacking in navigation */
.wp-block-navigation-item .pll-switcher-fse {
    width: 100%;
}

/* No translation styling */
.pll-switcher-fse__item.no-translation a {
    opacity: 0.6;
    font-style: italic;
}

/* ==========================================================================
   Classic Menu Styles (Polylang Multilingual)
   ========================================================================== */

.pll-classic-menu {
    display: flex;
    align-items: center;
}

.pll-classic-menu__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5em;
}

.pll-classic-menu__list li {
    position: relative;
    margin: 0;
    padding: 0;
}

.pll-classic-menu__list a {
    text-decoration: none;
    color: inherit;
    padding: 0.5em 0;
    display: block;
}

.pll-classic-menu__list a:hover {
    opacity: 0.8;
}

/* Current menu item */
.pll-classic-menu__list .current-menu-item > a,
.pll-classic-menu__list .current-menu-ancestor > a {
    font-weight: 600;
}

/* Submenu styles */
.pll-classic-menu__list .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    display: none;
    flex-direction: column;
    background: var(--wp--preset--color--base, #fff);
    color: var(--wp--preset--color--contrast, #000);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    padding: 0.5em 0;
    min-width: 180px;
    list-style: none;
    margin: 0;
    z-index: 100;
}

.pll-classic-menu__list li:hover > .sub-menu,
.pll-classic-menu__list li:focus-within > .sub-menu {
    display: flex;
}

.pll-classic-menu__list .sub-menu li {
    width: 100%;
}

.pll-classic-menu__list .sub-menu a {
    padding: 0.5em 1em;
    white-space: nowrap;
}

.pll-classic-menu__list .sub-menu a:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Nested submenus */
.pll-classic-menu__list .sub-menu .sub-menu {
    top: 0;
    left: 100%;
}

/* RTL support */
[dir="rtl"] .pll-classic-menu__list .sub-menu {
    left: auto;
    right: 0;
}

[dir="rtl"] .pll-classic-menu__list .sub-menu .sub-menu {
    left: auto;
    right: 100%;
}

/* Responsive */
@media (max-width: 782px) {
    .pll-classic-menu__list {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
    }

    .pll-classic-menu__list .sub-menu {
        position: static;
        box-shadow: none;
        padding-left: 1em;
        display: flex;
    }
}
