/**
 * Language Switcher Styles
 * WPML-compatible classes for theme compatibility
 */

/* Base styles */
.lf-language-switcher {
    position: relative;
    display: inline-block;
}

/* Dropdown style */
.lf-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lf-dropdown > ul > li {
    position: relative;
}

.lf-dropdown .lf-current-lang,
.lf-dropdown .wpml-ls-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

/* Chevron on the dropdown chip so the switcher is recognisable as a
 * clickable menu even when the admin hides both flags and names. */
.lf-dropdown .lf-dropdown-caret {
    font-size: 0.7em;
    opacity: 0.7;
    margin-left: 2px;
}
/* Minimum readable width for the chip when it only shows a language
 * code — prevents the "empty green rectangle" look the tester saw. */
.lf-dropdown .lf-lang-code {
    font-weight: 600;
    letter-spacing: 0.04em;
    min-width: 1.5em;
    text-align: center;
}

.lf-dropdown .lf-lang-dropdown,
.lf-dropdown .wpml-ls-sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 150px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lf-dropdown > ul > li:hover .lf-lang-dropdown,
.lf-dropdown > ul > li:hover .wpml-ls-sub-menu,
.lf-dropdown.open .lf-lang-dropdown,
.lf-dropdown.open .wpml-ls-sub-menu {
    display: block;
}

.lf-dropdown .lf-lang-dropdown li,
.lf-dropdown .wpml-ls-sub-menu li {
    margin: 0;
}

/* Dropdown menu items have their own colour context — the chip sits
 * inside the theme's header (usually white/light text on a dark bar)
 * but the menu that drops down has a white background and needs dark
 * text regardless of what the theme styles anchors to. Extra
 * .lf-language-switcher in the selector + !important lifts specificity
 * above themes that paint `.header-lang a { color: #fff }`. */
.lf-language-switcher.lf-dropdown .lf-lang-dropdown a,
.lf-language-switcher.lf-dropdown .wpml-ls-sub-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    text-decoration: none !important;
    color: #333 !important;
    background: transparent;
    transition: background 0.2s;
}

.lf-language-switcher.lf-dropdown .lf-lang-dropdown a:hover,
.lf-language-switcher.lf-dropdown .wpml-ls-sub-menu a:hover {
    background: #f5f5f5 !important;
    color: #111 !important;
}

/* List style */
.lf-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.lf-list li {
    margin: 0;
}

.lf-list a {
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    color: inherit;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background 0.2s;
}

.lf-list a:hover {
    background: rgba(0,0,0,0.05);
}

.lf-list .wpml-ls-current-language a {
    font-weight: bold;
}

/* Flags style */
.lf-flags {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lf-flag-link {
    display: inline-block;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lf-flag-link:hover,
.lf-flag-link.wpml-ls-current-language {
    opacity: 1;
}

/* Flag images */
.wpml-ls-flag {
    width: 18px;
    height: 12px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
}

/* WPML compatibility classes */
.wpml-ls-statics-shortcode_actions {
    display: inline-block;
}

.wpml-ls-legacy-dropdown {
    position: relative;
}

.wpml-ls-legacy-list-horizontal {
    display: flex;
    flex-wrap: wrap;
}

.wpml-ls-native {
    white-space: nowrap;
}

/* Admin bar integration */
#wpadminbar .lf-language-switcher img {
    width: 16px;
    height: 11px;
    vertical-align: middle;
    margin-right: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .lf-dropdown .lf-lang-dropdown,
    .lf-dropdown .wpml-ls-sub-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
    }
}
