/**
 * AquaLibs language selector v6.4.5
 *
 * The visible control is GTranslate's own popup trigger, not a proxy button.
 * Therefore one click on the UK flag opens the native language popup.
 */

header#header .grouptools .grouptool.langswitch {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 60px;
    min-width: 48px;
    padding: 0 8px !important;
    margin: 0;
    cursor: pointer;
}

#aql-gtranslate-wrapper.aql-gtranslate-native {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 60px;
    margin: 0;
    padding: 0;
    line-height: 1;
}

/* Immediate first-paint placeholder. popup.js replaces/adds the native trigger. */
#aql-gtranslate-wrapper .aql-language-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 22px;
    overflow: hidden;
    pointer-events: none;
}

#aql-gtranslate-wrapper .aql-language-placeholder svg {
    display: block;
    width: 32px;
    height: 22px;
}

/* Hide the placeholder the moment GTranslate's native popup trigger exists. */
#aql-gtranslate-wrapper:has(.gt_switcher-popup) .aql-language-placeholder {
    display: none;
}

/* Native GTranslate popup trigger: flag only, exactly like the old header. */
#aql-gtranslate-wrapper .gt_switcher-popup,
#aql-gtranslate-wrapper a.gt_switcher-popup {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 60px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    line-height: 1 !important;
    text-decoration: none !important;
}

/* GTranslate adds language text and a dropdown marker; AquaLibs only wants the flag. */
#aql-gtranslate-wrapper .gt_switcher-popup > span,
#aql-gtranslate-wrapper a.gt_switcher-popup > span {
    display: none !important;
}

#aql-gtranslate-wrapper .gt_switcher-popup img,
#aql-gtranslate-wrapper a.gt_switcher-popup img,
#aql-gtranslate-wrapper a.glink img {
    display: block !important;
    width: 32px !important;
    max-width: 32px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    opacity: 1 !important;
}

/* Do not let old group hover gradient rules affect the translator. */
header#header .langswitch:hover,
header#header .langswitch:focus,
header#header .langswitch *:hover,
header#header .langswitch *:focus {
    -webkit-text-fill-color: initial !important;
}

#aql-gtranslate-wrapper .gt_switcher-popup:focus-visible {
    outline: 2px solid #68c746 !important;
    outline-offset: 3px !important;
}

@media screen and (max-width: 799px) {
    header#header .grouptools .grouptool.langswitch {
        min-width: 44px;
        padding: 0 6px !important;
    }

    #aql-gtranslate-wrapper.aql-gtranslate-native,
    #aql-gtranslate-wrapper .gt_switcher-popup,
    #aql-gtranslate-wrapper a.gt_switcher-popup {
        height: 60px !important;
    }

    #aql-gtranslate-wrapper .aql-language-placeholder,
    #aql-gtranslate-wrapper .aql-language-placeholder svg,
    #aql-gtranslate-wrapper .gt_switcher-popup img,
    #aql-gtranslate-wrapper a.gt_switcher-popup img,
    #aql-gtranslate-wrapper a.glink img {
        width: 32px !important;
    }
}


/* ========================================================================
   AquaLibs classic GTranslate popup restoration - v6.4.5.1
   Recreates the old 4-column popup seen on AquaLibs and neutralises legacy
   template rules that break flag/text alignment.
   ======================================================================== */

/* Keep GTranslate's dark modal overlay exactly as the old popup behaviour. */
div.gt_black_overlay {
    background: rgba(0, 0, 0, .80) !important;
    opacity: 1 !important;
}

/* Centred desktop popup, close to the proportions of the old AquaLibs UI. */
div.gt_white_content {
    box-sizing: border-box !important;
    width: min(980px, calc(100vw - 48px)) !important;
    max-width: 980px !important;
    height: auto !important;
    max-height: min(375px, calc(100vh - 80px)) !important;
    margin: 0 !important;
    padding: 10px 18px 12px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: 0 8px 34px rgba(0, 0, 0, .28) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    font-family: "Poppins", sans-serif !important;
}

/*
 * GTranslate changes its own wrapping depending on viewport width.
 * Force the old AquaLibs desktop layout: four equal language columns.
 */
div.gt_white_content .gt_languages {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    align-items: stretch !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    column-count: initial !important;
    column-width: initial !important;
}

