/* ===== Taisiukas — маскот-помощник (inc/bot.php) ===== */

.twc-bot {
    --blue: var(--wd-primary-color, #2e6bc6);
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9995;
    font-family: var(--wd-text-font);
    font-size: 15px;
    line-height: 1.45;
    color: #14181f;
}

.twc-bot *,
.twc-bot *::before,
.twc-bot *::after {
    box-sizing: border-box;
}

/* ---------- Кнопка-маскот ---------- */
.twc-bot .twc-bot__launcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 16px 36px -12px rgba(27, 63, 128, .55), 0 0 0 1px rgba(16, 24, 40, .06);
    cursor: pointer;
    animation: twc-bot-float 4s ease-in-out infinite;
    transition: transform .2s ease;
}

.twc-bot .twc-bot__launcher:hover {
    background: #fff;
    transform: scale(1.06);
}

.twc-bot.is-open .twc-bot__launcher {
    animation: none;
}

.twc-face {
    display: block;
    width: 56px;
    height: 56px;
    overflow: visible;
}

.twc-face > * {
    transform-box: fill-box;
    transform-origin: center;
}

.twc-face__wrench {
    transform-origin: 30% 80%;
}

.twc-bot__dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 14px;
    height: 14px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #22c55e;
}

/* ---------- Эмоции (тамагочи) ----------
   По умолчанию: обычные глаза + улыбка. Каждое настроение включает свой набор. */
.twc-face .f {
    display: none;
}

.twc-face .e-normal,
.twc-face .m-smile {
    display: inline;
}

.twc-face .e-normal {
    transition: transform .25s ease;
    animation: twc-bot-blink 4.5s infinite;
}

/* Скрыть обычное лицо, если настроение рисует своё */
.twc-bot[data-mood="happy"] .e-normal,
.twc-bot[data-mood="love"] .e-normal,
.twc-bot[data-mood="sleepy"] .e-normal,
.twc-bot[data-mood="surprised"] .e-normal,
.twc-bot[data-mood="wave"] .e-normal,
.twc-bot[data-mood="fix"] .e-normal,
.twc-bot[data-mood="happy"] .m-smile,
.twc-bot[data-mood="love"] .m-smile,
.twc-bot[data-mood="wave"] .m-smile,
.twc-bot[data-mood="think"] .m-smile,
.twc-bot[data-mood="fix"] .m-smile,
.twc-bot[data-mood="sad"] .m-smile,
.twc-bot[data-mood="surprised"] .m-smile,
.twc-bot[data-mood="sleepy"] .m-smile {
    display: none;
}

/* 😊 happy */
.twc-bot[data-mood="happy"] .e-happy,
.twc-bot[data-mood="happy"] .m-big { display: inline; }
.twc-bot[data-mood="happy"] .twc-face { animation: twc-bot-hop .5s cubic-bezier(.34, 1.56, .64, 1); }

/* 😍 love */
.twc-bot[data-mood="love"] .e-love,
.twc-bot[data-mood="love"] .m-big { display: inline; }
.twc-bot[data-mood="love"] .e-love { animation: twc-bot-beat .6s ease-in-out infinite; }
.twc-bot[data-mood="love"] .twc-face { animation: twc-bot-hop .5s cubic-bezier(.34, 1.56, .64, 1) 2; }

/* 💭 think: смотрит вверх */
.twc-bot[data-mood="think"] .m-flat { display: inline; }
.twc-bot[data-mood="think"] .e-normal { transform: translate(1.4px, -1.8px); animation: none; }
.twc-bot[data-mood="think"] .twc-face { transform: rotate(-8deg); transition: transform .3s ease; }

/* 👀 look: смотрит вниз, на то, что вы печатаете */
.twc-bot[data-mood="look"] .e-normal { transform: translate(-1.2px, 1.8px); animation: none; }

/* 🔧 fix: прищурился и крутит ключ */
.twc-bot[data-mood="fix"] .e-focus,
.twc-bot[data-mood="fix"] .m-flat { display: inline; }
.twc-bot[data-mood="fix"] .twc-face__wrench { animation: twc-bot-wrench .25s ease-in-out infinite; }

/* 😢 sad: брови домиком, слеза */
.twc-bot[data-mood="sad"] .f-brows,
.twc-bot[data-mood="sad"] .m-frown,
.twc-bot[data-mood="sad"] .f-tear { display: inline; }
.twc-bot[data-mood="sad"] .e-normal { transform: translateY(1.2px) scale(.9); animation: none; }
.twc-bot[data-mood="sad"] .f-tear { animation: twc-bot-tear 1.2s ease-in infinite; }
.twc-bot[data-mood="sad"] .twc-face { transform: translateY(2px) rotate(4deg); transition: transform .3s ease; }

