/**
 * WooCommerce AI Chat Widget Styles
 * Simplified for Direct Link Mode (Icon + Tooltip Only)
 */

/* Main Container */
#woo-ai-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chat Button (Floating Action Button) */
.woo-ai-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    /* Changed from fixed to relative to stay inside container */
    z-index: 999999;
    animation: pulse 3s infinite;
    text-decoration: none !important;
    /* For <a> tag */
}

.woo-ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.woo-ai-chat-icon {
    width: 32px !important;
    height: 32px !important;
    color: white !important;
    fill: currentColor !important;
}

/* Pulse animation */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4), 0 0 0 0 rgba(37, 211, 102, 0.4);
    }

    50% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4), 0 0 0 10px rgba(37, 211, 102, 0);
    }

    100% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4), 0 0 0 0 rgba(37, 211, 102, 0.4);
    }
}

/* 
 * POSITIONING 
 */

/* Desktop */
#woo-ai-chat-widget.woo-ai-chat-bottom-left {
    bottom: 20px;
    left: 20px;
}

#woo-ai-chat-widget.woo-ai-chat-bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Mobile (Respect Nav Bar) */
@media (max-width: 768px) {
    #woo-ai-chat-widget.woo-ai-chat-bottom-left {
        bottom: 85px;
        left: 15px;
    }

    #woo-ai-chat-widget.woo-ai-chat-bottom-right {
        bottom: 85px;
        right: 15px;
    }

    .woo-ai-chat-button {
        width: 50px;
        height: 50px;
    }

    .woo-ai-chat-icon {
        width: 24px !important;
        height: 24px !important;
    }
}

/* 
 * WELCOME TOOLTIP 
 */
/* 
 * CHAT MODAL (The Popup)
 */
.woo-ai-chat-modal {
    position: absolute;
    bottom: 80px;
    /* Above the button */
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Hidden State */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    z-index: 999998;
}

/* Positioning relative to widget container */
#woo-ai-chat-widget.woo-ai-chat-bottom-left .woo-ai-chat-modal {
    left: 0;
    transform-origin: bottom left;
}

#woo-ai-chat-widget.woo-ai-chat-bottom-right .woo-ai-chat-modal {
    right: 0;
    transform-origin: bottom right;
}

/* Visible State */
.woo-ai-chat-modal.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Modal Header */
.woo-ai-chat-modal-header {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.woo-ai-chat-modal-title {
    font-weight: bold;
    font-size: 16px;
}

.woo-ai-chat-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
}

.woo-ai-chat-modal-close:hover {
    opacity: 1;
}

/* Modal Body (iFrame) */
.woo-ai-chat-modal-body {
    flex: 1;
    background: #fff;
    position: relative;
}

#woo-ai-chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .woo-ai-chat-modal {
        position: fixed;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0;
        z-index: 9999999;
        /* Fullscreen on top */
    }

    #woo-ai-chat-widget {
        z-index: 9999999;
        /* Ensure button stays on top if needed, or hide it */
    }
}

/* 
 * WELCOME TOOLTIP 
 */
.woo-ai-chat-tooltip {
    position: absolute;
    /* Relative to widget container */
    bottom: 75px;
    /* Above the button */
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8) translateY(10px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    width: 220px;
    /* Fixed width for centering */
    display: flex;
    justify-content: center;
    z-index: 999997;
}

/* Hide tooltip when modal is open */
.woo-ai-chat-modal.open~.woo-ai-chat-tooltip {
    display: none !important;
}

/* Center tooltip horizontally relative to button */
#woo-ai-chat-widget.woo-ai-chat-bottom-left .woo-ai-chat-tooltip {
    left: 0;
}

#woo-ai-chat-widget.woo-ai-chat-bottom-right .woo-ai-chat-tooltip {
    right: 0;
}

.woo-ai-chat-tooltip.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.woo-ai-chat-tooltip-bubble {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 10px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    position: relative;
    line-height: 1.4;
}

/* Emoji Animation */
.woo-ai-chat-tooltip-emoji {
    display: inline-block;
    animation: wave 1.5s infinite;
    transform-origin: 70% 70%;
    margin-left: 5px;
}

@keyframes wave {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(20deg);
    }

    75% {
        transform: rotate(-20deg);
    }
}

/* Close Button (X) */
.woo-ai-chat-tooltip-close {
    position: absolute;
    top: -8px;
    left: -8px;
    /* On the left for AR/RTL */
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    padding: 0;
}

.woo-ai-chat-tooltip-close svg {
    width: 12px;
    height: 12px;
}

.woo-ai-chat-tooltip-close:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}