/* One clean row per language. */
div.gt_white_content .gt_languages a.glink {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 7px !important;
    min-width: 0 !important;
    width: auto !important;
    height: 45px !important;
    margin: 0 !important;
    padding: 6px 10px 6px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #e2e2e2 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    color: #202020 !important;
    -webkit-text-fill-color: #202020 !important;
    font-family: "Poppins", sans-serif !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    text-align: left !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    vertical-align: middle !important;
}

/* Undo old global <a>, img and hover styles from the Joomla 3 template. */
div.gt_white_content .gt_languages a.glink:hover,
div.gt_white_content .gt_languages a.glink:focus {
    background: #f8f8f8 !important;
    color: #111 !important;
    -webkit-text-fill-color: #111 !important;
    text-decoration: none !important;
    outline: 0 !important;
}

div.gt_white_content .gt_languages a.glink img {
    display: block !important;
    flex: 0 0 32px !important;
    float: none !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 24px !important;
    max-height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    object-fit: cover !important;
    opacity: 1 !important;
    vertical-align: middle !important;
}

div.gt_white_content .gt_languages a.glink span {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    color: #202020 !important;
    -webkit-background-clip: border-box !important;
    -webkit-text-fill-color: #202020 !important;
    font-family: "Poppins", sans-serif !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    text-align: left !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    overflow: hidden !important;
}

/* English was bold in the old popup. */
div.gt_white_content .gt_languages a.glink:first-child span {
    font-weight: 700 !important;
}

/* Simple scrollbar, similar to the previous popup. */
div.gt_white_content {
    scrollbar-width: thin;
    scrollbar-color: #8d8d8d #f5f5f5;
}

div.gt_white_content::-webkit-scrollbar {
    width: 9px;
}

div.gt_white_content::-webkit-scrollbar-track {
    background: #f5f5f5;
}

div.gt_white_content::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background: #8d8d8d;
}

/* Tablet: retain readability rather than squeezing four columns. */
@media (max-width: 900px) {
    div.gt_white_content {
        width: calc(100vw - 28px) !important;
        max-height: calc(100vh - 50px) !important;
        padding: 10px 14px !important;
    }

    div.gt_white_content .gt_languages {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    div.gt_white_content .gt_languages a.glink,
    div.gt_white_content .gt_languages a.glink span {
        font-size: 16px !important;
    }
}

/* Mobile: two columns, then one on very narrow phones. */
@media (max-width: 620px) {
    div.gt_white_content .gt_languages {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    div.gt_white_content .gt_languages a.glink {
        height: 43px !important;
    }

    div.gt_white_content .gt_languages a.glink img {
        flex-basis: 28px !important;
        width: 28px !important;
        min-width: 28px !important;
        max-width: 28px !important;
        height: 21px !important;
        max-height: 21px !important;
    }
}

@media (max-width: 390px) {
    div.gt_white_content .gt_languages {
        grid-template-columns: 1fr !important;
    }
}


/* ========================================================================
   AquaLibs GTranslate modal positioning fix - v6.4.5.2
   v6.4.5.1 changed the popup width but left GTranslate's original left/top
   positioning in place. With left:50% and no translate, half of the 980px
   popup sat outside the right edge of the viewport.
   ======================================================================== */

html body div.gt_black_overlay {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 19881204 !important;
    background: rgba(0, 0, 0, .80) !important;
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

html body div.gt_white_content {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 19881205 !important;

    width: min(980px, calc(100vw - 48px)) !important;
    max-width: 980px !important;
    max-height: min(375px, calc(100vh - 80px)) !important;

    margin: 0 !important;
}

/* Make sure the 4th desktop column is not clipped by an inherited width. */
html body div.gt_white_content .gt_languages {
    width: 100% !important;
    max-width: none !important;
}

/* Keep popup clicks above the backdrop. */
html body div.gt_white_content,
html body div.gt_white_content * {
    pointer-events: auto;
}

@media (max-width: 900px) {
    html body div.gt_white_content {
        width: calc(100vw - 28px) !important;
        max-height: calc(100vh - 50px) !important;
    }
}

@media (max-width: 620px) {
    html body div.gt_white_content {
        width: calc(100vw - 20px) !important;
        max-height: calc(100vh - 28px) !important;
    }
}
