/* ============================================================
   HeyGen AI Avatar CSS
   Floating button on bottom-left and video widget
   ============================================================ */

/* Floating Launch Button */
#heygen-avatar-btn {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF2E2E, #CC0000);
    border: 3px solid #ffffff;
    box-shadow: 0 8px 25px rgba(255, 46, 46, 0.4);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
}

#heygen-avatar-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 30px rgba(255, 46, 46, 0.5);
}

#heygen-avatar-btn.active {
    transform: scale(0.9) rotate(90deg);
    opacity: 0;
    pointer-events: none;
}

/* Tooltip for the button */
#heygen-avatar-btn::before {
    content: "Talk to AI Avatar";
    position: absolute;
    left: 80px;
    background: #1F2937;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

#heygen-avatar-btn::after {
    content: "";
    position: absolute;
    left: 74px;
    border-width: 5px 6px 5px 0;
    border-style: solid;
    border-color: transparent #1F2937 transparent transparent;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

#heygen-avatar-btn:hover::before,
#heygen-avatar-btn:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Pulse animation around button */
.heygen-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 46, 46, 0.5);
    z-index: -1;
    animation: heygen-ripple 2s infinite ease-out;
}

@keyframes heygen-ripple {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Backdrop Blur Overlay */
#heygen-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#heygen-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* The Modal Window */
#heygen-avatar-window {
    position: fixed;
    bottom: 100px;
    left: 25px;
    width: 480px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    overflow: hidden;
    transform-origin: bottom left;
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

#heygen-avatar-window.show {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.heygen-header {
    background: linear-gradient(135deg, #1F2937, #374151);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.heygen-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    margin: 0;
}

.heygen-live-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
    animation: heygen-blink 1.5s infinite;
}

@keyframes heygen-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.heygen-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    display: flex;
}

.heygen-close-btn:hover {
    color: white;
}

/* Video Container */
.heygen-video-container {
    width: 100%;
    background: #111;
    /* Aspect ratio 16:9 for horizontal avatar */
    aspect-ratio: 16/9;
    position: relative;
    overflow: hidden;
}

.heygen-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1;
}

/* Custom Loading Screen */
.heygen-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1F2937;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: opacity 0.5s ease;
    color: white;
}

.heygen-loader-overlay.hide {
    opacity: 0;
    pointer-events: none;
}

.heygen-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 46, 46, 0.3);
    border-top-color: #FF2E2E;
    border-radius: 50%;
    animation: heygen-spin 1s linear infinite;
    margin-bottom: 15px;
}

.heygen-loader-text {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: heygen-pulse-text 1.5s infinite;
}

@keyframes heygen-spin {
    to { transform: rotate(360deg); }
}

@keyframes heygen-pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #heygen-avatar-window {
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 10000;
    }
    .heygen-video-container {
        height: calc(100% - 54px); /* Subtract header height */
        aspect-ratio: auto;
    }
    #heygen-backdrop {
        display: none; /* No backdrop needed on full screen mobile */
    }
}
