/* ============================================================================
   3PAY.SHOP — I18N LANGUAGE SWITCHER & UNIVERSAL «🌐 TRANSLATE» / «✨ UA|EN» UI
   Package: ?v=210_4a
   Dark + Light theme support, mobile responsive 360px+, zero duplicate selectors.
   ============================================================================ */

/* ---- 1. Bilingual Language Switcher in #header-params-popover & Mobile Sidebar ---- */
.hdr-params-row-lang {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.hdr-lang-switch-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
}

.hdr-lang-opt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.hdr-lang-opt-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.hdr-lang-opt-btn.is-active {
    background: rgba(14, 165, 233, 0.18);
    border-color: rgba(56, 189, 248, 0.72);
    color: #e0f2fe;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28);
}

.hdr-lang-opt-fiat {
    font-size: 0.66rem;
    font-weight: 700;
    opacity: 0.82;
}

.sidebar-lang-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
}

/* ---- 2. Universal «🌐 Translate» Trigger & Collapsible Panel ---- */
.tr3-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    max-width: 100%;
}

.tr3-wrap.is-compact {
    margin-top: 4px;
}

.tr3-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.34);
    background: rgba(15, 23, 42, 0.65);
    color: #7dd3fc;
    font-size: 0.73rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.tr3-trigger-btn:hover,
.tr3-trigger-btn.is-open {
    background: rgba(14, 165, 233, 0.22);
    border-color: rgba(56, 189, 248, 0.75);
    color: #f0f9ff;
}

.tr3-trigger-btn.is-compact {
    padding: 3px 7px;
    font-size: 0.76rem;
}

.tr3-panel {
    width: 100%;
    max-width: 100%;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid rgba(56, 189, 248, 0.32);
    background: rgba(9, 15, 30, 0.88);
    color: #e2e8f0;
    font-size: 0.84rem;
    line-height: 1.48;
    box-sizing: border-box;
    word-break: break-word;
}

.tr3-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.tr3-panel-label {
    font-size: 0.73rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 0.01em;
}

.tr3-mini-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tr3-mini-tab {
    padding: 2px 7px;
    border-radius: 7px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.6);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    line-height: 1.25;
}

.tr3-mini-tab:hover {
    color: #e2e8f0;
    border-color: rgba(56, 189, 248, 0.55);
}

.tr3-mini-tab.is-active {
    background: rgba(14, 165, 233, 0.25);
    border-color: rgba(56, 189, 248, 0.82);
    color: #f0f9ff;
}

.tr3-panel-text {
    white-space: pre-wrap;
    color: inherit;
}

.tr3-panel-text.is-loading {
    opacity: 0.75;
    font-style: italic;
}

.tr3-panel-text.is-error {
    color: #fca5a5;
}

.tr3-panel.is-auto {
    border-left: 3px solid #38bdf8;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.14), rgba(16, 185, 129, 0.08));
}

.ord-chat-draft-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 2px 6px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* ---- 3. Compact «🌐» Button & Inline Panel inside Big Olezhka Thought Bubble ---- */
.tr3-thought-btn {
    position: absolute;
    top: 8px;
    right: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(15, 23, 42, 0.68);
    color: #bae6fd;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.tr3-thought-btn:hover,
.tr3-thought-btn.is-open {
    background: rgba(14, 165, 233, 0.28);
    border-color: rgba(56, 189, 248, 0.82);
}

.tr3-thought-panel {
    flex: 1 0 100%;
    width: 100%;
    margin-top: 8px;
    padding: 7px 9px;
    border-radius: 10px;
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(7, 13, 27, 0.92);
    color: #e2e8f0;
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: left;
    max-height: 118px;
    overflow-y: auto;
    scrollbar-width: thin;
}

@media (max-width: 680px) {
    .tr3-thought-btn {
        top: 5px;
        right: 30px;
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }

    .tr3-thought-panel {
        max-height: 92px;
        font-size: 0.74rem;
    }
}

/* ---- 4. Draft Input Helper «✨ UA | EN» ---- */
.tr3-draft-tools {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.tr3-draft-bar-floating {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px 2px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.tr3-draft-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.5);
    background: rgba(14, 165, 233, 0.16);
    color: #bae6fd;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}

.tr3-draft-btn:hover:not(:disabled) {
    background: rgba(14, 165, 233, 0.3);
    border-color: rgba(56, 189, 248, 0.9);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(14, 165, 233, 0.25);
}

.tr3-draft-btn:disabled,
.tr3-draft-btn.is-busy {
    opacity: 0.78;
    cursor: wait;
    animation: tr3DraftPulse 1.1s ease-in-out infinite;
}

@keyframes tr3DraftPulse {
    0%, 100% {
        opacity: 0.95;
    }
    50% {
        opacity: 0.52;
    }
}

/* ---- 5. Light Theme Overrides ---- */
html[data-theme="light"] .hdr-lang-opt-btn {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

html[data-theme="light"] .hdr-lang-opt-btn.is-active {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0369a1;
    box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.22);
}

html[data-theme="light"] .tr3-trigger-btn {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}

html[data-theme="light"] .tr3-trigger-btn:hover,
html[data-theme="light"] .tr3-trigger-btn.is-open {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0c4a6e;
}

html[data-theme="light"] .tr3-panel,
html[data-theme="light"] .tr3-thought-panel {
    background: #f8fafc;
    border-color: #bae6fd;
    color: #0f172a;
}

html[data-theme="light"] .tr3-panel.is-auto {
    border-left: 3px solid #0284c7;
    background: linear-gradient(135deg, #f0f9ff, #ecfdf5);
}

html[data-theme="light"] .tr3-panel-label {
    color: #0284c7;
}

html[data-theme="light"] .tr3-mini-tab {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #475569;
}

html[data-theme="light"] .tr3-mini-tab.is-active {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0369a1;
}

html[data-theme="light"] .tr3-panel-text.is-error {
    color: #b91c1c;
}

html[data-theme="light"] .tr3-thought-btn {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}

html[data-theme="light"] .tr3-draft-btn {
    background: #e0f2fe;
    border-color: #38bdf8;
    color: #0369a1;
    box-shadow: 0 1px 2px rgba(2, 132, 199, 0.12);
}

html[data-theme="light"] .tr3-draft-btn:hover:not(:disabled) {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
}

/* ---- 6. Mobile Responsive (360px+) ---- */
@media (max-width: 640px) {
    .hdr-lang-opt-btn {
        font-size: 0.71rem;
        padding: 7px 6px;
    }

    .tr3-panel {
        padding: 8px 9px;
        font-size: 0.8rem;
    }

    .tr3-draft-btn {
        padding: 3px 7px;
        font-size: 0.69rem;
    }
}

@media (max-width: 420px) {
    .hdr-lang-switch-group {
        grid-template-columns: 1fr;
    }

    .tr3-panel-head {
        gap: 6px;
    }
}
