/**
 * Language Switcher CSS - Comprehensive Styling
 * Optimized for all devices and browsers
 * Supports Vietnamese, English, Korean, Chinese, Japanese
 */

/* ==========================================================================
   Base Language Switcher Styles
   ========================================================================== */

.language-switcher {
    position: relative;
    z-index: 1000;
}

.custom-select-wrapper {
    position: relative;
    min-width: 120px;
}

.custom-select {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.select-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    transition: all 0.3s ease;
    color: white;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    backdrop-filter: blur(10px);
}

.select-selected:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.select-selected::after {
    content: '▼';
    font-size: 10px;
    margin-left: auto;
    transition: transform 0.3s ease;
    opacity: 0.7;
}

.select-arrow-active .select-selected::after {
    transform: rotate(180deg);
}

/* ==========================================================================
   Dropdown Menu Styles
   ========================================================================== */

.select-items {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.select-items:not(.select-hide) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.select-hide {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #007bff;
    padding-left: 20px;
}

.lang-option:active {
    background: #e9ecef;
    transform: scale(0.98);
}

/* ==========================================================================
   Flag Image Styles
   ========================================================================== */

.flag-img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.lang-option:hover .flag-img {
    transform: scale(1.1);
}

/* ==========================================================================
   Notification System
   ========================================================================== */

#language-notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
    max-width: 350px;
}

.language-notification {
    background: #007bff;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.3);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    word-wrap: break-word;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.language-notification.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    box-shadow: 0 4px 20px rgba(40, 167, 69, 0.3);
}

.language-notification.error {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    box-shadow: 0 4px 20px rgba(220, 53, 69, 0.3);
}

.language-notification.loading {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.notification-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.language-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.language-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   Responsive Design - Tablet
   ========================================================================== */

@media (max-width: 991px) {
    .language-switcher {
        margin-left: 10px;
    }
    
    .select-selected {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .flag-img {
        width: 18px;
        height: 14px;
    }
    
    .lang-option {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    #language-notifications {
        top: 15px;
        right: 15px;
        max-width: 280px;
    }
}

/* ==========================================================================
   Responsive Design - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    .language-switcher {
        margin: 15px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 15px;
    }
    
    .custom-select-wrapper {
        min-width: 100%;
    }
    
    .select-selected {
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        margin: 0 20px;
        font-size: 16px;
        justify-content: space-between;
    }
    
    .select-items {
        position: static;
        margin: 10px 20px 0;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        box-shadow: none;
        backdrop-filter: blur(10px);
    }
    
    .lang-option {
        color: #fff;
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 16px;
    }
    
    .lang-option:last-child {
        border-bottom: none;
    }
    
    .lang-option:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        padding-left: 24px;
    }
    
    .flag-img {
        width: 24px;
        height: 18px;
    }
    
    /* Mobile notifications */
    #language-notifications {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .language-notification {
        font-size: 14px;
        padding: 12px 16px;
        border-radius: 6px;
    }
    
    /* Mobile overlay for dropdown */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ==========================================================================
   Small Mobile Devices
   ========================================================================== */

@media (max-width: 480px) {
    .select-selected {
        padding: 10px 14px;
        margin: 0 15px;
        font-size: 15px;
    }
    
    .lang-option {
        padding: 14px 18px;
        font-size: 15px;
    }
    
    .flag-img {
        width: 22px;
        height: 16px;
    }
    
    .language-notification {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    #language-notifications {
        top: 8px;
        right: 8px;
        left: 8px;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .select-items {
        background: #2d3748;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .lang-option {
        color: #e2e8f0;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .lang-option:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #90cdf4;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
    .select-selected {
        border: 2px solid white;
        background: rgba(0, 0, 0, 0.8);
    }
    
    .select-items {
        border: 2px solid #000;
    }
    
    .lang-option:hover {
        background: #000;
        color: #fff;
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .select-selected,
    .select-items,
    .lang-option,
    .flag-img,
    .language-notification {
        transition: none;
        animation: none;
    }
    
    .select-selected::after {
        transition: none;
    }
    
    .notification-spinner {
        animation: none;
        border: 2px solid white;
        border-top: 2px solid transparent;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .language-switcher,
    #language-notifications {
        display: none !important;
    }
}
