/* Rev Hreflangs Language Switcher - Frontend Styles */

/* Base Styles */
.rev-lang-switcher {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.4;
    box-sizing: border-box;
}

.rev-lang-switcher * {
    box-sizing: border-box;
}

/* Size Variations */
.rev-lang-switcher-small {
    font-size: 12px;
}

.rev-lang-switcher-medium {
    font-size: 14px;
}

.rev-lang-switcher-large {
    font-size: 16px;
}

/* Theme: Default */
.rev-lang-switcher-default {
    --primary-color: #0073aa;
    --secondary-color: #f1f1f1;
    --text-color: #333;
    --border-color: #ddd;
    --hover-color: #005a87;
    --current-color: #0073aa;
}

/* Theme: Modern */
.rev-lang-switcher-modern {
    --primary-color: #2c3e50;
    --secondary-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --hover-color: #34495e;
    --current-color: #3498db;
}

/* Theme: Minimal */
.rev-lang-switcher-minimal {
    --primary-color: #333;
    --secondary-color: transparent;
    --text-color: #333;
    --border-color: #ccc;
    --hover-color: #000;
    --current-color: #333;
}

/* Theme: Colorful */
.rev-lang-switcher-colorful {
    --primary-color: #e74c3c;
    --secondary-color: #f8f9fa;
    --text-color: #2c3e50;
    --border-color: #e74c3c;
    --hover-color: #c0392b;
    --current-color: #e74c3c;
}

/* Dropdown Style */
.rev-lang-dropdown {
    position: relative;
    display: inline-block;
}

.rev-lang-current {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: 500;
}

.rev-lang-current-text {
    color: var(--text-color);
    font-size: 0.9em;
}

.rev-lang-current-lang {
    background: var(--current-color);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
}

.rev-lang-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-color);
    font-size: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    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 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.rev-lang-select:hover {
    border-color: var(--hover-color);
}

.rev-lang-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Selected option styling */
.rev-lang-select option:checked {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.rev-lang-select option:hover {
    background: var(--secondary-color);
}

/* Ensure selected value is visible when dropdown is closed */
.rev-lang-select {
    color: var(--text-color);
    font-weight: 500;
}

.rev-lang-select:not([size]):not([multiple]) {
    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 12px center;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Force the selected option to be visible */
.rev-lang-select option[selected] {
    display: block;
}

/* Ensure the select shows the selected text */
.rev-lang-select:focus {
    color: var(--text-color);
}

/* Visual feedback for selection */
.rev-lang-select.has-selection {
    color: var(--text-color);
    font-weight: 500;
}

.rev-lang-select.selection-changed {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
    transition: all 0.2s ease;
}

/* Ensure selected option text is visible */
.rev-lang-select option[selected] {
    font-weight: 600;
    color: var(--primary-color);
}

/* Use data attribute to show selected text */
.rev-lang-select[data-current-text]:not([size]):not([multiple]) {
    color: var(--text-color);
}

/* Ensure the select shows the selected value text */
.rev-lang-select:not([size]):not([multiple]) {
    color: var(--text-color) !important;
    font-weight: 500 !important;
}

/* Force text visibility in all browsers */
.rev-lang-select {
    color: var(--text-color) !important;
    font-weight: 500 !important;
}

/* Override any browser default styling that might hide the text */
.rev-lang-select option {
    color: var(--text-color) !important;
    background: white !important;
}

.rev-lang-select option:checked,
.rev-lang-select option[selected] {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 600 !important;
}

/* Custom dropdown arrow */
.rev-lang-select::-ms-expand {
    display: none;
}

/* Firefox specific styling */
.rev-lang-select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 var(--text-color);
}

/* Ensure text is visible in all browsers */
.rev-lang-select option {
    color: var(--text-color);
    background: white;
}

.rev-lang-select option:checked {
    background: var(--primary-color);
    color: white;
}

/* Buttons Style */
.rev-lang-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rev-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.rev-lang-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.rev-lang-btn.rev-lang-current {
    background: var(--current-color);
    color: white;
    border-color: var(--current-color);
    font-weight: 600;
}

.rev-lang-btn.rev-lang-current:hover {
    background: var(--hover-color);
    border-color: var(--hover-color);
}

.rev-lang-flag {
    display: inline-block;
    font-size: 1.2em;
    line-height: 1;
}

.rev-lang-text {
    white-space: nowrap;
}

/* Flags Style */
.rev-lang-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.rev-lang-flag-link {
    display: inline-block;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    text-decoration: none;
}

.rev-lang-flag-link:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

.rev-lang-flag-link.rev-lang-current {
    background: var(--current-color);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
}

.rev-lang-flag-link.rev-lang-current:hover {
    background: var(--hover-color);
}

.rev-lang-flag {
    display: block;
    font-size: 1.5em;
    line-height: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rev-lang-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .rev-lang-btn {
        justify-content: center;
        text-align: center;
    }
    
    .rev-lang-flags {
        justify-content: center;
    }
    
    .rev-lang-dropdown {
        width: 100%;
    }
}

/* Hover Effects and Animations */
.rev-lang-switcher * {
    transition: all 0.2s ease;
}

.rev-lang-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.rev-lang-flag-link:active {
    transform: scale(1.05);
}

/* Focus States for Accessibility */
.rev-lang-btn:focus,
.rev-lang-flag-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.rev-lang-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .rev-lang-switcher-default {
        --primary-color: #4a9eff;
        --secondary-color: #2d3748;
        --text-color: #e2e8f0;
        --border-color: #4a5568;
        --hover-color: #3182ce;
        --current-color: #4a9eff;
    }
    
    .rev-lang-switcher-modern {
        --primary-color: #4a9eff;
        --secondary-color: #2d3748;
        --text-color: #e2e8f0;
        --border-color: #4a5568;
        --hover-color: #3182ce;
        --current-color: #4a9eff;
    }
    
    .rev-lang-switcher-minimal {
        --primary-color: #e2e8f0;
        --secondary-color: transparent;
        --text-color: #e2e8f0;
        --border-color: #4a5568;
        --hover-color: #f7fafc;
        --current-color: #e2e8f0;
    }
    
    .rev-lang-select {
        background-color: #2d3748;
        color: #e2e8f0;
    }
}

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

.rev-lang-switcher {
    animation: rev-lang-fade-in 0.3s ease-out;
}

/* Loading State */
.rev-lang-switcher.loading {
    opacity: 0.6;
    pointer-events: none;
}

.rev-lang-switcher.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: rev-lang-spin 1s linear infinite;
}

@keyframes rev-lang-spin {
    to {
        transform: rotate(360deg);
    }
}
