/**
 * WSA Translate - Frontend Styles
 * Version: 6.6.0
 * 
 * Optimized for performance and compatibility with WordPress themes
 */

/* ================================================================
   CSS VARIABLES
   ================================================================ */

:root {
    --wsa-active-color: #2271b1;
    --wsa-text-color: #ffffff;
    --wsa-hover-color: #135e96;
}

/* ================================================================
   LANGUAGE SWITCHER - BASE STYLES
   ================================================================ */

.wsa-switcher {
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.wsa-switcher * {
    box-sizing: border-box;
}

.wsa-switcher a {
    text-decoration: none !important;
}

.wsa-flag {
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* Flag Images (v6.6.0) */
.wsa-flag-img {
    height: 20px;
    width: auto;
    border-radius: 3px;
    object-fit: cover;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wsa-flag-emoji {
    font-size: 20px;
    line-height: 1;
}

.wsa-name {
    display: inline-block;
    vertical-align: middle;
}

.wsa-arrow {
    font-size: 10px;
    margin-left: 5px;
    transition: transform 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

/* ================================================================
   DROPDOWN STYLE
   ================================================================ */

.wsa-dropdown {
    position: relative;
    display: inline-block;
}

.wsa-dropdown-current {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.wsa-dropdown-current:hover {
    border-color: var(--wsa-active-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wsa-dropdown-current:focus {
    outline: none;
    border-color: var(--wsa-active-color);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.2);
}

.wsa-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    margin-top: 6px;
    padding: 6px 0;
    list-style: none;
    z-index: 99999;
}

.wsa-dropdown.open .wsa-dropdown-list {
    display: block;
    animation: wsaFadeIn 0.2s ease;
}

.wsa-dropdown.open .wsa-arrow {
    transform: rotate(180deg);
}

.wsa-dropdown-list li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wsa-dropdown .wsa-lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #333;
    text-decoration: none !important;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.wsa-dropdown .wsa-lang-item:hover {
    background: var(--wsa-active-color);
    color: var(--wsa-text-color);
}

.wsa-dropdown .wsa-lang-item.active {
    background: var(--wsa-active-color);
    color: var(--wsa-text-color);
    font-weight: 600;
}

.wsa-dropdown .wsa-lang-item.active::after {
    content: "\2713";
    margin-left: auto;
    font-size: 12px;
}

/* ================================================================
   BUTTONS STYLE
   ================================================================ */

.wsa-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.wsa-style-buttons .wsa-lang-item,
.wsa-style-flags_only .wsa-lang-item,
.wsa-style-names_only .wsa-lang-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.wsa-style-buttons .wsa-lang-item:hover,
.wsa-style-flags_only .wsa-lang-item:hover,
.wsa-style-names_only .wsa-lang-item:hover {
    background: var(--wsa-hover-color);
    border-color: var(--wsa-hover-color);
    color: var(--wsa-text-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wsa-style-buttons .wsa-lang-item.active,
.wsa-style-flags_only .wsa-lang-item.active,
.wsa-style-names_only .wsa-lang-item.active {
    background: var(--wsa-active-color);
    border-color: var(--wsa-active-color);
    color: var(--wsa-text-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Flags Only - Smaller padding */
.wsa-style-flags_only .wsa-lang-item {
    padding: 8px 12px;
}

.wsa-style-flags_only .wsa-flag {
    font-size: 22px;
}

/* Names Only - Text style */
.wsa-style-names_only .wsa-lang-item {
    background: transparent;
    border: none;
    padding: 6px 10px;
}

.wsa-style-names_only .wsa-lang-item:hover {
    background: rgba(0, 0, 0, 0.05);
    box-shadow: none;
    transform: none;
    color: var(--wsa-active-color);
}

.wsa-style-names_only .wsa-lang-item.active {
    background: transparent;
    color: var(--wsa-active-color);
    text-decoration: underline !important;
    box-shadow: none;
}

/* ================================================================
   MENU INTEGRATION - IMPROVED FOR THEME COMPATIBILITY
   ================================================================ */

/* WordPress Menu Item */
li.wsa-menu-item {
    position: relative;
    display: flex !important;
    align-items: center;
}

li.wsa-menu-item > .wsa-dropdown,
li.wsa-menu-item > .wsa-buttons {
    margin-left: 10px;
}

/* Fix for various themes */
.wsa-menu-item .wsa-dropdown-current {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
}

.wsa-menu-item .wsa-dropdown-current:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Dark header themes */
.dark-header .wsa-menu-item .wsa-dropdown-current,
.dark-theme .wsa-menu-item .wsa-dropdown-current,
header.dark .wsa-menu-item .wsa-dropdown-current {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Light header themes */
.light-header .wsa-menu-item .wsa-dropdown-current,
.light-theme .wsa-menu-item .wsa-dropdown-current,
header.light .wsa-menu-item .wsa-dropdown-current {
    color: #333;
    border-color: #e0e0e0;
}

/* ================================================================
   CUSTOM MENU STYLES - USER REQUESTED (v6.6.0)
   Stile të customizuara për #menu-menu
   ================================================================ */

/* Image */
#menu-menu .wsa-dropdown-current img {
    width: 20px !important;
    height: 15px !important;
}

/* Wsa flag img */
#menu-menu .menu-item li .wsa-flag-img {
    width: 20px !important;
    height: 15px !important;
}

/* Wsa dropdown current */
#menu-menu .menu-item .wsa-dropdown-current {
    padding-left: 3px;
    padding-right: 3px;
    padding-top: 3px;
    padding-bottom: 3px;
}

/* Additional menu compatibility */
#menu-menu .wsa-menu-item {
    position: relative;
}

#menu-menu .wsa-menu-item .wsa-dropdown {
    position: relative;
}

#menu-menu .wsa-menu-item .wsa-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    min-width: 140px;
}

#menu-menu .wsa-menu-item .wsa-dropdown-current {
    background: transparent;
    border-color: transparent;
    font-size: inherit;
    color: inherit;
}

#menu-menu .wsa-menu-item .wsa-dropdown-current:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: transparent;
}

#menu-menu .wsa-lang-item .wsa-flag-img {
    width: 20px !important;
    height: 15px !important;
    border-radius: 2px;
}

/* Ensure proper display in navigation */
#menu-menu .wsa-switcher {
    display: flex;
    align-items: center;
}