/* 😮 surprised */
.twc-bot[data-mood="surprised"] .e-wide,
.twc-bot[data-mood="surprised"] .m-o { display: inline; }
.twc-bot[data-mood="surprised"] .twc-face { animation: twc-bot-squish .5s ease; }

/* 😴 sleepy */
.twc-bot[data-mood="sleepy"] .e-closed,
.twc-bot[data-mood="sleepy"] .m-small,
.twc-bot[data-mood="sleepy"] .f-zzz { display: inline; }
.twc-bot[data-mood="sleepy"] .f-zzz text { animation: twc-bot-z 2.4s ease-in-out infinite; }
.twc-bot[data-mood="sleepy"] .f-zzz text:nth-child(2) { animation-delay: .4s; }
.twc-bot[data-mood="sleepy"] .f-zzz text:nth-child(3) { animation-delay: .8s; }
.twc-bot[data-mood="sleepy"] .twc-bot__launcher { animation: twc-bot-breathe 3s ease-in-out infinite; }
.twc-bot[data-mood="sleepy"] .twc-bot__dot { background: #f59e0b; }

/* 😉 wave: подмигивает и машет ключом */
.twc-bot[data-mood="wave"] .e-wink,
.twc-bot[data-mood="wave"] .m-big { display: inline; }
.twc-bot[data-mood="wave"] .twc-bot__launcher .twc-face { animation: twc-bot-wave .6s ease-in-out 2; }
.twc-bot[data-mood="wave"] .twc-face__wrench { animation: twc-bot-wrench .3s ease-in-out 4; }

/* Пузырь-эмоция над маскотом */
.twc-bot__emote {
    position: absolute;
    top: -14px;
    left: -10px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 16px -6px rgba(16, 24, 40, .4);
    font-size: 18px;
    line-height: 1;
    opacity: 0;
    transform: scale(.4) translateY(8px);
    transition: opacity .2s ease, transform .3s cubic-bezier(.34, 1.56, .64, 1);
    pointer-events: none;
}

.twc-bot__emote.is-on {
    opacity: 1;
    transform: none;
}

@keyframes twc-bot-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes twc-bot-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(.96, 1.03); }
}

@keyframes twc-bot-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(.1); }
}

@keyframes twc-bot-beat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

@keyframes twc-bot-tear {
    0% { transform: translateY(0); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateY(9px); opacity: 0; }
}

@keyframes twc-bot-z {
    0%, 100% { opacity: 0; transform: translateY(3px); }
    50% { opacity: 1; transform: translateY(-2px); }
}

@keyframes twc-bot-wave {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-12deg); }
    75% { transform: rotate(12deg); }
}

@keyframes twc-bot-wrench {
    0%, 100% { transform: rotate(0); }
    50% { transform: rotate(-35deg); }
}

@keyframes twc-bot-hop {
    0% { transform: translateY(0); }
    40% { transform: translateY(-8px) scale(1.05); }
    100% { transform: translateY(0); }
}

@keyframes twc-bot-squish {
    0%, 100% { transform: scale(1); }
    30% { transform: scale(1.15, .85); }
    60% { transform: scale(.92, 1.08); }
}

/* ---------- Подсказка ---------- */
.twc-bot__teaser {
    position: absolute;
    right: 0;
    bottom: 86px;
    width: 230px;
    padding: 14px 32px 14px 16px;
    border-radius: 18px 18px 4px 18px;
    background: #fff;
    box-shadow: 0 16px 40px -14px rgba(16, 24, 40, .35);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    animation: twc-bot-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}

.twc-bot__teaser[hidden],
.twc-bot__panel[hidden] {
    display: none;
}

.twc-bot .twc-bot__teaser-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f3f6;
    box-shadow: none;
    color: #5b6472;
    font-size: 15px;
    line-height: 22px;
    cursor: pointer;
}

@keyframes twc-bot-pop {
    from { opacity: 0; transform: translateY(10px) scale(.95); }
    to { opacity: 1; transform: none; }
}

