/* AI Chat Widget Styles */
.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    /* Let clicks pass through wrapper */
}

/* Spin Ball Container */
.ai-spin-ball-container {
    width: 100px;
    height: 100px;
    cursor: pointer;
    position: relative;
    z-index: 10000;
    pointer-events: auto;

    /* Flex centering is more robust */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Clip the zoomed content */
    overflow: hidden;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    background: transparent;

    /* Add bounce animation */
    animation: gentleBounce 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

/* The inner wrapper for the Unicorn Embed */
.unicorn-embed-wrapper {
    /* 
       We set a fixed large size. 
       Flexbox in parent centers this 400x400 box in the 200x200 container.
       This automatically crops 100px from each side.
    */
    width: 400px !important;
    height: 400px !important;
    flex-shrink: 0;
    /* Prevent shrinking */

    pointer-events: none;
    position: relative;
}

/* Force the Unicorn Project div to fill the wrapper */
.unicorn-embed-wrapper>div,
div[data-us-project] {
    width: 100% !important;
    height: 100% !important;
}

/* Aggressive Logo Hiding */
.unicorn-embed-wrapper a,
.unicorn-embed-wrapper .us-branding,
div[data-us-project]+a,
a[href*="unicorn.studio"] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    position: absolute;
    bottom: -9999px;
}

.ai-spin-ball-container:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 87, 34, 0.4);
    /* Glow effect on hover */
    animation: none;
    /* Stop bounce on hover */
}

/* Pulsing Glow Ring for Discoverability */
.ai-spin-ball-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 85, 0, 0.3), rgba(255, 136, 0, 0.1), transparent);
    animation: pulseGlowRing 2.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes pulseGlowRing {

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

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.3;
    }
}

@keyframes gentleBounce {

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

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

/* Particle Ring Effect */
.ai-spin-ball-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 85, 0, 0.4);
    animation: rotateParticles 20s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes rotateParticles {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
        opacity: 0.6;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
        opacity: 0.6;
    }
}

/* Attention Pulse - for first-time visitors */
.ai-spin-ball-container.attention-pulse {
    animation: gentleBounce 3s ease-in-out infinite, attentionPulse 2s ease-in-out 3;
}

@keyframes attentionPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(255, 85, 0, 0.8), 0 0 60px rgba(255, 136, 0, 0.4);
    }
}

/* Shake Animation - triggers after delay */
.ai-spin-ball-container.shake-hint {
    animation: gentleBounce 3s ease-in-out infinite, gentleShake 0.5s ease-in-out 3;
}

@keyframes gentleShake {

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

    25% {
        transform: translateY(0) rotate(-5deg);
    }

    75% {
        transform: translateY(0) rotate(5deg);
    }
}

/* Cursor hint */
.ai-spin-ball-container {
    cursor: pointer;
}

.ai-spin-ball-container:hover {
    cursor: pointer;
}

/* Enhanced glow on first visit */
.ai-spin-ball-container.first-visit::before {
    animation: pulseGlowRing 2.5s ease-in-out infinite, firstVisitGlow 3s ease-in-out infinite;
}

@keyframes firstVisitGlow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.5);
    }
}

/* Floating Tooltip */
.ai-tooltip {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10001;
}

.ai-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--secondary-accent);
}

.ai-tooltip.visible {
    opacity: 1;
    animation: tooltipFloat 2s ease-in-out infinite;
}

@keyframes tooltipFloat {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

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


/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 120px;
    /* Positioned above the 100px ball with some spacing */
    right: 0;
    width: 380px;
    height: 550px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    /* Enable clicks in window */
}

.ai-chat-window.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #fff;
    font-weight: 600;
}

.close-chat {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: color 0.2s;
}

.close-chat:hover {
    color: #fff;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: var(--primary-accent, #FF5722);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: #eee;
    border-bottom-left-radius: 2px;
}

.message.loading {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary-accent, #FF5722);
}

.chat-input-area button {
    background: var(--primary-accent, #FF5722);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-input-area button:hover {
    transform: scale(1.05);
}

.chat-input-area button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}