/**
 * Telegram Bot Footer Circle Styles
 * تنسيقات دائرة بوت تليجرام في الفوتر
 */

/* =============================================
   Variables
   ============================================= */
:root {
    --telegram-blue: #0088cc;
    --telegram-blue-light: #00a1e0;
    --linkedin-blue: #0077B5;
    --online-green: #22c55e;
    --circle-size: 56px;
    --bubble-width: 280px;
}

/* =============================================
   Footer with Telegram Modifications
   ============================================= */
.footer--with-telegram {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
}

.footer--with-telegram::before {
    content: '';
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 26px;
    background: var(--white, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom: none;
    border-radius: 35px 35px 0 0;
}

/* =============================================
   Telegram Circle
   ============================================= */
.telegram-circle {
    position: absolute;
    top: calc(-1 * var(--circle-size) / 2 - 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.telegram-circle__link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--circle-size);
    height: var(--circle-size);
    border-radius: 50%;
    background: var(--white, #fff);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    overflow: visible;
}

.telegram-circle__link:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

.telegram-circle__logo {
    width: var(--circle-size);
    height: var(--circle-size);
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 2;
}

/* Online Badge - Top Right */
.telegram-circle__online-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--online-green);
    border-radius: 50%;
    z-index: 5;
    animation: pulseOnline 2s ease-in-out infinite;
}

@keyframes pulseOnline {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
    }
}

/* Telegram Badge - Bottom Center */
.telegram-circle__telegram-badge {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: var(--white, #fff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    color: var(--telegram-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

.telegram-circle__telegram-badge svg {
    width: 14px;
    height: 14px;
}

.telegram-circle.is-speaking .telegram-circle__telegram-badge {
    animation: telegramPulse 0.5s ease-in-out;
}

@keyframes telegramPulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.15);
    }
}

/* Shimmer Effect */
.telegram-circle__shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    z-index: 3;
    border-radius: 50%;
    pointer-events: none;
}

.telegram-circle.is-shimmering .telegram-circle__shimmer {
    animation: shimmer 0.8s ease-in-out;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* =============================================
   Speech Bubble
   ============================================= */
.telegram-bubble {
    position: absolute;
    bottom: calc(var(--circle-size) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: var(--bubble-width);
    background: var(--white, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    padding: 14px 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 101;
}

.telegram-bubble.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Close Button */
.telegram-bubble__close {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.telegram-bubble__close:hover {
    background: #f5f5f5;
    color: #666;
}

/* Content Link */
.telegram-bubble__content {
    display: block;
    text-decoration: none;
    color: inherit;
}

.telegram-bubble__content:hover .telegram-bubble__question {
    color: var(--telegram-blue);
}

/* Question Text */
.telegram-bubble__question {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: #333;
    line-height: 1.5;
    margin-bottom: 10px;
    transition: color 0.2s ease;
    padding-left: 26px;
}

/* Divider */
.telegram-bubble__divider {
    display: block;
    height: 1px;
    background: #eee;
    margin-bottom: 10px;
}

/* CTA */
.telegram-bubble__cta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #888;
}

.telegram-bubble__username {
    color: var(--telegram-blue);
    font-weight: 500;
    direction: ltr;
}

/* Arrow pointing to circle */
.telegram-bubble__arrow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid var(--white, #fff);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.05));
}

/* =============================================
   Animation States
   ============================================= */
.telegram-bubble.is-animating-in {
    animation: bubbleIn 0.4s ease-out forwards;
}

.telegram-bubble.is-animating-out {
    animation: bubbleOut 0.3s ease-in forwards;
}

@keyframes bubbleIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes bubbleOut {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.95);
    }
}

/* =============================================
   Responsive - Mobile
   ============================================= */
@media (max-width: 768px) {
    :root {
        --circle-size: 50px;
        --bubble-width: 260px;
    }

    .footer--with-telegram::before {
        display: none;
    }

    /* Move circle to right side */
    .telegram-circle {
        left: auto;
        right: 20px;
        transform: none;
    }

    /* Adjust bubble position for mobile */
    .telegram-bubble {
        left: auto;
        right: 0;
        transform: translateY(10px);
        width: calc(100vw - 40px);
        max-width: 300px;
    }

    .telegram-bubble.is-visible {
        transform: translateY(0);
    }

    .telegram-bubble.is-animating-in {
        animation: bubbleInMobile 0.4s ease-out forwards;
    }

    .telegram-bubble.is-animating-out {
        animation: bubbleOutMobile 0.3s ease-in forwards;
    }

    @keyframes bubbleInMobile {
        0% {
            opacity: 0;
            transform: translateY(20px) scale(0.9);
        }
        100% {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    @keyframes bubbleOutMobile {
        0% {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
        100% {
            opacity: 0;
            transform: translateY(10px) scale(0.95);
        }
    }

    /* Arrow on mobile - align to right */
    .telegram-bubble__arrow {
        left: auto;
        right: calc(var(--circle-size) / 2 - 10px);
        transform: none;
    }

    /* Footer layout adjustments for mobile */
    .footer--with-telegram .footer__content {
        padding-right: calc(var(--circle-size) + 30px);
    }

    .footer--with-telegram .footer__left {
        order: -1;
    }
    
    /* Telegram badge adjustment for mobile */
    .telegram-circle__telegram-badge {
        width: 22px;
        height: 22px;
    }
    
    .telegram-circle__telegram-badge svg {
        width: 12px;
        height: 12px;
    }

    .telegram-bubble__question {
        font-size: 0.9rem;
        padding-left: 22px;
    }
}

@media (max-width: 480px) {
    :root {
        --circle-size: 46px;
    }

    .telegram-circle {
        right: 15px;
    }

    .telegram-bubble {
        width: calc(100vw - 30px);
        max-width: 280px;
        padding: 12px 14px;
    }

    .telegram-bubble__question {
        font-size: 0.85rem;
    }

    .telegram-bubble__cta {
        font-size: 0.75rem;
    }
}

/* =============================================
   No Animation for users who prefer reduced motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    .telegram-circle__shimmer,
    .telegram-circle__online-badge,
    .telegram-circle__telegram-badge {
        animation: none;
    }

    .telegram-bubble {
        transition: opacity 0.2s ease;
    }

    .telegram-bubble.is-animating-in,
    .telegram-bubble.is-animating-out {
        animation: none;
    }
}