/* ---------- Окно чата ---------- */
.twc-bot__panel {
    position: absolute;
    right: 0;
    bottom: 88px;
    display: flex;
    flex-direction: column;
    width: 370px;
    height: min(560px, calc(100vh - 140px));
    border-radius: 24px;
    background: #f6f8fb;
    box-shadow: 0 30px 70px -20px rgba(10, 18, 34, .45), 0 0 0 1px rgba(16, 24, 40, .06);
    overflow: hidden;
    animation: twc-bot-pop .3s cubic-bezier(.34, 1.4, .64, 1);
}

.twc-bot__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--blue) 0%, #1b3f80 100%);
    color: #fff;
}

.twc-bot .twc-bot__avatar {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 48px;
    height: 48px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: none;
    cursor: pointer;
}

.twc-bot__avatar .twc-face {
    width: 40px;
    height: 40px;
}

.twc-bot__who {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
}

.twc-bot__who b {
    display: block;
    font-family: var(--wd-title-font);
    font-size: 17px;
}

.twc-bot__who span {
    font-size: 12px;
    opacity: .8;
}

.twc-bot .twc-bot__close {
    width: 34px;
    height: 34px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    box-shadow: none;
    color: #fff;
    font-size: 22px;
    line-height: 34px;
    cursor: pointer;
}

.twc-bot .twc-bot__close:hover {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

.twc-bot__log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.twc-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 18px;
    animation: twc-bot-pop .25s ease;
    word-wrap: break-word;
}

.twc-msg--bot {
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.twc-msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    background: var(--blue);
    color: #fff;
}

.twc-msg--chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    padding: 0;
}

