/* ==========================================================================
   Language Switcher & Circular Flag Popup System (Deecotechnic)
   Supports: EN (Default), TH, FR with Circular Vector Flags & Dark Theme
   ========================================================================== */

/* ───────────────────────────────────────────
   1. Floating Language Switcher Button
─────────────────────────────────────────── */
#lang-switcher-btn {
    position: fixed;
    top: 124px;
    right: 20px;
    z-index: 990;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease, border-color 0.25s ease;
    outline: none;
}

#lang-switcher-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.45);
    border-color: #38bdf8;
}

#lang-switcher-btn:active {
    transform: scale(0.95);
}

.lang-btn-flag {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.lang-btn-flag svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lang-btn-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: #0369a1;
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 6px;
    border: 1px solid #ffffff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ───────────────────────────────────────────
   2. Circular Flag Element
─────────────────────────────────────────── */
.lang-flag-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.6);
    margin-right: 14px;
    flex-shrink: 0;
    background: #e2e8f0;
}

.lang-flag-circle svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ───────────────────────────────────────────
   3. Language Selection Popup Modal
─────────────────────────────────────────── */
#lang-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#lang-popup.show {
    visibility: visible;
    opacity: 1;
}

.lang-popup-inner {
    background: #ffffff;
    width: 92%;
    max-width: 420px;
    border-radius: 20px;
    padding: 26px 24px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
}

#lang-popup.show .lang-popup-inner {
    transform: translateY(0) scale(1);
}

/* Dark mode theme for popup */
[data-theme="dark"] .lang-popup-inner {
    background: #181c24;
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
}

/* Header */
.lang-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .lang-popup-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.lang-popup-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

[data-theme="dark"] .lang-popup-header h3 {
    color: #f8fafc;
}

.lang-popup-close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px 8px;
    transition: color 0.2s, background-color 0.2s;
}

.lang-popup-close:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

/* Language Popup Footer Close Button */
.lang-popup-footer {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
}

[data-theme="dark"] .lang-popup-footer {
    border-top-color: #334155;
}

.lang-popup-bottom-close {
    width: 100%;
    padding: 10px 18px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.lang-popup-bottom-close:hover,
.lang-popup-bottom-close:active {
    background: #e2e8f0;
    color: #0f172a;
}

[data-theme="dark"] .lang-popup-bottom-close {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

[data-theme="dark"] .lang-popup-bottom-close:hover,
[data-theme="dark"] .lang-popup-bottom-close:active {
    background: #334155;
    color: #ffffff;
}

/* Language Options List */
.lang-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lang-option-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.22s ease;
    user-select: none;
}

.lang-option-card:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .lang-option-card {
    background: #1e2430;
    border-color: #2e3646;
}

[data-theme="dark"] .lang-option-card:hover {
    background: #262e3d;
    border-color: #3b82f6;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* Active State */
.lang-option-card.active {
    background: rgba(14, 165, 233, 0.08);
    border-color: #0284c7;
    box-shadow: 0 0 0 1px #0284c7;
}

[data-theme="dark"] .lang-option-card.active {
    background: rgba(14, 165, 233, 0.15);
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px #38bdf8;
}

.lang-card-left {
    display: flex;
    align-items: center;
}

.lang-text-group {
    display: flex;
    flex-direction: column;
}

.lang-name {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.25;
}

[data-theme="dark"] .lang-name {
    color: #f1f5f9;
}

.lang-native-name {
    font-size: 12.5px;
    color: #64748b;
    margin-top: 2px;
}

[data-theme="dark"] .lang-native-name {
    color: #94a3b8;
}

.lang-card-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-theme="dark"] .lang-badge {
    background: #334155;
    color: #cbd5e1;
}

.lang-option-card.active .lang-badge {
    background: #0284c7;
    color: #ffffff;
}

.lang-check-icon {
    font-size: 16px;
    color: #0284c7;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="dark"] .lang-check-icon {
    color: #38bdf8;
}

.lang-option-card.active .lang-check-icon {
    opacity: 1;
    transform: scale(1);
}

/* ───────────────────────────────────────────
   4. Hide floating buttons on menu/dropdown open
─────────────────────────────────────────── */
body.mobile-nav-active #lang-switcher-btn,
body.nav-dropdown-open #lang-switcher-btn,
body.has-dropdown-open #lang-switcher-btn,
.header:hover ~ #lang-switcher-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -10 !important;
    transform: scale(0.6) !important;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease !important;
}

@supports selector(:has(*)) {
    body:has(#navbar .dropdown:hover) #lang-switcher-btn,
    body:has(#navbar .dropdown:focus-within) #lang-switcher-btn,
    body:has(.navbar .dropdown:hover) #lang-switcher-btn,
    body:has(.navbar .dropdown:focus-within) #lang-switcher-btn,
    body:has(.header .dropdown:hover) #lang-switcher-btn,
    body:has(.header .dropdown:focus-within) #lang-switcher-btn,
    body:has(.header:hover) #lang-switcher-btn,
    body:has(#navbar:hover) #lang-switcher-btn {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: -10 !important;
        transform: scale(0.6) !important;
        transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease !important;
    }
}

@media (max-width: 1279px) {
    #lang-switcher-btn {
        top: 112px !important;
        right: 20px !important;
    }
}

@media (max-width: 576px) {
    #lang-switcher-btn {
        top: 108px !important;
        right: 15px !important;
        width: 42px !important;
        height: 42px !important;
    }

    .lang-btn-flag {
        width: 24px;
        height: 24px;
    }

    .lang-popup-inner {
        padding: 22px 18px;
    }

    .lang-flag-circle {
        width: 32px;
        height: 32px;
        min-width: 32px;
        margin-right: 10px;
    }

    .lang-name {
        font-size: 15px;
    }

    .lang-popup-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(239, 68, 68, 0.1);
        color: #ef4444;
    }

    .lang-popup-bottom-close {
        padding: 12px 20px;
        font-size: 15px;
        background: rgba(239, 68, 68, 0.12);
        color: #ef4444;
        border-color: rgba(239, 68, 68, 0.35);
        border-radius: 14px;
    }

    .lang-popup-bottom-close:active {
        background: #ef4444;
        color: #ffffff;
    }
}

/* ───────────────────────────────────────────
   5. Dynamic Multi-Language Content Blocks
─────────────────────────────────────────── */
html[lang="en"] [data-lang-block]:not([data-lang-block="en"]) {
    display: none !important;
}
html[lang="th"] [data-lang-block]:not([data-lang-block="th"]) {
    display: none !important;
}
html[lang="fr"] [data-lang-block]:not([data-lang-block="fr"]) {
    display: none !important;
}

/* ───────────────────────────────────────────
   6. Clean Auto-Translate Integration (Hide Google Translate UI)
─────────────────────────────────────────── */
body {
    top: 0px !important;
    position: static !important;
}

#google_translate_element,
.skiptranslate,
.goog-te-banner-frame,
iframe.goog-te-banner-frame,
.goog-te-menu-frame,
#goog-gt-tt,
.goog-tooltip,
.goog-tooltip:hover,
.goog-te-balloon-frame {
    display: none !important;
    visibility: hidden !important;
}

.goog-text-highlight {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

