/* LatePoint Multilingual Frontend Styles */

/* CRITICAL: Force dropdown closed state - highest priority */
.latepoint-language-switcher .language-switcher-options[style],
.latepoint-language-switcher .language-switcher-options,
.latepoint-booking-form-language-switcher .language-switcher-options[style],
.latepoint-booking-form-language-switcher .language-switcher-options {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

/* Only allow open when class is present */
.latepoint-language-switcher.open .language-switcher-options,
.latepoint-booking-form-language-switcher.open .language-switcher-options {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Language Switcher */
.latepoint-language-switcher,
.latepoint-booking-form-language-switcher {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.latepoint-language-switcher.dropdown,
.latepoint-booking-form-language-switcher.dropdown {
    position: relative;
}

/* Ensure dropdown is closed by default - multiple fallbacks */
.latepoint-language-switcher .language-switcher-options,
.latepoint-language-switcher:not(.open) .language-switcher-options,
.latepoint-language-switcher ul.language-switcher-options,
.latepoint-language-switcher:not(.open) ul.language-switcher-options,
.latepoint-booking-form-language-switcher .language-switcher-options,
.latepoint-booking-form-language-switcher:not(.open) .language-switcher-options,
.latepoint-booking-form-language-switcher ul.language-switcher-options,
.latepoint-booking-form-language-switcher:not(.open) ul.language-switcher-options {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
}

/* Only show when explicitly open */
.latepoint-language-switcher.open .language-switcher-options,
.latepoint-language-switcher.open ul.language-switcher-options,
.latepoint-booking-form-language-switcher.open .language-switcher-options,
.latepoint-booking-form-language-switcher.open ul.language-switcher-options {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 300px !important;
    overflow: visible !important;
}

.latepoint-language-switcher .language-switcher-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #333;
    user-select: none;
}

.latepoint-language-switcher .language-switcher-current:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.latepoint-language-switcher .language-switcher-current .flag {
    font-size: 16px;
    line-height: 1;
}

.latepoint-language-switcher .language-switcher-current .arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.latepoint-language-switcher.open .language-switcher-current .arrow {
    transform: rotate(180deg);
}

/* Base dropdown state - ALWAYS CLOSED by default */
.latepoint-language-switcher .language-switcher-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 1000;
    min-width: 140px;
    
    /* CLOSED STATE - multiple ways to ensure it's hidden */
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

/* OPEN STATE - only when .open class is present */
.latepoint-language-switcher.open .language-switcher-options {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 300px !important;
    overflow: visible !important;
    transform: translateY(0);
}

.latepoint-language-switcher .language-switcher-options li {
    margin: 0;
    padding: 0;
}

.latepoint-language-switcher .language-switcher-options a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.latepoint-language-switcher .language-switcher-options a:hover {
    background: #f5f5f5;
}

.latepoint-language-switcher .language-switcher-options .flag {
    font-size: 16px;
    line-height: 1;
}

/* Language Switcher Wrapper */
.latepoint-language-switcher-wrapper {
    text-align: right;
    margin-bottom: 15px;
}

/* Booking Form Integration */
.latepoint-booking-form-language-switcher {
    margin-bottom: 20px;
    background: #f8f9fa;
    border-radius: 6px;
}

.latepoint-booking-form-language-switcher .language-switcher-current {
    background: transparent;
    border: 1px solid #ddd;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 20px;
}

.latepoint-booking-form-language-switcher .language-switcher-current:hover {
    background: rgba(255, 255, 255, 0.9);
}

.latepoint-booking-form-language-switcher .language-switcher-options {
    min-width: 100px;
    border-radius: 8px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.latepoint-booking-form-language-switcher .language-switcher-options a {
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
}

.latepoint-booking-form-language-switcher .language-switcher-options a:last-child {
    border-bottom: none;
}

/* Specific styles for booking form language switcher */
.latepoint-booking-form-language-switcher .language-switcher-current,
.latepoint-booking-form-language-switcher button.language-switcher-current {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #333;
}

.latepoint-booking-form-language-switcher .language-switcher-current:hover,
.latepoint-booking-form-language-switcher button.language-switcher-current:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.latepoint-booking-form-language-switcher .language-switcher-current .flag {
    font-size: 16px;
    line-height: 1;
}

.latepoint-booking-form-language-switcher .language-switcher-current .arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.latepoint-booking-form-language-switcher.open .language-switcher-current .arrow {
    transform: rotate(180deg);
}

/* Dropdown options for booking form */
.latepoint-booking-form-language-switcher .language-switcher-options {
    position: absolute;
    top: 3em;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 1000;
    min-width: 100px;
    
    /* CLOSED STATE */
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.latepoint-booking-form-language-switcher .language-switcher-options li {
    margin: 0;
    padding: 0;
}

.latepoint-booking-form-language-switcher .language-switcher-options a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.latepoint-booking-form-language-switcher .language-switcher-options a:hover {
    background: #f5f5f5;
}

.latepoint-booking-form-language-switcher .language-switcher-options .flag {
    font-size: 16px;
    line-height: 1;
}

/* Enhanced Loading Indicators */
.latepoint-language-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.latepoint-language-loading.visible {
    opacity: 1;
}

.latepoint-language-loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: latepoint-spin 1s linear infinite;
}

@keyframes latepoint-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.latepoint-language-message {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 300px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.latepoint-language-message.visible {
    transform: translateX(0);
}

.latepoint-language-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.latepoint-language-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Enhanced message types */
.latepoint-language-message-warning {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.latepoint-language-message-warning::before {
    content: '⚠️';
    margin-right: 8px;
}

/* RTL Support */
.latepoint-rtl .latepoint-language-switcher-wrapper {
    text-align: left;
}

.latepoint-rtl .latepoint-language-switcher .language-switcher-options {
    left: auto;
    right: 0;
}

.latepoint-rtl .latepoint-language-message {
    right: auto;
    left: 20px;
}

/* Service & Category Content Updates */
.service-content-updating,
.category-content-updating {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .latepoint-language-switcher-wrapper {
        text-align: center;
    }
    
    .latepoint-language-switcher .language-switcher-current {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .latepoint-language-switcher .language-switcher-options a {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .latepoint-language-message {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 768px) {
    .latepoint-language-loading .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
    
    .latepoint-language-message {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 13px;
    }
    
    .latepoint-language-switcher .language-switcher-options {
        min-width: 180px;
    }
}

/* Integration with LatePoint booking forms */
.latepoint-booking-form-element .latepoint-language-switcher-wrapper {
    margin-bottom: 20px;
    padding: 0 15px;
    position: absolute;
    right: 0;
    top: 1em;
    z-index: 99;
}

/* Service/Category display elements */
.service-name, .category-name, .agent-name {
    transition: all 0.3s ease;
}

.service-description, .category-description, .agent-bio {
    transition: all 0.3s ease;
}

/* Smooth content updates */
.latepoint-content-updating {
    position: relative;
}

.latepoint-content-updating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Language switcher in different contexts */
.latepoint-widget .latepoint-language-switcher {
    margin-bottom: 10px;
}

.latepoint-shortcode .latepoint-language-switcher {
    margin-bottom: 15px;
}

/* Accessibility improvements */
.latepoint-language-switcher .language-switcher-current:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.latepoint-language-switcher .language-switcher-options a:focus {
    background: #007cba;
    color: white;
    outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .latepoint-language-switcher .language-switcher-current {
        border-width: 2px;
    }
    
    .latepoint-language-switcher .language-switcher-options {
        border-width: 2px;
    }
}

/* Performance optimization for animations */
.latepoint-language-switcher,
.latepoint-language-switcher *,
.latepoint-language-message,
.latepoint-content-transition {
    will-change: transform, opacity;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .latepoint-language-switcher .language-switcher-current {
        background: #2d2d2d;
        border-color: #555;
        color: #fff;
    }
    
    .latepoint-language-switcher .language-switcher-current:hover {
        background: #3d3d3d;
        border-color: #666;
    }
    
    .latepoint-language-switcher .language-switcher-options {
        background: #2d2d2d;
        border-color: #555;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .latepoint-language-switcher .language-switcher-options a {
        color: #fff;
    }
    
    .latepoint-language-switcher .language-switcher-options a:hover {
        background: #3d3d3d;
    }
}

/* Additional AJAX switching improvements */
.latepoint-ajax-language-switch {
    cursor: pointer;
    transition: all 0.2s ease;
}

.latepoint-ajax-language-switch:hover {
    background-color: rgba(0, 124, 186, 0.1);
}

/* Current language in list view */
.latepoint-language-switcher.list .current-language {
    font-weight: bold;
    opacity: 0.7;
    cursor: default;
}

/* Additional safeguards to prevent dropdown being open by default */
.latepoint-language-switcher .language-switcher-options[style*="display: block"] {
    display: none !important;
}

.latepoint-language-switcher.open .language-switcher-options[style*="display: block"] {
    display: block !important;
}

/* Reset any inline styles that might interfere */
.latepoint-language-switcher .language-switcher-options[style] {
    display: none !important;
}

.latepoint-language-switcher.open .language-switcher-options[style] {
    display: block !important;
}

.latepoint-message.latepoint-message-error {
    display: none!important;
}

.os-item .os-service-selector .os-item-price-label {
    display: none!important;
}

.latepoint-w .latepoint-booking-form-element .os-items .os-item .os-item-i .os-item-price-w .os-item-price,
.latepoint-w .latepoint-transaction-payment-form .os-items .os-item .os-item-i .os-item-price-w .os-item-price {
    font-size: 17px!important;
}