/* AI-консультант: плавающий виджет (правый нижний угол) + модалка.
   Левый нижний угол занят круглой кнопкой отзыва (.popup-form) — не пересекаемся. */

/* ===== ВРЕМЕННО СКРЫТ (2026-07-29, по просьбе клиента) =====
   Чтобы показать виджет обратно — удалить ТОЛЬКО правило ниже.
   Альтернатива без правки кода: «Додаткові налаштування» → выключатель «Показувати віджет». */
.tg-ai { display: none !important; }
/* ===== конец временного скрытия ===== */

.tg-ai {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998; /* под модалкой (9999) и под .tg-popup-overlay CF7 (999999) */
}

.tg-ai__trigger {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
    display: block;
    line-height: 0;
}

/* --- ПК: карточка с аватаром --- */
.tg-ai__card {
    position: relative;
    display: block;
    width: 120px;
    height: 170px;
    border-radius: 16px;
    overflow: hidden;
    background: #1a1a1a;
    box-shadow: 0 10px 30px rgba(17, 24, 28, .28);
    border: 3px solid #fff;
    transition: transform .22s ease, box-shadow .22s ease;
}

.tg-ai__trigger:hover .tg-ai__card {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 16px 38px rgba(17, 24, 28, .36);
}

.tg-ai__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tg-ai__label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 8px 9px;
    background: linear-gradient(to top, rgba(0, 0, 0, .82) 45%, transparent);
    color: #fff;
    font-size: 11.5px;
    line-height: 1.25;
    text-align: center;
    letter-spacing: .1px;
}

/* --- Мобильные: облачко --- */
.tg-ai__bubble { display: none; }

/* --- Модалка --- */
.tg-ai-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tg-ai-modal[hidden] { display: none; }

.tg-ai-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 28, .68);
}

.tg-ai-modal__box {
    position: relative;
    width: min(980px, 100%);
    max-height: calc(100vh - 40px);
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.tg-ai-modal__frame,
.tg-ai-modal__frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.tg-ai-modal__close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 38px;
    height: 38px;
    padding: 0;
    background: rgba(0, 0, 0, .5);
    border: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 26px;
    line-height: 34px;
    cursor: pointer;
    transition: background .2s ease;
}

.tg-ai-modal__close:hover { background: var(--blog-main-color, #e60000); }

body.tg-ai-open { overflow: hidden; }

@media screen and (max-width: 767px) {
    .tg-ai {
        right: 14px;
        bottom: 78px; /* выше круглой кнопки/панелей */
    }

    .tg-ai__card { display: none; }

    .tg-ai__bubble {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 10px 15px;
        background: #fff;
        border: 1px solid #e8e8ee;
        border-radius: 999px;
        box-shadow: 0 6px 18px rgba(17, 24, 28, .18);
        color: var(--blog-main-color, #e60000);
        font-size: 13.5px;
        font-weight: 600;
        line-height: 1;
        white-space: nowrap;
    }

    .tg-ai__trigger:active .tg-ai__bubble { transform: scale(.97); }

    .tg-ai-modal { padding: 10px; }

    /* окно 9:16 под вертикальный эмбед — иначе снизу остаётся белый фон его страницы;
       ширина ограничена высотой экрана, чтобы модалка всегда влезала целиком */
    .tg-ai-modal__box {
        aspect-ratio: 9 / 16;
        width: min(100%, calc((100vh - 20px) * 9 / 16));
        height: auto;
        max-height: calc(100vh - 20px);
    }
}