#menu-menu .wsa-dropdown-current .wsa-flag {
    display: flex;
    align-items: center;
}

#menu-menu .wsa-dropdown-current .wsa-name {
    font-size: inherit;
}

/* ================================================================
   FLOATING SWITCHER (SIDEBAR)
   ================================================================ */

.wsa-floating-switcher {
    position: fixed;
    z-index: 999999;
    padding: 10px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.wsa-floating-switcher:hover {
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

/* Positions */
.wsa-pos-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wsa-pos-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wsa-pos-top-right {
    top: 20px;
    right: 20px;
}

.wsa-pos-top-left {
    top: 20px;
    left: 20px;
}

.wsa-pos-middle-right {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding-right: 15px;
}

.wsa-pos-middle-left {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 15px;
}

/* Floating Switcher Content Adjustments */
.wsa-floating-switcher .wsa-dropdown-list {
    bottom: 100%;
    top: auto;
    margin-bottom: 5px;
}

.wsa-pos-top-right .wsa-dropdown-list,
.wsa-pos-top-left .wsa-dropdown-list {
    top: 100%;
    bottom: auto;
    margin-top: 5px;
    margin-bottom: 0;
}

/* ================================================================
   ANIMATIONS
   ================================================================ */

@keyframes wsaFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media screen and (max-width: 768px) {
    .wsa-dropdown-current {
        padding: 8px 12px;
        font-size: 13px;
    }

    .wsa-dropdown-list {
        min-width: 140px;
    }

    .wsa-dropdown .wsa-lang-item {
        padding: 8px 14px;
    }

    .wsa-buttons {
        gap: 6px;
    }

    .wsa-style-buttons .wsa-lang-item,
    .wsa-style-flags_only .wsa-lang-item {
        padding: 6px 10px;
        font-size: 13px;
    }

    .wsa-flag {
        font-size: 18px;
    }
    
    .wsa-floating-switcher {
        padding: 8px;
    }
    
    /* On mobile, keep floating corner position */
    .wsa-pos-bottom-right,
    .wsa-pos-bottom-left {
        bottom: 15px;
    }
    
    /* Mobile menu styles */
    #menu-menu .wsa-menu-item .wsa-dropdown-list {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        bottom: auto;
        top: auto;
    }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */

@media print {
    .wsa-switcher,
    .wsa-floating-switcher {
        display: none !important;
    }
}

/* ================================================================
   ACCESSIBILITY
   ================================================================ */

.wsa-switcher a:focus,
.wsa-switcher button:focus {
    outline: 2px solid var(--wsa-active-color);
    outline-offset: 2px;
}

/* Screen reader text */
.wsa-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ================================================================
   HIGH PERFORMANCE OPTIMIZATIONS
   ================================================================ */

/* Use GPU acceleration for animations */
.wsa-dropdown-list,
.wsa-floating-switcher,
.wsa-lang-item {
    will-change: transform, opacity;
}

/* Reduce layout shifts */
.wsa-switcher,
.wsa-dropdown,
.wsa-buttons {
    contain: layout style;
}

/* Optimize for paint */
.wsa-flag-img {
    content-visibility: auto;
}
