/* ═══════════════════════════════════════════════════════════════════
   Flavor Translate — Frontend Widget v6
   Professional design — SVG globe, Google-brand colours
   All .notranslate elements are protected from GT translation
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --ft-blue:    #1a73e8;
    --ft-blue2:   #4285f4;
    --ft-green:   #34a853;
    --ft-yellow:  #fbbc04;
    --ft-red:     #ea4335;
    --ft-dark:    #202124;
    --ft-mid:     #5f6368;
    --ft-light:   #f8f9fa;
    --ft-border:  rgba(0,0,0,0.10);
    --ft-radius:  16px;
    --ft-shadow:  0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
    --ft-shadow2: 0 8px 28px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.07);
}

/* ── Container ──────────────────────────────────────────────────── */
.ft-widget-wrap {
    font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    color-scheme: light only;
}

/* ── Floating positions ─────────────────────────────────────────── */
.ft-position-bottom_right { position: fixed; bottom: 24px; right: 24px; z-index: 99999; }
.ft-position-bottom_left  { position: fixed; bottom: 24px; left:  24px; z-index: 99999; }
.ft-position-top_right    { position: fixed; top:    24px; right: 24px; z-index: 99999; }
.ft-position-top_left     { position: fixed; top:    24px; left:  24px; z-index: 99999; }
.ft-position-inline       { position: relative; display: inline-block; }
.ft-position-bottom_right,
.ft-position-bottom_left,
.ft-position-top_right,
.ft-position-top_left     { pointer-events: all; isolation: isolate; }

.ft-switcher { position: relative; display: inline-flex; }

/* ═══════════════════════════════════════════════════════════════════
   TRIGGER BUTTON
   Professional gradient with SVG globe — not an emoji
   ═══════════════════════════════════════════════════════════════════ */
.ft-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    background: linear-gradient(135deg, var(--ft-blue) 0%, var(--ft-blue2) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
    letter-spacing: 0.01em;
    transition: box-shadow 0.18s, transform 0.14s, background 0.18s;
    box-shadow: 0 2px 10px rgba(26,115,232,0.38), 0 1px 3px rgba(26,115,232,0.2);
}
.ft-trigger:hover {
    background: linear-gradient(135deg, #1557b0 0%, var(--ft-blue) 100%);
    box-shadow: 0 4px 18px rgba(26,115,232,0.48), 0 2px 5px rgba(26,115,232,0.25);
    transform: translateY(-1px);
}
.ft-trigger:active { transform: translateY(0); }
.ft-trigger svg { flex-shrink: 0; }

/* Style variants */
.ft-style-pill    .ft-trigger { border-radius: 50px; }
.ft-style-rounded .ft-trigger { border-radius: 12px; }
.ft-style-square  .ft-trigger { border-radius: 6px; }

/* ── Floating bubble ── shows current language flag + code ──────── */
.ft-style-floating .ft-trigger {
    border-radius: 50%;
    width: 62px;
    height: 62px;
    padding: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.18),
                inset 0 1px 0 rgba(255,255,255,0.10);
    overflow: hidden;
}
.ft-style-floating .ft-trigger:hover {
    background: linear-gradient(145deg, #334155 0%, #1e293b 100%);
    box-shadow: 0 6px 26px rgba(0,0,0,0.34), 0 3px 10px rgba(0,0,0,0.22),
                inset 0 1px 0 rgba(255,255,255,0.14);
    transform: translateY(-2px) scale(1.05);
}

/* Flag image inside bubble */
.ft-bubble-flag {
    width: 36px !important;
    height: 27px !important;
    border-radius: 4px;
    object-fit: cover;
    display: block;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    flex-shrink: 0;
}

/* Language code badge below flag */
.ft-bubble-code {
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
    display: block;
}

.ft-style-floating .ft-trigger-label,
.ft-style-floating .ft-trigger-globe,
.ft-style-floating .ft-arrow { display: none; }

/* Inline flag in pill/rounded/square trigger */
.ft-trigger-flag {
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.3);
}

/* Globe icon wrapper */
.ft-trigger-globe { display: flex; align-items: center; }

/* Arrow */
.ft-arrow {
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid rgba(255,255,255,0.85);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.ft-switcher.open .ft-arrow { transform: rotate(180deg); }

/* ═══════════════════════════════════════════════════════════════════
   DROPDOWN PANEL
   ═══════════════════════════════════════════════════════════════════ */
.ft-dropdown {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    background: #fff;
    border: 1px solid var(--ft-border);
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow2);
    min-width: 246px;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
    pointer-events: none;
}

