/* TxChat pokalbio valdiklis */
.txchat {
    --txchat-red: #ff2424;
    --txchat-red-text: #d91a1a; /* tekstas ant / su raudona: kontrastas 5.1:1 (#ff2424 - tik 3.8:1, WCAG reikia 4.5) */
    --txchat-ink: #381a21;
    --txchat-bg: #fff;
    --txchat-soft: #f4f1f1;
    --txchat-head: #141414;
    font-family: 'Montserrat', sans-serif;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000000004;
}

/* testo režime šalia seno ChatBot burbulo (jis dešinėje) - kairėje */
.txchat--test {
    right: auto;
    left: 20px;
}

.txchat__launcher {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: var(--txchat-red-text);
    color: #fff;
    font: 600 14px/1 'Montserrat', sans-serif;
    box-shadow: 0 6px 20px rgba(56, 26, 33, .25);
    cursor: pointer;
}

.txchat__launcher:hover,
.txchat__launcher:focus-visible {
    background: #e01818;
}

.txchat.is-open .txchat__launcher {
    display: none;
}

.txchat__panel {
    position: relative;
    padding: 0;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: var(--txchat-bg);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(56, 26, 33, .28);
    overflow: hidden;
}

.txchat__panel[hidden] {
    display: none;
}

.txchat__head {
    position: static;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 12px 12px 16px;
    background: var(--txchat-head);
    color: #fff;
}

.txchat__title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}

.txchat__head button {
    border: 0;
    background: transparent;
    color: #fff;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 0;
}

.txchat__head button:hover,
.txchat__head button:focus-visible {
    background: rgba(255, 255, 255, .15);
}

.txchat__log {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain; /* slenkant iki galo nesislenka puslapis po pokalbiu (iPhone Safari) */
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--txchat-soft);
}

.txchat__msg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--txchat-ink);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.txchat__msg--bot {
    align-self: flex-start;
    background: #fff;
    border-bottom-left-radius: 4px;
}

.txchat__msg--user {
    align-self: flex-end;
    background: var(--txchat-red-text);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.txchat__msg a {
    color: var(--txchat-red-text);
    text-decoration: underline;
}

/* kliento žinutė raudonu fonu - nuoroda balta (raudona ant raudonos nesimatė) */
.txchat__msg--user a {
    color: #fff;
    overflow-wrap: anywhere;
}

.txchat__msg--error {
    background: #fdecee;
}

.txchat__msg--typing {
    color: #8a7a7e;
    font-style: italic;
}

.txchat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 12px 12px 8px;
    border-top: 1px solid #eadfe1;
}

.txchat__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* 16 px: mažesnį iPhone Safari priartina fokuse */
.txchat__input {
    flex: 1;
    resize: none;
    box-sizing: border-box;
    min-height: 76px;
    max-height: 160px;
    overflow-y: hidden;
    border: 1px solid #d9cdd0;
    border-radius: 10px;
    padding: 10px 12px;
    font: 16px/1.4 'Montserrat', sans-serif;
    color: var(--txchat-ink);
}

.txchat__input.is-full {
    overflow-y: auto;
}

.txchat__input:focus {
    /* rėmelis lieka visada; fokuse - raudonas (svetainės tema outline kartais nuima) */
    outline: none;
    border-color: var(--txchat-red-text);
    box-shadow: 0 0 0 1px var(--txchat-red-text);
}

.txchat__send {
    flex: none;
    border: 0;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    background: var(--txchat-red);
    color: #fff;
    cursor: pointer;
    line-height: 0;
}

.txchat__send:disabled {
    opacity: .5;
    cursor: default;
}

