/**
 * VIME Language Switcher Widget Styles
 */

/* Base Wrapper */
.vime-ls-wrapper {
    position: relative;
    display: inline-block;
}

/* Common Styles */
.vime-ls-text {
    display: inline-block;
}

.vime-ls-flag {
    display: inline-block;
    vertical-align: middle;
    object-fit: cover;
}

.vime-ls-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.rtl .vime-ls-icon {
    margin-right: 0;
    margin-left: 8px;
}

/* Select Layout */
.vime-ls-select {
    display: inline-block;
    width: auto;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
}

.rtl .vime-ls-select {
    background-position: left 10px center;
    padding-right: 15px;
    padding-left: 40px;
}

.vime-ls-select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Dropdown Layout */
.vime-ls-wrapper.vime-ls-dropdown .vime-ls-dropdown,
ul.vime-ls-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 9999;
    min-width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    max-height: 300px;
    overflow-y: auto;
}

.rtl .vime-ls-dropdown {
    left: auto;
    right: 0;
}

/* Dropdown Current Button */
.vime-ls-current {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: transparent;
    border: 1px solid #ddd;
    padding: 8px 16px;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.vime-ls-current:hover {
    border-color: #999;
}

.vime-ls-current:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.vime-ls-arrow {
    display: inline-flex;
    transition: transform 0.3s ease;
}

/* Dropdown States */
.vime-ls-dropdown.is-open,
.vime-ls-current[aria-expanded="true"] + .vime-ls-dropdown,
.vime-ls-wrapper.vime-ls-dropdown .vime-ls-dropdown.is-open {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

.vime-ls-current[aria-expanded="true"] .vime-ls-arrow {
    transform: rotate(180deg);
}

/* Hover Trigger */
.vime-ls-hover:hover + .vime-ls-dropdown,
.vime-ls-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Animations */
.vime-ls-dropdown[data-animation="fade"] {
    transition: opacity 300ms ease, visibility 300ms ease;
}

.vime-ls-dropdown[data-animation="slide"] {
    transition: opacity 300ms ease, visibility 300ms ease, transform 300ms ease;
}

.vime-ls-dropdown[data-animation="none"] {
    transition: none;
}

/* Dropdown Items */
.vime-ls-item {
    margin: 0;
    padding: 0;
    position: relative;
}

.vime-ls-dropdown .vime-ls-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.vime-ls-dropdown .vime-ls-item:first-child a {
    border-radius: 3px 3px 0 0;
}

.vime-ls-dropdown .vime-ls-item:last-child a {
    border-radius: 0 0 3px 3px;
}

.vime-ls-dropdown .vime-ls-item a:hover {
    background: #f5f5f5;
}

.vime-ls-dropdown .vime-ls-item.is-active a {
    background: #e8f4fd;
    color: #0073aa;
    font-weight: 600;
}

/* Inline Layout */
.vime-ls-inline {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
}

.vime-ls-inline .vime-ls-item {
    display: inline-flex;
    align-items: center;
}

.vime-ls-inline .vime-ls-item a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

.vime-ls-inline .vime-ls-item a:hover {
    opacity: 0.8;
}

.vime-ls-inline .vime-ls-item.is-active a {
    font-weight: 600;
}

/* Separator */
.vime-ls-separator {
    margin: 0 10px;
    opacity: 0.5;
}

/* Flag Shapes */
.vime-ls-flag {
    object-fit: cover;
    display: inline-block;
    vertical-align: middle;
}

.vime-ls-flag[style*="border-radius: 50%"] {
    object-fit: cover;
}

/* Animation Classes */
.vime-ls-animation-fade {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.vime-ls-animation-fade-slide {
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.vime-ls-animation-scale {
    transform: translateY(-10px) scale(0.95);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.vime-ls-animation-scale.is-open,
.vime-ls-current[aria-expanded="true"] + .vime-ls-animation-scale {
    transform: translateY(0) scale(1);
}

/* Responsive */
@media (max-width: 768px) {
    .vime-ls-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    
    .vime-ls-dropdown.is-open,
    .vime-ls-current[aria-expanded="true"] + .vime-ls-dropdown {
        transform: translateY(0);
    }
    
    .vime-ls-dropdown .vime-ls-item a {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .vime-ls-inline {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .vime-ls-inline .vime-ls-item {
        width: 100%;
    }
    
    .vime-ls-inline .vime-ls-item a {
        width: 100%;
        padding: 10px 15px;
    }
    
    .vime-ls-separator {
        display: none;
    }
}

/* Accessibility */
.vime-ls-wrapper:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 4px;
    border-radius: 4px;
}

.vime-ls-select:focus,
.vime-ls-current:focus,
.vime-ls-item a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .vime-ls-dropdown {
        border-width: 2px;
    }
    
    .vime-ls-current {
        border-width: 2px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .vime-ls-dropdown {
        background: #1a1a1a;
        border-color: #444;
    }
    
    .vime-ls-dropdown .vime-ls-item a:hover {
        background: #2a2a2a;
    }
    
    .vime-ls-dropdown .vime-ls-item.is-active a {
        background: #0a4a7a;
        color: #fff;
    }
}

/* RTL Support */
.rtl .vime-ls-wrapper {
    direction: rtl;
    text-align: right;
}

.rtl .vime-ls-inline {
    flex-direction: row-reverse;
}

.rtl .vime-ls-dropdown {
    text-align: right;
}

/* Loading State */
.vime-ls-wrapper.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Custom Dropdown Positioning */
.vime-ls-wrapper.vime-ls-dropdown {
    position: relative;
}

.vime-ls-wrapper.vime-ls-dropdown .vime-ls-dropdown {
    margin-top: 5px;
}

/* Smooth scrollbar for dropdown */
.vime-ls-dropdown::-webkit-scrollbar {
    width: 6px;
}

.vime-ls-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.vime-ls-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.vime-ls-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Button Icon Spacing */
.vime-ls-current .vime-ls-icon + .vime-ls-flag,
.vime-ls-current .vime-ls-icon + .vime-ls-text {
    margin-left: 0;
}

/* Ensure flags maintain aspect ratio */
.vime-ls-flag {
    flex-shrink: 0;
}

/* Print Styles */
@media print {
    .vime-ls-wrapper {
        display: none;
    }
}