/* Rainbow top stripe — Google 4-colour */
.ft-dropdown::before {
    content: '';
    flex-shrink: 0;
    display: block;
    height: 4px;
    border-radius: var(--ft-radius) var(--ft-radius) 0 0;
    background: linear-gradient(90deg,
        var(--ft-blue) 0 25%,
        var(--ft-red) 25% 50%,
        var(--ft-yellow) 50% 75%,
        var(--ft-green) 75% 100%);
}

/* Top-widget dropdown opens downward */
.ft-position-top_right .ft-dropdown,
.ft-position-top_left  .ft-dropdown {
    bottom: auto; top: calc(100% + 12px);
    transform: translateY(-8px) scale(0.97);
    transform-origin: top right;
}
.ft-position-top_left    .ft-dropdown { transform-origin: top left; right: auto; left: 0; }
.ft-position-bottom_left .ft-dropdown { right: auto; left: 0; }

.ft-switcher.open .ft-dropdown {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Panel header — "Translate" label */
.ft-dropdown-header {
    padding: 10px 14px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ft-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
    user-select: none;
}

/* Search */
.ft-dropdown-search {
    padding: 6px 10px 8px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.ft-dropdown-search input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
    background: var(--ft-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 9px center;
    box-sizing: border-box;
    transition: border-color 0.14s, box-shadow 0.14s;
    color: var(--ft-dark);
}
.ft-dropdown-search input:focus {
    border-color: var(--ft-blue);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.14);
    background-color: #fff;
}

/* Language list */
.ft-lang-list {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px;
    flex: 1;
}
.ft-lang-list::-webkit-scrollbar { width: 4px; }
.ft-lang-list::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 2px; }

