/* Base Switcher */
.gt-switcher {
    position: relative;
    display: inline-block;
    font-family: var(--font-family-base, inherit);
    z-index: 1000;
}

/* Current Language Display */
.gt-switcher-current {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-md, 12px);
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-inverse, #fff);
    font-weight: 500;
}

/* Sticky State Override */
.main-navigation.scrolled .gt-switcher-current {
    color: var(--text, #141414);
}

.main-navigation.scrolled .gt-switcher-current:hover,
.main-navigation.scrolled .gt-switcher.open .gt-switcher-current {
    background: rgba(0, 0, 0, 0.05);
}

/* Hover/Active State */
.gt-switcher-current:hover,
.gt-switcher.open .gt-switcher-current {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Icons */
.gt-flag-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.gt-flag-icon svg,
.gt-flag-icon img {
    width: 20px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    object-fit: cover;
}

.gt-lang-code {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 14px;
    line-height: 1;
}

.gt-lang-name {
    display: none;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
}

.gt-arrow {
    display: block;
    width: 12px;
    height: 8px;
    transition: transform 0.2s ease;
    color: currentColor;
    opacity: 0.7;
}

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

/* Dropdown */
.gt-switcher-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-surface, #fff);
    border-radius: var(--radius-md, 12px);
    box-shadow: var(--shadow-lg, 0 10px 30px rgba(0, 0, 0, 0.12));
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    transition-delay: 0.2s;
    /* Prevent immediate closing */
    padding: 6px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Bridge the gap to prevent closing when moving mouse */
.gt-switcher-dropdown::before {
    content: '';
    position: absolute;
    top: -10px;
    /* Covers the margin + a bit more */
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.gt-switcher.open .gt-switcher-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Desktop Hover Support */
@media (min-width: 1025px) {
    .gt-switcher:hover .gt-switcher-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition-delay: 0s;
        /* Instant open */
    }

    .gt-switcher:hover .gt-switcher-current .gt-arrow {
        transform: rotate(180deg);
    }

    .gt-switcher:hover .gt-switcher-current {
        background: rgba(0, 0, 0, 0.05);
        /* Match theme hover */
    }
}

/* Dropdown Items */
.gt-switcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text, #333);
    text-decoration: none;
    transition: background 0.1s ease;
    font-size: 14px;
    border-radius: var(--radius-sm, 6px);
}

.gt-switcher-item:hover {
    background: var(--bg-muted, #f3f4f6);
    color: var(--text, #161615);
}

.gt-switcher-item.current {
    font-weight: 600;
    background: var(--bg-muted, #f3f4f6);
    /* Neutral active state */
    color: var(--text, #161615);
}

/* Mobile Styling for Navigation Integration */
@media (max-width: 1024px) {

    /* Use padding-block instead of borders/margins */
    li.nav-lang-switcher {
        width: 100%;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .gt-switcher {
        display: block;
        width: 100%;
    }

    .gt-switcher-current {
        justify-content: flex-start;
        width: 100%;
        padding: var(--space-md);
        background: transparent;
        color: var(--text, #161615);
        gap: 12px;
    }

    .main-navigation.scrolled .gt-switcher-current {
        color: var(--text, #161615);
    }

    .gt-lang-code {
        display: none;
    }

    .gt-lang-name {
        display: inline-block;
        font-size: var(--font-size-base);
        font-weight: var(--font-weight-semibold);
    }

    .gt-arrow {
        margin-left: auto;
        width: 12px;
        height: 8px;
        opacity: 0.7;
    }

    .gt-switcher-dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        margin-top: 5px;
        padding: 0;
        background: transparent;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
        padding-left: 0;
        /* Remove indent */
        gap: 2px;
    }

    .gt-switcher.open .gt-switcher-dropdown {
        display: block;
        animation: slideDown 0.2s ease;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .gt-switcher-item {
        padding: var(--space-md) !important;
        padding-left: 0;
        border-radius: var(--radius-md, 12px);
        background: transparent;
        font-size: 16px;
        margin-bottom: 2px;
    }

    .gt-switcher-item:hover,
    .gt-switcher-item.current {
        background: var(--bg-muted, #f3f4f6);
        padding: var(--space-md);
    }

    .gt-switcher-item.current {
        display: none;
    }

    .gt-switcher-item .gt-lang-code {
        display: none;
    }

    .gt-switcher-item .gt-lang-name {
        display: inline-block;
    }
}