/* ═══════════════ TELEGRAM WIDGET — LEVITATION ═══════════════ */
.tg-widget {
    position: fixed;
    bottom: 20px;
    right: 30px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;

    /* Entrance: slide in from right */
    animation: tgWidgetEntrance 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.8s both;
}

/* ─── CHAT BUBBLE ─── */
.tg-message {
    background: white;
    padding: 16px 24px;
    border-radius: 20px;
    border-bottom-right-radius: 4px;

    font-family: var(--ff-body);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--clr-text);

    width: max-content;
    max-width: 320px;
    white-space: nowrap;

    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;

    border: 2px solid transparent;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);

    /* Hidden initially, then fade in + start levitating */
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    animation:
        tgBubbleAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 1.8s forwards,
        tgBubbleLevitate 4s ease-in-out 2.5s infinite;
}

/* Glow Effect via Opacity (GPU Friendly) */
.tg-message::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 20px;
    border-bottom-right-radius: 4px;
    border: 2px solid rgba(42, 171, 238, 0.15);
    box-shadow: 0 12px 36px rgba(42, 171, 238, 0.12),
        0 0 16px rgba(42, 171, 238, 0.06);
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    animation: tgGlowOpacity 5s ease-in-out 3s infinite;
}

/* Bubble tail */
.tg-message::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 0;
    width: 20px;
    height: 20px;
    background: white;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    border-radius: 0 0 4px 0;
}

/* ─── MAIN BUTTON ─── */
.tg-button {
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    border-radius: 50px;
    font-family: var(--ff-body);
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    position: relative;
    overflow: visible;

    box-shadow: 0 6px 20px rgba(42, 171, 238, 0.35);

    /* Levitation + heartbeat micro-pulse */
    animation: tgButtonLevitate 4s ease-in-out 0.6s infinite,
        tgHeartbeat 2.5s ease-in-out 2s infinite;

    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.4s ease;
}

/* Soft inner pulse ring */
.tg-button::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50px;
    border: 2px solid rgba(42, 171, 238, 0.4);
    animation: tgPulseRing 3s ease-in-out infinite;
    pointer-events: none;
}

/* Radar expand wave */
.tg-button::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50px;
    border: 2px solid rgba(42, 171, 238, 0.5);
    animation: tgRadarWave 3s ease-out 2s infinite;
    pointer-events: none;
}

.tg-button:hover {
    transform: translateY(-8px) scale(1.08);
    box-shadow: 0 16px 40px rgba(42, 171, 238, 0.5);
    color: white;
}

.tg-button:hover::before,
.tg-button:hover::after {
    animation-play-state: paused;
    opacity: 0;
}

.tg-button svg {
    width: 26px;
    height: 26px;
    z-index: 1;
}

.tg-button span {
    z-index: 1;
}

/* ─── FLOATING SHADOW (under the whole widget) ─── */
.tg-widget::after {
    content: '';
    position: absolute;
    bottom: -16px;
    right: 20px;
    width: 120px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(42, 171, 238, 0.18), transparent 70%);
    animation: tgShadowPulse 4s ease-in-out 0.6s infinite;
    pointer-events: none;
}

/* ═══════════════ KEYFRAMES ═══════════════ */

/* Entrance */
@keyframes tgWidgetEntrance {
    from {
        opacity: 0;
        transform: translateX(60px) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

/* Bubble appear — pops in with spring */
@keyframes tgBubbleAppear {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bubble levitation — gentle float */
@keyframes tgBubbleLevitate {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Bubble glow — soft breathing border highlight */
/* Bubble glow — soft breathing border highlight (Opacity Optimized) */
@keyframes tgGlowOpacity {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

/* Button levitation — offset from bubble */
@keyframes tgButtonLevitate {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-7px);
    }
}

/* Pulse ring around button */
@keyframes tgPulseRing {

    0%,
    100% {
        transform: scale(1);
        opacity: 0;
    }

    20% {
        transform: scale(1);
        opacity: 0.6;
    }

    80% {
        transform: scale(1.15);
        opacity: 0;
    }
}

/* Radar expanding wave */
@keyframes tgRadarWave {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Heartbeat micro-pulse */
@keyframes tgHeartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    14% {
        transform: scale(1.04);
    }

    28% {
        transform: scale(1);
    }

    42% {
        transform: scale(1.02);
    }

    56% {
        transform: scale(1);
    }
}

/* Shadow under widget */
@keyframes tgShadowPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(0.7);
        opacity: 0.2;
    }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
    .tg-widget {
        bottom: 90px;
        right: 20px;
        align-items: flex-end;
    }

    .tg-message {
        font-size: 1rem;
        padding: 12px 18px;
        max-width: 85vw;
        width: auto;
        white-space: normal;
    }

    .tg-button {
        padding: 12px 24px;
        font-size: 1rem;
    }
}