@media (max-width: 480px) {
    /* uždarytas - tik mygtuko dydžio (kitaip permatomas blokas per visą plotį dengia kitus mygtukus apačioje) */
    .txchat,
    .txchat--test {
        bottom: 12px;
    }

    .txchat {
        right: 12px;
    }

    .txchat--test {
        left: 12px;
        right: auto;
    }

    /* atidarytas - tarp matomo ekrano viršaus ir apačios (ne skaičiuojamu aukščiu: iPhone Safari juostos jį keičia,
       ir su 100svh antraštė su uždarymo mygtuku atsidūrė už ekrano ribų) */
    .txchat.is-open {
        top: 12px;
        bottom: 12px;
        left: 12px;
        right: 12px;
        display: flex;
        flex-direction: column;
    }

    .txchat.is-open:not(.txchat--test) .txchat__launcher {
        margin-left: auto;
    }

    .txchat__panel {
        width: 100%;
    }

    .txchat.is-open .txchat__panel {
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .txchat__launcher-text {
        display: none;
    }

    .txchat__tool {
        gap: 6px;
        padding: 10px 6px;
        font-size: 13px;
    }
}

/* Po forma: „Pamatykite, kaip atrodys jūsų kambaryje" + nuotrauka iš galerijos / telefono kamera */
.txchat__tools { padding: 0 12px 12px; }
.txchat__tools-label { margin: 0 0 8px; font-size: 13px; line-height: 1.4; color: #6f6266; }
.txchat__tools-row { display: flex; gap: 8px; }
.txchat__tool {
    flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0;
    padding: 10px 8px; border: 1px solid #d9cdd0; border-radius: 12px; background: var(--txchat-bg);
    color: var(--txchat-ink); font: 600 14px/1.2 'Montserrat', sans-serif; cursor: pointer;
}
.txchat__tool svg { flex: none; color: var(--txchat-red); }
/* didesnis telefono šriftas (prieinamumo nustatymas) - užrašas keliasi į antrą eilutę, ne už mygtuko krašto */
.txchat__tool span { min-width: 0; text-align: left; overflow-wrap: break-word; }
.txchat__tool:hover, .txchat__tool:focus-visible { border-color: var(--txchat-red-text); }
.txchat__tool.is-selected { border-color: var(--txchat-red-text); background: #fff1f1; }
/* kompiuteryje (pelė) kameros nėra - capture atidarytų tik failų langą */
@media (hover: hover) and (pointer: fine) {
    .txchat__camera { display: none; }
}

/* Pridėta nuotrauka prieš siunčiant: kortelė virš įvedimo lauko */
.txchat__form { flex-wrap: wrap; }
.txchat__attach {
    flex: 0 0 100%; position: relative; display: flex; align-items: center; gap: 12px; box-sizing: border-box;
    padding: 10px 36px 10px 10px; border: 1px solid #e6dfe1; border-radius: 12px; background: var(--txchat-soft);
}
.txchat__attach[hidden] { display: none; }
.txchat__attach img { display: block; flex: none; width: 96px; height: 72px; object-fit: cover; border-radius: 8px; }
.txchat__attach-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.35; color: #6f6266; }
.txchat__attach-text strong { font-size: 15px; color: var(--txchat-ink); }
.txchat__attach-remove {
    position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border: 0; border-radius: 50%;
    background: none; color: #4a3d41; font-size: 22px; line-height: 24px; padding: 0; cursor: pointer;
}
.txchat__img { display: block; max-width: 100%; border-radius: 10px; margin-bottom: 4px; cursor: zoom-in; }
/* fancyBox iš pokalbio - virš pokalbio lango (jo z-index 2000000004) */
.txchat-fancy.fancybox-container { z-index: 2000000010; }
.txchat__msg--render { max-width: 92%; }
/* AI vaizdas: tarpinis (neryškus) laukimo metu, po galutiniu - pastaba, kad tai iliustracija */
.txchat__img--partial { filter: blur(6px); opacity: .7; cursor: default; }
.txchat__msg--ai-wait { max-width: 92%; }
.txchat__msg--ai > div { font-size: 11px; line-height: 1.4; color: #8a7a7e; }
.txchat__download { display: inline-block; margin-top: 4px; font-size: 13px; font-weight: 600; }

/* ask_choice atsakymų mygtukai po asistento žinute */
.txchat__choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    max-width: 85%;
}

.txchat__choice {
    padding: 8px 12px;
    border: 1px solid var(--txchat-red-text);
    border-radius: 16px;
    background: var(--txchat-bg);
    color: var(--txchat-red-text);
    font: 500 13px/1.3 'Montserrat', sans-serif;
    text-align: left;
    cursor: pointer;
}

.txchat__choice:hover,
.txchat__choice:focus-visible {
    background: var(--txchat-red-text);
    color: #fff;
}

/* atidarytas pokalbis telefone - puslapis po juo nesislenka (JS uždeda klasę ant <html>) */
html.txchat-lock,
html.txchat-lock body {
    overflow: hidden;
    overscroll-behavior: none;
}

/* Tawk.to (įkeliamas header.tpl) - paslėptas nuo pat pradžių, kad nesumirksėtų; rodomas tik kai pokalbis perdavė vadybininkui
   arba vadybininko pokalbis jau vyksta (JS uždeda html.txchat-tawk). Tawk konteinerio id atsitiktinis, jo display - inline !important. */
html:not(.txchat-tawk) body > div:has(> #min-widget),
html:not(.txchat-tawk) #min-widget,
html:not(.txchat-tawk) #max-widget,
html:not(.txchat-tawk) #message-preview,
html:not(.txchat-tawk) #chat-bubble,
html:not(.txchat-tawk) #branding-widget {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* vadybininko pokalbis (Tawk): langas atidarytas - mūsų mygtuko nėra; sumažintas - mūsų mygtukas virš Tawk juostos */
html.txchat-tawk-max .txchat:not(.is-open) .txchat__launcher {
    display: none;
}

html.txchat-tawk:not(.txchat-tawk-max) .txchat:not(.is-open) {
    bottom: 96px;
}
