/* TranslatePixel — Frontend Language Switcher */

/* ──────────────────────────────────────────────────
   Base
────────────────────────────────────────────────── */
.tp-switcher {
    display: inline-block;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.tp-flag {
    font-size: 1.1em;
    line-height: 1;
}

/* ──────────────────────────────────────────────────
   Dropdown Style
────────────────────────────────────────────────── */
.tp-switcher--dropdown .tp-switcher__dropdown {
    position: relative;
    display: inline-block;
}

.tp-switcher--dropdown .tp-switcher__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
    white-space: nowrap;
    min-width: 100px;
}

.tp-switcher--dropdown .tp-switcher__toggle:hover,
.tp-switcher--dropdown .tp-switcher__toggle[aria-expanded="true"] {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
    outline: none;
}

.tp-caret {
    font-size: 10px;
    color: #9ca3af;
    margin-left: auto;
    transition: transform .2s;
}

.tp-switcher--dropdown .tp-switcher__toggle[aria-expanded="true"] .tp-caret {
    transform: rotate(180deg);
}

.tp-switcher__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    list-style: none;
    margin: 0;
    padding: 4px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .15s, transform .15s, visibility .15s;
}

.tp-switcher__menu.tp-menu--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tp-switcher__menu li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tp-switcher__menu li + li {
    margin-top: 2px;
}

.tp-switcher__menu li::before {
    display: none;
}

.tp-switcher__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 5px;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
    white-space: nowrap;
    font-size: 13px;
}

.tp-switcher__item:hover {
    background: #f3f4f6;
    color: inherit;
    text-decoration: none;
}

.tp-switcher__item--active {
    background: #eef2ff;
    color: #4f46e5;
    font-weight: 600;
}

.tp-switcher__item--active:hover {
    background: #e0e7ff;
    color: #4f46e5;
}

/* ──────────────────────────────────────────────────
   List Style
────────────────────────────────────────────────── */
.tp-switcher--list .tp-switcher__list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tp-switcher--list .tp-switcher__list li {
    margin: 0;
    padding: 0;
}

.tp-switcher--list .tp-switcher__list li::before {
    display: none;
}

.tp-switcher--list .tp-switcher__item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    text-decoration: none;
    color: inherit;
    font-size: 13px;
    transition: border-color .12s, background .12s;
}

.tp-switcher--list .tp-switcher__item:hover {
    border-color: #6366f1;
    background: #eef2ff;
    color: #4f46e5;
    text-decoration: none;
}

.tp-switcher--list .tp-switcher__item--active {
    border-color: #4f46e5;
    background: #4f46e5;
    color: #fff;
    font-weight: 600;
}

.tp-switcher--list .tp-switcher__item--active:hover {
    background: #4338ca;
    border-color: #4338ca;
    color: #fff;
}

/* ──────────────────────────────────────────────────
   Flags Style
────────────────────────────────────────────────── */
.tp-switcher--flags .tp-switcher__flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.tp-switcher__flag-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    text-decoration: none;
    transition: border-color .12s, box-shadow .12s, transform .12s;
    cursor: pointer;
}

.tp-switcher__flag-item:hover {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
    transform: scale(1.1);
    text-decoration: none;
}

.tp-switcher__flag-item--active {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.2);
}

/* ──────────────────────────────────────────────────
   Expand-on-Hover Card Style
────────────────────────────────────────────────── */
.tp-switcher--expand {
    display: inline-block;
}

.tp-switcher--expand .tp-switcher__expand {
    outline: none;
    cursor: pointer;
}

.tp-switcher--expand .tp-switcher__expand-card {
    display: inline-flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,.10);
    padding: 6px;
    min-width: 180px;
    overflow: hidden;
    gap: 0;
    transition: gap .2s ease, box-shadow .2s ease;
}

.tp-switcher--expand .tp-switcher__expand:hover .tp-switcher__expand-card,
.tp-switcher--expand .tp-switcher__expand:focus .tp-switcher__expand-card,
.tp-switcher--expand .tp-switcher__expand:focus-within .tp-switcher__expand-card {
    box-shadow: 0 8px 28px rgba(0,0,0,.16);
}

/* Hide non-active items by default; reveal on hover/focus */
.tp-switcher--expand .tp-switcher__expand-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: #1f2937;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .2s ease, opacity .15s ease, padding .2s ease, background .12s;
}

.tp-switcher--expand .tp-switcher__expand-item--active {
    max-height: 60px;
    padding-top: 10px;
    padding-bottom: 10px;
    opacity: 1;
    background: #f3f4f6;
    font-weight: 600;
    color: #1f2937;
}

.tp-switcher--expand .tp-switcher__expand:hover .tp-switcher__expand-item,
.tp-switcher--expand .tp-switcher__expand:focus .tp-switcher__expand-item,
.tp-switcher--expand .tp-switcher__expand:focus-within .tp-switcher__expand-item {
    max-height: 60px;
    padding-top: 10px;
    padding-bottom: 10px;
    opacity: 1;
}

