/**
 * Smart AI Multilingual - Language Switcher Styles
 *
 * @package SmartAIMultilingual
 * @since 1.0.0
 */

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
    --saml-switcher-bg: #ffffff;
    --saml-switcher-border: #ddd;
    --saml-switcher-text: #333;
    --saml-switcher-hover-bg: #f5f5f5;
    --saml-switcher-active-bg: #e9e9e9;
    --saml-switcher-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --saml-switcher-radius: 4px;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
.saml-language-switcher {
    position: relative;
    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;
}

.saml-language-switcher * {
    box-sizing: border-box;
}

.saml-language-switcher a {
    text-decoration: none;
    color: inherit;
}

/* ==========================================================================
   Flag Icons
   ========================================================================== */
.saml-flag {
    display: inline-block;
    width: 24px;
    height: 18px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    vertical-align: middle;
    flex-shrink: 0;
}

/* Flag backgrounds using CSS gradients for basic representation */
.saml-flag-en {
    background: 
        linear-gradient(to bottom, #012169 0%, #012169 100%);
    position: relative;
}

.saml-flag-en::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(45deg, transparent 35%, white 35%, white 40%, transparent 40%),
        linear-gradient(-45deg, transparent 35%, white 35%, white 40%, transparent 40%),
        linear-gradient(45deg, transparent 60%, white 60%, white 65%, transparent 65%),
        linear-gradient(-45deg, transparent 60%, white 60%, white 65%, transparent 65%);
}

.saml-flag-tr {
    background: #e30a17;
    position: relative;
}

.saml-flag-tr::before {
    content: '☪';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
}

.saml-flag-ar {
    background: linear-gradient(to bottom, 
        #000000 0%, #000000 33.33%, 
        #ffffff 33.33%, #ffffff 66.66%, 
        #007a3d 66.66%, #007a3d 100%);
}

.saml-flag-ru {
    background: linear-gradient(to bottom, 
        #ffffff 0%, #ffffff 33.33%, 
        #0039a6 33.33%, #0039a6 66.66%, 
        #d52b1e 66.66%, #d52b1e 100%);
}

/* ==========================================================================
   Dropdown Style
   ========================================================================== */
.saml-switcher-dropdown {
    position: relative;
    min-width: 150px;
}

.saml-switcher-dropdown .current-language {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 35px 10px 12px;
    background: var(--saml-switcher-bg);
    border: 1px solid var(--saml-switcher-border);
    border-radius: var(--saml-switcher-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.saml-switcher-dropdown .current-language:hover {
    border-color: #999;
}

.saml-switcher-dropdown .current-language::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #666;
    transition: transform 0.2s ease;
}

.saml-switcher-dropdown.open .current-language::after {
    transform: translateY(-50%) rotate(180deg);
}

.saml-switcher-dropdown .language-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--saml-switcher-bg);
    border: 1px solid var(--saml-switcher-border);
    border-radius: var(--saml-switcher-radius);
    box-shadow: var(--saml-switcher-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    list-style: none;
    padding: 0;
    margin: 0;
}

.saml-switcher-dropdown.open .language-list {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.saml-switcher-dropdown .language-list li {
    margin: 0;
    padding: 0;
}

.saml-switcher-dropdown .language-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    transition: background-color 0.15s ease;
}

.saml-switcher-dropdown .language-list a:hover {
    background: var(--saml-switcher-hover-bg);
}

.saml-switcher-dropdown .language-list li:first-child a {
    border-radius: var(--saml-switcher-radius) var(--saml-switcher-radius) 0 0;
}

.saml-switcher-dropdown .language-list li:last-child a {
    border-radius: 0 0 var(--saml-switcher-radius) var(--saml-switcher-radius);
}

.saml-switcher-dropdown .language-list .current a {
    background: var(--saml-switcher-active-bg);
    font-weight: 600;
}

/* ==========================================================================
   Horizontal Style
   ========================================================================== */
.saml-switcher-horizontal {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: var(--saml-switcher-bg);
    border: 1px solid var(--saml-switcher-border);
    border-radius: var(--saml-switcher-radius);
    overflow: hidden;
}

.saml-switcher-horizontal .language-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-right: 1px solid var(--saml-switcher-border);
    transition: background-color 0.15s ease;
}

.saml-switcher-horizontal .language-item:last-child {
    border-right: none;
}

.saml-switcher-horizontal .language-item:hover {
    background: var(--saml-switcher-hover-bg);
}

.saml-switcher-horizontal .language-item.current {
    background: var(--saml-switcher-active-bg);
    font-weight: 600;
}

/* ==========================================================================
   Vertical Style
   ========================================================================== */
.saml-switcher-vertical {
    display: inline-flex;
    flex-direction: column;
    background: var(--saml-switcher-bg);
    border: 1px solid var(--saml-switcher-border);
    border-radius: var(--saml-switcher-radius);
    overflow: hidden;
    min-width: 150px;
}

.saml-switcher-vertical .language-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--saml-switcher-border);
    transition: background-color 0.15s ease;
}

