/**
 * MISA Language Switcher V2 - CSS Styles
 * Modern UI with search functionality and responsive design
 * Project: MISA.AccountingPlatform.ClientSearch
 * Created: 2025-01-24
 */

/* ============================================================================
   V2 Container
   ============================================================================ */
.language-switcher-container-v2 .language-switcher-v2 {
    position: relative;
    display: inline-block;
    font-family: 'AvertaStdCY', Helvetica, Arial, sans-serif;
    font-size: 14px;
    height: 100%;
    display: flex;
    align-items: center;
    margin-left: 10px;
}

/* ============================================================================
   Trigger Button
   ============================================================================ */
.language-trigger-v2 {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    min-width: 160px;
    height: 36px;
    transition: all 0.2s ease;
    outline: none;
    border: 0;
    box-sizing: border-box;
}

/* Globe Icon */
.globe-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    pointer-events: none;
}

/* Current Language Name */
.current-language-name {
    color: #333333;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
}


/* ============================================================================
   Dropdown Container
   ============================================================================ */
.language-dropdown-v2 {
    position: absolute;
    top: 100%;
    right: 0;
    background: #ffffff;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 575px;
    width: 235px;
    overflow: hidden;
    box-sizing: border-box;
}

/* ============================================================================
   Search Container
   ============================================================================ */
.search-container {
    padding: 12px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.language-search {
    width: 100%;
    padding: 8px 12px 8px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.language-search:focus {
    border-color: #31a035;
    box-shadow: 0 0 0 2px rgba(49, 160, 53, 0.2);
}

.language-search::placeholder {
    color: #999999;
    font-style: italic;
}

/* Search Icon */
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   Language List
   ============================================================================ */
.language-list-v2 {
    max-height: 510px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.language-list-v2::-webkit-scrollbar {
    width: 6px;
}

.language-list-v2::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.language-list-v2::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.language-list-v2::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ============================================================================
   Language Sections
   ============================================================================ */
.language-section {
    margin-bottom: 8px;
}

.language-section:last-child {
    margin-bottom: 0;
}

.section-title {
    padding: 8px 12px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ============================================================================
   Language Items
   ============================================================================ */
.language-item-v2 {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 50px;
    box-sizing: border-box;
}

.language-item-v2:hover,
.language-item-v2.focused {
    background-color: #EFF6FF;
}

.language-item-v2.active {
    background-color: transparent;
}

.language-item-v2.active:hover {
    background-color: #EFF6FF;
}

/* Flag Icon */
.flag-icon {
    width: 24px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Language Names Container */
.language-names {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* Language Name (English) */
.language-name {
    font-size: 14px;
    font-weight: 500;
    color: #333333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.language-item-v2.active .language-name {
    color: #1976d2;
}

/* Native Name */
.native-name {
    font-size: 12px;
    color: #666666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.language-item-v2.active .native-name {
    color: #1976d2;
}

/* Check Mark */
.check-mark {
    color: #1976d2;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
    margin-left: auto;
}

/* ============================================================================
   No Results State
   ============================================================================ */
.no-results {
    padding: 24px 12px;
    text-align: center;
    color: #999999;
    font-style: italic;
    background: #f8f9fa;
}

/* ============================================================================
   Loading State
   ============================================================================ */
.language-switcher-v2.loading .language-trigger-v2 {
    opacity: 0.6;
    cursor: not-allowed;
}

.language-switcher-v2.loading .current-language-name::after {
    content: "...";
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { opacity: 0; }
    40% { opacity: 0.5; }
    60%, 100% { opacity: 1; }
}

/* ============================================================================
   RTL Language Support
   ============================================================================ */
.language-item-v2[data-rtl="true"] .language-names {
    text-align: right;
    direction: rtl;
}

.language-item-v2[data-rtl="true"] .native-name {
    font-family: 'Tahoma', 'Arial Unicode MS', sans-serif;
}

/* ============================================================================
   Mobile Responsive Design
   ============================================================================ */
@media (max-width: 980px){
    .language-trigger-v2 {
        min-width: 40px;
        width: auto;
        font-size: 14px;
        justify-content: center;
        transform: scale(1.35);
        padding: 8px 12px 10px !important;
    }
    
    .current-language-name {
        display: none;
    }
}

@media (max-width: 780px) {
    .language-switcher-v2 {
        width: 100%;
    }
    
    .search-container {
        padding: max(env(safe-area-inset-top), 16px) 16px 16px;
        background: #f8f9fa;
        position: sticky;
        top: 0;
        z-index: 2;
    }
    
    .language-search {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 16px 12px 40px;
        height: 44px;
    }
    
    .search-icon {
        left: 16px;
    }
    
    .language-list-v2 {
        padding-bottom: env(safe-area-inset-bottom, 16px);
    }
    
    .language-item-v2 {
        padding: 16px;
        border-bottom: 1px solid #f0f0f0;
        min-height: 50px;
    }
    
    .language-item-v2:last-child {
        border-bottom: none;
    }
    
    .flag-icon {
        width: 28px;
        height: 21px;
    }
    
    .language-names {
        gap: 4px;
    }
    
    .language-name {
        font-size: 16px;
    }
    
    .native-name {
        font-size: 14px;
    }
    
    .check-mark {
        font-size: 18px;
    }
    
    .section-title {
        padding: 12px 16px 8px;
        font-size: 13px;
    }
    
    /* Mobile close overlay */
    .language-dropdown-v2::before {
        content: "";
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        background: url('/tim-ke-toan/Content/Images/Svg/icon-close.svg') center no-repeat;
        background-size: 16px;
        cursor: pointer;
        z-index: 3;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.1);
    }
}

/* ============================================================================
   Touch-Friendly Interactions
   ============================================================================ */
@media (hover: none) and (pointer: coarse) {
    .language-item-v2 {
        min-height: 48px;
        padding: 12px 16px;
    }
    
    .language-trigger-v2 {
        min-height: 44px;
        padding: 10px 12px;
    }
    
    .language-search {
        min-height: 44px;
    }
}

/* ============================================================================
   High Contrast Mode Support
   ============================================================================ */
/* ============================================================================
   Reduced Motion Support
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .language-trigger-v2,
    .language-search,
    .language-item-v2 {
        transition: none;
    }
    
    .language-list-v2 {
        scroll-behavior: auto;
    }
    
    @keyframes loading-dots {
        0%, 100% { opacity: 1; }
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */
@media print {
    .language-switcher-v2 {
        display: none;
    }
}

/* ============================================================================
   Focus Visible Support (Modern Browsers)
   ============================================================================ */
.language-trigger-v2:focus:not(:focus-visible) {
    box-shadow: none;
}

.language-search:focus:not(:focus-visible) {
    box-shadow: none;
}

.language-item-v2:focus-visible {
    outline: 2px solid #1976d2;
    outline-offset: -2px;
}

/* ============================================================================
   Animation Enhancements
   ============================================================================ */
.language-dropdown-v2 {
    animation: dropdown-appear 0.2s ease-out;
    transform-origin: top;
}

@keyframes dropdown-appear {
    from {
        opacity: 0;
        transform: scaleY(0.95) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

/* Hide dropdown when not shown */
.language-dropdown-v2[style*="display: none"] {
    animation: none;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.language-switcher-v2.compact .language-trigger-v2 {
    min-width: 120px;
    padding: 6px 10px;
    height: 32px;
    font-size: 13px;
}

.language-switcher-v2.compact .globe-icon {
    width: 16px;
    height: 16px;
}

.language-switcher-v2.full-width {
    width: 100%;
}

.language-switcher-v2.full-width .language-trigger-v2 {
    width: 100%;
}