.twc-bot .twc-chipbtn {
    min-height: 0;
    margin: 0;
    padding: 8px 12px;
    border: 1.5px solid var(--blue);
    border-radius: 999px;
    background: #fff;
    box-shadow: none;
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.twc-bot .twc-chipbtn:hover {
    background: var(--blue);
    color: #fff;
}

.twc-msg small {
    display: block;
    margin-top: 6px;
    color: #6b7280;
    font-size: 12px;
}

.twc-bot__prices {
    margin: 8px 0 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.twc-bot__prices li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 0 !important;
    padding: 6px 0;
    border-top: 1px dashed rgba(16, 24, 40, .1);
    font-size: 14px;
}

.twc-bot__prices li::before {
    display: none !important;
}

.twc-bot__prices b {
    white-space: nowrap;
}

.twc-bot__prices em {
    color: var(--blue);
    font-size: 13px;
    font-style: normal;
    font-weight: 600;
}

.twc-bot .twc-bot__more {
    display: inline-block;
    margin-top: 4px;
    color: var(--blue);
    font-size: 13px;
    font-weight: 600;
}

.twc-bot .twc-bot__cta {
    display: block;
    width: 100%;
    min-height: 0;
    margin: 10px 0 0;
    padding: 11px 14px;
    border: 0;
    border-radius: 12px;
    background: var(--blue);
    box-shadow: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.twc-bot .twc-bot__cta:hover {
    background: var(--blue);
    color: #fff;
    filter: brightness(1.08);
}

.twc-bot .twc-bot__call {
    display: block;
    margin-top: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #e5f6ec;
    color: #1e7a3e;
    font-weight: 700;
    text-align: center;
}

.twc-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.twc-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa4b2;
    animation: twc-bot-dots 1s infinite;
}

.twc-typing i:nth-child(2) { animation-delay: .15s; }
.twc-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes twc-bot-dots {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.twc-bot__input {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border-top: 1px solid rgba(16, 24, 40, .06);
    background: #fff;
}

.twc-bot .twc-bot__input input {
    flex: 1;
    min-width: 0;
    height: 46px;
    margin: 0;
    padding: 0 14px;
    border: 1.5px solid rgba(16, 24, 40, .1);
    border-radius: 14px;
    background: #f6f8fb;
    box-shadow: none;
    color: #14181f;
    font-size: 16px;
}

.twc-bot .twc-bot__input input:focus {
    border-color: var(--blue);
    background: #fff;
    outline: none;
}

.twc-bot .twc-bot__input button {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--blue);
    box-shadow: none;
    color: #fff;
    cursor: pointer;
}

/* ---------- Телефон ---------- */
@media (max-width: 768px) {
    .twc-bot {
        right: 12px;
        bottom: 88px; /* над нижней панелью «Skambinti / Sužinoti kainą» */
    }

    .twc-bot .twc-bot__launcher {
        width: 60px;
        height: 60px;
        border-radius: 20px;
    }

    .twc-bot__launcher .twc-face {
        width: 46px;
        height: 46px;
    }

    .twc-bot__teaser {
        bottom: 72px;
    }

    .twc-bot.is-open {
        right: 0;
        left: 0;
        bottom: 0;
    }

    .twc-bot.is-open .twc-bot__launcher {
        display: none;
    }

    .twc-bot__panel {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: auto;
        height: 82vh;
        border-radius: 24px 24px 0 0;
    }

    html.twc-modal-open .twc-bot {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .twc-bot *,
    .twc-bot__launcher {
        animation: none !important;
    }
}

/* ===== Присутствие: реакции на то, что вы смотрите ===== */

/* Убираем обычное лицо для новых состояний */
.twc-bot[data-mood="broken"] .e-normal, .twc-bot[data-mood="broken"] .m-smile,
.twc-bot[data-mood="lowbat"] .e-normal, .twc-bot[data-mood="lowbat"] .m-smile,
.twc-bot[data-mood="charged"] .e-normal, .twc-bot[data-mood="charged"] .m-smile,
.twc-bot[data-mood="photo"] .e-normal, .twc-bot[data-mood="photo"] .m-smile {
    display: none;
}

/* 💥 broken: экран треснул */
.twc-bot[data-mood="broken"] .e-wide,
.twc-bot[data-mood="broken"] .m-o,
.twc-bot[data-mood="broken"] .f-crack { display: inline; }
.twc-bot[data-mood="broken"] .f-crack { animation: twc-bot-crack .25s ease-out; }
.twc-bot[data-mood="broken"] .twc-bot__launcher { animation: twc-bot-shake .4s ease-in-out 2; }

/* 🪫 lowbat: батарея садится */
.twc-bot[data-mood="lowbat"] .e-closed,
.twc-bot[data-mood="lowbat"] .m-small,
.twc-bot[data-mood="lowbat"] .f-batt { display: inline; }
.twc-bot[data-mood="lowbat"] .f-batt { animation: twc-bot-blinkred .6s steps(2) infinite; }
.twc-bot[data-mood="lowbat"] .twc-face { transform: translateY(3px) scaleY(.94); transition: transform .5s ease; filter: saturate(.4); }

/* ⚡ charged: зарядился */
.twc-bot[data-mood="charged"] .e-happy,
.twc-bot[data-mood="charged"] .m-big,
.twc-bot[data-mood="charged"] .f-bolt { display: inline; }
.twc-bot[data-mood="charged"] .f-bolt { animation: twc-bot-beat .5s ease-in-out infinite; }
.twc-bot[data-mood="charged"] .twc-face { animation: twc-bot-hop .45s cubic-bezier(.34, 1.56, .64, 1) 2; }

/* 📸 photo: вспышка */
.twc-bot[data-mood="photo"] .e-wink,
.twc-bot[data-mood="photo"] .m-big,
.twc-bot[data-mood="photo"] .f-flash { display: inline; }
.twc-bot[data-mood="photo"] .f-flash { animation: twc-bot-flash .7s ease-out forwards; }

/* 😎 spin: показывает спину — разворачивается */
.twc-bot[data-mood="spin"] .twc-bot__launcher .twc-face { animation: twc-bot-spin .9s ease-in-out; }

@keyframes twc-bot-crack {
    from { opacity: 0; stroke-dasharray: 0 30; }
    to { opacity: .75; stroke-dasharray: 30 0; }
}

@keyframes twc-bot-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px) rotate(-3deg); }
    40% { transform: translateX(4px) rotate(3deg); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes twc-bot-blinkred {
    0% { opacity: 1; }
    100% { opacity: .2; }
}

@keyframes twc-bot-flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes twc-bot-spin {
    from { transform: rotateY(0); }
    to { transform: rotateY(360deg); }
}

/* Облачко с репликой */
.twc-bot__say {
    position: absolute;
    right: 8px;
    bottom: 86px;
    width: max-content;
    max-width: 240px;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    background: #fff;
    box-shadow: 0 16px 40px -14px rgba(16, 24, 40, .35), 0 0 0 1px rgba(16, 24, 40, .05);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    animation: twc-bot-pop .3s cubic-bezier(.34, 1.56, .64, 1);
    pointer-events: none;
}

.twc-bot__say[hidden],
.twc-bot.is-open .twc-bot__say {
    display: none;
}

@media (max-width: 768px) {
    .twc-bot__say {
        bottom: 72px;
        max-width: calc(100vw - 40px);
    }
}