.ft-lang-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.09s;
    color: var(--ft-dark);
    text-decoration: none;
    user-select: none;
}
.ft-lang-option:hover  { background: #f1f3f4; }
.ft-lang-option:focus  { outline: 2px solid var(--ft-blue); outline-offset: -2px; }
.ft-lang-option.active { background: #e8f0fe; color: #1557b0; font-weight: 600; }

.ft-flag-icon {
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
    display: block;
    object-fit: cover;
}
.ft-lang-option-name { flex: 1; font-size: 13.5px; }

/* Quality dots */
.ft-qdot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.75;
}
.ft-q-excellent { background: var(--ft-green); }
.ft-q-good      { background: var(--ft-yellow); }
.ft-q-fair      { background: #ff6d00; }
.ft-q-poor      { background: var(--ft-red); }

.ft-check {
    color: var(--ft-blue); font-size: 14px; font-weight: 700;
    opacity: 0; transition: opacity 0.1s; margin-left: 2px;
}
.ft-lang-option.active .ft-check { opacity: 1; }

/* Powered-by */
.ft-powered {
    padding: 7px 14px;
    text-align: center;
    font-size: 10px;
    color: #9aa0a6;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    user-select: none;
}
.ft-powered-link { text-decoration: none; }
.ft-powered-logo b { font-style: normal; font-weight: 700; font-size: 10px; }
.ft-powered-logo .c1 { color: var(--ft-blue2); }
.ft-powered-logo .c2 { color: var(--ft-red); }
.ft-powered-logo .c3 { color: var(--ft-yellow); }
.ft-powered-logo .c4 { color: var(--ft-blue2); }
.ft-powered-logo .c5 { color: var(--ft-green); }
.ft-powered-logo .c6 { color: var(--ft-red); }
.ft-powered-logo .c7 { color: var(--ft-blue2); }

/* ═══════════════════════════════════════════════════════════════════
   FLAGS-ONLY BAR
   ═══════════════════════════════════════════════════════════════════ */
.ft-flags-bar {
    display: flex; flex-wrap: wrap; gap: 5px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--ft-border);
    border-top: 4px solid var(--ft-blue);
    border-radius: 14px;
    box-shadow: var(--ft-shadow);
}
.ft-flag-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 26px;
    border-radius: 5px;
    border: 2px solid transparent;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    background: transparent;
    transition: transform 0.13s, border-color 0.13s, box-shadow 0.13s;
}
.ft-flag-btn:hover  { transform: scale(1.12) translateY(-1px); border-color: var(--ft-blue); box-shadow: 0 2px 8px rgba(26,115,232,0.28); }
.ft-flag-btn:focus  { outline: 2px solid var(--ft-blue); outline-offset: 2px; }
.ft-flag-btn.active { border-color: var(--ft-blue); box-shadow: 0 0 0 3px rgba(26,115,232,0.22); }
.ft-flag-btn img    { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ═══════════════════════════════════════════════════════════════════
   POPUP MODE
   ═══════════════════════════════════════════════════════════════════ */
.ft-popup-trigger {
    /* Uses .ft-style-floating styles — circle with SVG globe */
}

.ft-popup-overlay {
    position: fixed; inset: 0;
    background: rgba(32,33,36,0.48);
    z-index: 999997;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.ft-popup-overlay.visible { opacity: 1; visibility: visible; }

.ft-popup-panel {
    position: fixed; top: 50%; left: 50%;
    z-index: 999998;
    background: #fff;
    border-radius: 20px;
    width: 90%; max-width: 580px; max-height: 76vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 56px rgba(0,0,0,0.20), 0 4px 14px rgba(0,0,0,0.09);
    opacity: 0; visibility: hidden;
    transform: translate(-50%, -48%) scale(0.95);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.ft-popup-panel.visible {
    opacity: 1; visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}
/* Rainbow top bar */
.ft-popup-panel::before {
    content: '';
    display: block; height: 5px; flex-shrink: 0;
    background: linear-gradient(90deg,
        var(--ft-blue) 0 25%, var(--ft-red) 25% 50%,
        var(--ft-yellow) 50% 75%, var(--ft-green) 75% 100%);
    border-radius: 20px 20px 0 0;
}
.ft-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px 10px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.ft-popup-header h3 {
    font-size: 16px; font-weight: 700; margin: 0; color: var(--ft-dark);
    display: flex; align-items: center; gap: 8px;
}
.ft-popup-header h3::before { content: ''; display: inline-block; width: 20px; height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231a73e8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/%3E%3C/svg%3E");
    background-size: contain; background-repeat: no-repeat; }
.ft-popup-close {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: #f1f3f4; cursor: pointer; font-size: 18px; color: var(--ft-mid);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.13s;
}
.ft-popup-close:hover { background: #e8eaed; color: var(--ft-dark); }

.ft-popup-search {
    padding: 10px 16px; border-bottom: 1px solid #f0f0f0; flex-shrink: 0;
}
.ft-popup-search input {
    width: 100%; padding: 9px 12px 9px 34px;
    border: 1px solid #e0e0e0; border-radius: 24px; font-size: 14px;
    outline: none; background: var(--ft-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
    box-sizing: border-box; color: var(--ft-dark);
    transition: border-color 0.14s, box-shadow 0.14s;
}
.ft-popup-search input:focus {
    border-color: var(--ft-blue); background-color: #fff;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.14);
}

.ft-popup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 2px; padding: 10px 12px;
    overflow-y: auto; flex: 1;
    overscroll-behavior: contain;
}
.ft-popup-grid::-webkit-scrollbar { width: 5px; }
.ft-popup-grid::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 3px; }

.ft-popup-lang {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px; border-radius: 10px;
    cursor: pointer; font-size: 13px; color: var(--ft-dark);
    text-decoration: none; transition: background 0.09s;
    user-select: none;
}
.ft-popup-lang:hover  { background: #f1f3f4; }
.ft-popup-lang:focus  { outline: 2px solid var(--ft-blue); outline-offset: -2px; }
.ft-popup-lang.active { background: #e8f0fe; color: #1557b0; font-weight: 600; }
.ft-popup-lang img    { width: 24px; height: 18px; border-radius: 3px; object-fit: cover; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(0,0,0,0.08); }

/* ═══════════════════════════════════════════════════════════════════
   LOADING BAR — rainbow stripe across top of page
   ═══════════════════════════════════════════════════════════════════ */
.ft-loading-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    z-index: 999999; display: none;
    background: linear-gradient(90deg,
        var(--ft-blue) 0%, var(--ft-red) 25%,
        var(--ft-yellow) 50%, var(--ft-green) 75%, var(--ft-blue) 100%);
    background-size: 200% 100%;
    animation: ft-slide 1.4s linear infinite;
}
.ft-loading-bar.active { display: block; }
@keyframes ft-slide { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ═══════════════════════════════════════════════════════════════════
   RTL / A11Y / RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
[dir="rtl"] .ft-dropdown   { right: auto; left: 0; }
[dir="rtl"] .ft-lang-list  { direction: rtl; }
[dir="rtl"] .ft-check      { margin-right: auto; margin-left: 0; }

@media (max-width: 480px) {
    .ft-position-bottom_right { bottom: 14px; right: 14px; }
    .ft-position-bottom_left  { bottom: 14px; left: 14px; }
    .ft-dropdown  { min-width: 210px; max-height: 340px; }
    .ft-popup-panel { border-radius: 16px; }
    .ft-popup-grid  { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .ft-trigger { padding: 8px 13px; font-size: 13px; }
    .ft-style-floating .ft-trigger { width: 50px; height: 50px; }
}

@media (prefers-reduced-motion: reduce) {
    .ft-dropdown, .ft-popup-overlay, .ft-popup-panel,
    .ft-trigger, .ft-lang-option, .ft-flag-btn,
    .ft-loading-bar { transition: none !important; animation: none !important; }
}