.saml-switcher-vertical .language-item:last-child {
    border-bottom: none;
}

.saml-switcher-vertical .language-item:hover {
    background: var(--saml-switcher-hover-bg);
}

.saml-switcher-vertical .language-item.current {
    background: var(--saml-switcher-active-bg);
    font-weight: 600;
}

/* ==========================================================================
   Flags Only Style
   ========================================================================== */
.saml-switcher-flags-only {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.saml-switcher-flags-only .language-item {
    display: block;
    padding: 4px;
    border-radius: var(--saml-switcher-radius);
    transition: all 0.15s ease;
    opacity: 0.7;
}

.saml-switcher-flags-only .language-item:hover {
    opacity: 1;
    transform: scale(1.1);
}

.saml-switcher-flags-only .language-item.current {
    opacity: 1;
    box-shadow: 0 0 0 2px #2271b1;
}

.saml-switcher-flags-only .saml-flag {
    display: block;
    width: 32px;
    height: 24px;
}

/* ==========================================================================
   Language Names
   ========================================================================== */
.saml-language-name {
    white-space: nowrap;
}

.saml-language-native {
    color: #666;
    font-size: 12px;
    margin-left: 4px;
}

/* ==========================================================================
   RTL Support
   ========================================================================== */
[dir="rtl"] .saml-switcher-dropdown .current-language {
    padding: 10px 12px 10px 35px;
}

[dir="rtl"] .saml-switcher-dropdown .current-language::after {
    right: auto;
    left: 12px;
}

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

[dir="rtl"] .saml-switcher-horizontal .language-item {
    border-right: none;
    border-left: 1px solid var(--saml-switcher-border);
}

[dir="rtl"] .saml-switcher-horizontal .language-item:last-child {
    border-left: none;
}

[dir="rtl"] .saml-switcher-flags-only {
    flex-direction: row-reverse;
}

/* ==========================================================================
   Widget Specific Styles
   ========================================================================== */
.widget .saml-language-switcher {
    width: 100%;
}

.widget .saml-switcher-dropdown {
    width: 100%;
}

.widget .saml-switcher-vertical {
    width: 100%;
}

/* ==========================================================================
   Dark Theme Support
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .saml-language-switcher {
        --saml-switcher-bg: #2d2d2d;
        --saml-switcher-border: #444;
        --saml-switcher-text: #e0e0e0;
        --saml-switcher-hover-bg: #3d3d3d;
        --saml-switcher-active-bg: #4d4d4d;
    }
    
    .saml-language-native {
        color: #999;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
.saml-language-switcher a:focus,
.saml-switcher-dropdown .current-language:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.saml-switcher-dropdown .current-language:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Screen reader text */
.saml-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;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes saml-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.saml-switcher-dropdown.open .language-list {
    animation: saml-fade-in 0.2s ease forwards;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .saml-language-switcher {
        display: none;
    }
}

/* ==========================================================================
   Elementor Compatibility
   ========================================================================== */
.elementor-widget-container .saml-language-switcher {
    display: inline-block;
}

.elementor-widget-text-editor .saml-language-switcher {
    margin: 0;
}

/* Header builder compatibility */
.elementor-location-header .saml-language-switcher {
    z-index: 100;
}

/* Menu widget compatibility */
.elementor-nav-menu .saml-language-switcher {
    padding: 0 15px;
}