/* Space between items only appears when the card is expanded */
.tp-switcher--expand .tp-switcher__expand:hover .tp-switcher__expand-card,
.tp-switcher--expand .tp-switcher__expand:focus .tp-switcher__expand-card,
.tp-switcher--expand .tp-switcher__expand:focus-within .tp-switcher__expand-card {
    gap: 2px;
}

.tp-switcher--expand .tp-switcher__expand-item:hover {
    background: #f3f4f6;
    text-decoration: none;
    color: #1f2937;
}

.tp-switcher--expand .tp-switcher__expand-item .tp-flag {
    font-size: 20px;
    line-height: 1;
}

.tp-switcher--expand .tp-switcher__expand-item .tp-ai-sparkle {
    margin-left: auto;
}

/* ──────────────────────────────────────────────────
   Floating Switcher
────────────────────────────────────────────────── */
.tp-floating {
    position: fixed;
    z-index: 9990;
}

.tp-floating--bottom-right { bottom: 20px; right: 20px; }
.tp-floating--bottom-left  { bottom: 20px; left: 20px; }
.tp-floating--top-right    { top: 20px; right: 20px; }
.tp-floating--top-left     { top: 20px; left: 20px; }

.tp-floating .tp-switcher--dropdown .tp-switcher__menu {
    /* Floating bottom-* positions need upward menu */
}

.tp-floating--bottom-right .tp-switcher__menu,
.tp-floating--bottom-left .tp-switcher__menu {
    bottom: calc(100% + 4px);
    top: auto;
    transform: translateY(-4px);
}

.tp-floating--bottom-right .tp-switcher__menu.tp-menu--open,
.tp-floating--bottom-left .tp-switcher__menu.tp-menu--open {
    transform: translateY(0);
}

.tp-floating--bottom-right .tp-switcher__menu { right: 0; left: auto; }
.tp-floating--top-right .tp-switcher__menu    { right: 0; left: auto; }

.tp-floating .tp-switcher--dropdown .tp-switcher__toggle {
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

/* ──────────────────────────────────────────────────
   AI Sparkle & Tooltip
────────────────────────────────────────────────── */

/* Sparkle inside dropdown toggle button */
.tp-switcher__toggle .tp-ai-sparkle {
    font-size: 13px;
    line-height: 1;
    margin-left: 4px;
    opacity: 0.85;
    transition: transform .15s, opacity .15s;
    display: inline-block;
    vertical-align: middle;
    cursor: help;
}

/* Sparkle as last item in list style */
.tp-ai-sparkle-item {
    list-style: none !important;
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0;
}

.tp-ai-sparkle-item::before { display: none; }

/* Sparkle in flags row */
.tp-switcher__flags .tp-ai-sparkle {
    font-size: 18px;
    line-height: 1;
    opacity: 0.85;
    cursor: help;
    transition: transform .15s, opacity .15s;
    display: inline-flex;
    align-items: center;
}

/* Hover / focus states */
.tp-ai-sparkle:hover,
.tp-ai-sparkle:focus-visible {
    opacity: 1;
    transform: scale(1.2);
    outline: none;
}

/* Tooltip — positioned absolute from .tp-switcher (position:relative) */
.tp-ai-tooltip {
    position: absolute;
    z-index: 99999;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    background: #1f2937;
    color: #f9fafb;
    font-size: 12px;
    line-height: 1.55;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.22);
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s, visibility .15s;
}

.tp-ai-tooltip.tp-ai-tooltip--visible {
    opacity: 1;
    visibility: visible;
}

/* Arrow pointing down (tooltip above switcher) */
.tp-ai-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

/* Flip below when JS adds this class */
.tp-ai-tooltip.tp-ai-tooltip--below {
    bottom: auto;
    top: calc(100% + 10px);
}

.tp-ai-tooltip.tp-ai-tooltip--below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1f2937;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .tp-ai-tooltip {
        background: #374151;
    }
    .tp-ai-tooltip::after { border-top-color: #374151; }
    .tp-ai-tooltip.tp-ai-tooltip--below::after { border-bottom-color: #374151; border-top-color: transparent; }
}

/* ──────────────────────────────────────────────────
   hreflang tag in <head> (no visual styles needed,
   but ensure the switcher links have the right attribute)
────────────────────────────────────────────────── */

/* RTL support */
[dir="rtl"] .tp-switcher__menu {
    right: 0;
    left: auto;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .tp-switcher--dropdown .tp-switcher__toggle {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    .tp-switcher__menu {
        background: #1f2937;
        border-color: #374151;
    }
    .tp-switcher__item {
        color: #f9fafb;
    }
    .tp-switcher__item:hover {
        background: #374151;
    }
    .tp-switcher__item--active {
        background: #312e81;
        color: #c7d2fe;
    }
    .tp-switcher--list .tp-switcher__item {
        border-color: #374151;
        color: #f9fafb;
    }
    .tp-switcher--list .tp-switcher__item:hover {
        background: #374151;
        border-color: #6366f1;
        color: #c7d2fe;
    }
}
