/* 언어 선택기 스타일 */
.language-selector {
    position: relative;
    z-index: 1002;
}

/* 언어 버튼 기본 스타일 - 웹사이트 기본 네온 초록색 테두리 네모 스타일 */
.language-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: rgba(0, 208, 132, 0.1);
    border: 2px solid #00D084;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 24px;
    outline: none;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.2);
}

.language-btn:hover {
    background-color: #00D084;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 208, 132, 0.6);
    border: 2px solid #00D084; /* border-color 대신 border로 통일 */
}

.language-flag {
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* 드롭다운 메뉴 - 위로 펼쳐지도록 수정 */
.language-dropdown {
    position: absolute;
    bottom: 100%; /* top에서 bottom으로 변경하여 위로 펼쳐지게 함 */
    right: 0;
    background-color: #1a1a1a;
    border: 1px solid rgba(0, 208, 132, 0.3);
    border-radius: 8px;
    min-width: 180px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1003;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px); /* 음수에서 양수로 변경 */
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    margin-bottom: 8px; /* 버튼과의 간격 추가 */
}

.language-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px); /* 위로 펼쳐질 때의 최종 위치 조정 */
}

.language-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.language-option:hover {
    background-color: rgba(0, 208, 132, 0.1);
}

.language-option .flag {
    font-size: 20px;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.language-option .name {
    color: white;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

/* 데스크탑 언어 선택기 위치 - 텔레그램 버튼 왼쪽에 배치 */
.language-selector.desktop {
    position: fixed;
    bottom: 30px; /* 텔레그램 FAB와 동일한 높이 */
    right: 100px; /* 텔레그램 버튼 왼쪽에 배치 */
    z-index: 999;
}

/* 모바일 언어 선택기 위치 */
.language-selector.mobile {
    display: none;
    margin-right: 5px; /* 햄버거 메뉴와의 간격을 줄임 */
    z-index: 1002;
    flex-shrink: 0;
}

/* 데스크탑에서 모바일 선택기 숨기기 */
@media (min-width: 769px) {
    .language-selector.mobile {
        display: none !important;
    }
}

/* 모바일에서 데스크탑 선택기 숨기고 모바일 선택기 표시 */
@media (max-width: 768px) {
    .language-selector.desktop {
        display: none !important;
    }
    
    .language-selector.mobile {
        display: flex;
        position: relative;
        z-index: 1002;
        margin-right: 5px; /* 햄버거 메뉴와 더 가까이 */
        margin-left: auto; /* 자동으로 오른쪽으로 밀어내기 */
        order: 10; /* 햄버거 메뉴 바로 앞에 배치 */
    }
    
    .language-selector.mobile .language-dropdown {
        top: 100%; /* 아래로 펼쳐지도록 변경 */
        bottom: auto; /* bottom 속성 제거 */
        right: 0;
        left: auto;
        min-width: 160px;
        margin-top: 8px; /* 버튼과의 간격 */
        margin-bottom: 0; /* 기존 margin-bottom 제거 */
        transform: translateY(10px); /* 초기 위치 */
    }
    
    .language-selector.mobile .language-dropdown.active {
        transform: translateY(0); /* 펼쳐졌을 때 위치 */
    }
}

/* 스크롤바 스타일링 */
.language-dropdown::-webkit-scrollbar {
    width: 6px;
}

.language-dropdown::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.language-dropdown::-webkit-scrollbar-thumb {
    background: rgba(0, 208, 132, 0.5);
    border-radius: 3px;
}

.language-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 208, 132, 0.7);
}

/* 애니메이션 최적화 */
.language-selector * {
    will-change: auto;
}

.language-dropdown.active {
    will-change: opacity, visibility, transform;
}

/* 아랍어 RTL 지원 */
html[lang="ar"] .language-dropdown {
    left: 0;
    right: auto;
}

html[lang="ar"] .language-option {
    flex-direction: row-reverse;
}

/* 언어별 폰트 최적화 */
html[lang="ar"] body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
}

html[lang="zh"] body {
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
}

html[lang="hi"] body {
    font-family: 'Noto Sans Devanagari', 'Mangal', 'Gargi', sans-serif;
}

html[lang="ko"] body {
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

html[lang="ru"] body {
    font-family: 'Segoe UI', 'Roboto', 'Ubuntu', 'Cantarell', sans-serif;
}

/* 언어별 텍스트 정렬 최적화 */
html[lang="ar"] .section-title,
html[lang="ar"] .section-subtitle,
html[lang="ar"] .section-description {
    text-align: right;
}

html[lang="ar"] .nav-links {
    flex-direction: row-reverse;
}

html[lang="ar"] .user-menu {
    flex-direction: row-reverse;
}

/* 언어별 간격 조정 */
html[lang="zh"] .section-title,
html[lang="ko"] .section-title,
html[lang="hi"] .section-title {
    line-height: 1.2;
}

/* 모바일에서 언어별 최적화 */
@media (max-width: 768px) {
    html[lang="ar"] .navbar {
        flex-direction: row-reverse;
    }
    
    html[lang="ar"] .mobile-auth-buttons {
        flex-direction: column-reverse;
    }
    
    html[lang="zh"] .section-title,
    html[lang="ko"] .section-title {
        font-size: 2.2rem;
    }
    
    /* 햄버거 메뉴를 맨 오른쪽에 배치 */
    .hamburger {
        order: 11; /* 언어 선택기 다음에 배치 */
        margin-left: 0; /* 좌측 마진 제거 */
    }
}

/* 다크모드 최적화 */
@media (prefers-color-scheme: dark) {
    .language-dropdown {
        background-color: #0d0d0d;
        border-color: rgba(0, 208, 132, 0.4);
    }
    
    .language-option:hover {
        background-color: rgba(0, 208, 132, 0.15);
    }
}

/* 접근성 개선 */
.language-btn:focus {
    outline: 2px solid #00D084;
    outline-offset: 2px;
}

.language-option:focus {
    background-color: rgba(0, 208, 132, 0.2);
    outline: none;
}

/* 키보드 네비게이션 지원 */
.language-option[data-focused="true"] {
    background-color: rgba(0, 208, 132, 0.2);
}

/* 모바일 터치 최적화 */
@media (max-width: 768px) {
    .language-option {
        padding: 14px 16px;
        min-height: 48px;
    }
    
    .language-btn {
        width: 42px;
        height: 42px;
        background-color: rgba(0, 208, 132, 0.1);
        border: 2px solid #00D084;
        border-radius: 10px; /* 모바일에서도 네모 모양 */
        box-shadow: 0 0 8px rgba(0, 208, 132, 0.2); /* 모바일에서도 네온 효과 */
        font-size: 20px; /* 모바일에서도 큰 국기 */
    }
    
    .language-btn:hover {
        background-color: #00D084;
        box-shadow: 0 0 15px rgba(0, 208, 132, 0.5);
    }
    
    .language-flag {
        font-size: 18px; /* 모바일에서 약간 작게 */
    }
}

/* 고해상도 디스플레이 최적화 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .language-flag {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}
