/* Advanced AI Chat Bar v3.0 - CSS Fade-in Animation */

/* Animazione fade-in da sinistra a destra */
@keyframes fadeInFromLeft {
    0% {
        opacity: 0;
        transform: translateX(-30px);
        filter: blur(4px);
    }
    60% {
        opacity: 0.7;
        filter: blur(1px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
        filter: blur(0);
    }
}

/* Animazione per l'emoji iniziale */
@keyframes fadeInEmoji {
    0% {
        opacity: 0;
        transform: translateX(-40px) scale(0.5) rotate(-180deg);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-10px) scale(1.2) rotate(-90deg);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) rotate(0deg);
    }
}

/* Stili per il testo typewriter */
.typewriter-text {
    display: inline-block;
    min-height: 24px;
    overflow: hidden;
}

.typewriter-char {
    display: inline-block;
    opacity: 0;
    animation: fadeInFromLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Emoji con animazione speciale */
.typewriter-char.emoji-char {
    font-size: 1.2em;
    animation: fadeInEmoji 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Lettere GAIA con effetto glow */
.typewriter-char.gaia-char {
    font-weight: 600;
    color: #f22237;
    position: relative;
    animation: fadeInFromLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards,
               glow 2s ease-in-out infinite;
    animation-delay: 0s, 1s;
}

@keyframes glow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(242, 34, 55, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(242, 34, 55, 0.8),
                    0 0 30px rgba(242, 34, 55, 0.6);
    }
}

.typewriter-char:hover {
    transform: translateY(-2px) scale(1.1);
    color: #f22237;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Typewriter - testo dinamico gestito da JavaScript */
.ai-placeholder-text {
    display: inline-block;
    min-height: 1rem;
    color: rgba(0, 0, 0, 1);
    font-size: 1rem;
    font-weight: 400;
    position: relative;
}

/* Cursore lampeggiante moderno */
.ai-typewriter-cursor {
    display: inline-block;
    color: #f22237;
    font-weight: 400;
    margin-left: 1px;
    animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Highlight GAIA con effetto glow */
.ai-gaia-highlight {
    font-weight: 600;
    color: #f22237;
    position: relative;
    text-shadow: 0 0 8px rgba(242, 34, 55, 0.3);
    animation: gaiaGlow 2s ease-in-out infinite;
}

@keyframes gaiaGlow {
    0%, 100% {
        text-shadow: 0 0 8px rgba(242, 34, 55, 0.3);
    }
    50% {
        text-shadow: 0 0 16px rgba(242, 34, 55, 0.6),
                     0 0 24px rgba(242, 34, 55, 0.4);
    }
}

/* Cursor che appare alla fine con effetto pulse */
.ai-typing-cursor {
    opacity: 0;
    animation: cursor-appear 400ms ease-out forwards, cursor-pulse 1.5s ease-in-out infinite;
    animation-delay: 2500ms, 2900ms; /* Appare dopo che il testo è completo, poi pulsa */
}

@keyframes cursor-appear {
    to {
        opacity: 1;
    }
}

@keyframes cursor-pulse {
    0%, 100% {
        transform: scaleY(1);
        opacity: 1;
    }
    50% {
        transform: scaleY(1.2);
        opacity: 0.7;
    }
}

.ai-chat-advanced-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: -5em !important;
    padding: .5em;
    z-index: 100;
    position: relative;
}

/* Classe .fixed rimossa - usa solo .is-sticky */

.ai-chat-advanced {
    position: relative;
    width: 100%;
    max-width: 700px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.ai-chat-advanced:hover {
    transform: scale(1.02) translateY(-2px);
}

/* Multiple glow layers */
.ai-glow-layer {
    position: absolute;
    border-radius: 50px;
    filter: blur(40px);
    transition: all 0.6s ease;
    pointer-events: none;
}

.ai-glow-1 {
    inset: -30px;
    background: radial-gradient(ellipse at 20% 50%,
                rgba(242, 34, 55, 0.3) 0%,
                rgba(242, 34, 55, 0.1) 50%,
                transparent 70%);
    opacity: 0.3;
    animation: glow-pulse-1 4s ease-in-out infinite;
}

.ai-glow-2 {
    inset: -40px;
    background: radial-gradient(ellipse at 80% 50%,
                rgba(255, 89, 0, 0.2) 0%,
                rgba(255, 89, 0, 0.05) 50%,
                transparent 70%);
    opacity: 0.2;
    animation: glow-pulse-2 4s ease-in-out infinite 0.5s;
}

.ai-glow-3 {
    inset: -20px;
    background: conic-gradient(from 180deg at 50% 50%,
                rgba(242, 34, 55, 0.1) 0deg,
                rgba(255, 89, 0, 0.1) 90deg,
                rgba(242, 34, 55, 0.1) 180deg,
                rgba(255, 89, 0, 0.1) 270deg,
                rgba(242, 34, 55, 0.1) 360deg);
    opacity: 0;
    animation: glow-rotate 10s linear infinite;
}

.ai-chat-advanced:hover .ai-glow-1 {
    opacity: 0.8;
    transform: scale(1.1);
}

.ai-chat-advanced:hover .ai-glow-2 {
    opacity: 0.6;
    transform: scale(1.15);
}

.ai-chat-advanced:hover .ai-glow-3 {
    opacity: 0.4;
}

@keyframes glow-pulse-1 {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.5; }
}

@keyframes glow-pulse-2 {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.08); opacity: 0.4; }
}

@keyframes glow-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main container */
.ai-bar-container {
    position: relative;
    background: linear-gradient(135deg,
                rgba(255, 255, 255, 0.95) 0%,
                rgba(255, 255, 255, 0.9) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 50px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.320, 1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06),
                0 8px 48px rgba(0, 0, 0, 0.04),
                inset 0 1px 0 rgba(255, 255, 255, 1),
                inset 0 -1px 0 rgba(0, 0, 0, 0.04);
}

.ai-chat-advanced:hover .ai-bar-container {
    position: relative;
    transform: translateY(-1px);
    box-shadow: 0 12px 40px rgba(242, 34, 55, 0.2),
                0 24px 80px rgba(242, 34, 55, 0.15),
                0 0 120px rgba(255, 89, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* Border gradient moderno con pseudo-elemento */
.ai-chat-advanced:hover .ai-bar-container::before {
    content: "";
    position: absolute;
    inset: -1px;
    padding: 1px;
    background: linear-gradient(90deg,
        #f22237 0%,
        #ff5900 25%,
        #f22237 50%,
        #ff5900 75%,
        #f22237 100%);
    background-size: 200% 100%;
    border-radius: 51px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 1;
    animation: gradientShift 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Gradient overlays */
.ai-gradient-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
                rgba(242, 34, 55, 0.02) 0%,
                rgba(255, 89, 0, 0.02) 50%,
                rgba(242, 34, 55, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ai-gradient-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg,
                transparent 40%,
                rgba(255, 255, 255, 0.7) 50%,
                transparent 60%);
    background-size: 200% 100%;
    background-position: -100% 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-gradient-pulse {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
                rgba(242, 34, 55, 0.1) 0%,
                transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-chat-advanced:hover .ai-gradient-overlay {
    opacity: 1;
}

.ai-chat-advanced:hover .ai-gradient-shimmer {
    opacity: 1;
    animation: shimmer 2s ease-in-out infinite;
}

.ai-chat-advanced:hover .ai-gradient-pulse {
    opacity: 0.5;
}

@keyframes shimmer {
    0% { background-position: -100% 0; }
    100% { background-position: 100% 0; }
}

/* Content */
.ai-bar-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px 16px 24px;
}

/* AI Icon with advanced animations */
.ai-icon-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-icon-glow {
    position: absolute;
    inset: -8px;
    background: radial-gradient(circle,
                rgba(242, 34, 55, 0.3) 0%,
                transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: icon-glow-pulse 2s ease-in-out infinite;
}

@keyframes icon-glow-pulse {
    0%, 100% { transform: scale(1); opacity: 0; }
    50% { transform: scale(1.2); opacity: 0.6; }
}

.ai-sparkle-icon {
    position: relative;
    width: 24px;
    height: 24px;
    color: #f22237;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 2;
}

.ai-sparkle-icon svg {
    width: 100%;
    height: 100%;
}

.ai-star-main {
    animation: star-pulse 3s ease-in-out infinite;
}

.ai-star-small-1 {
    animation: star-twinkle-1 2s ease-in-out infinite;
}

.ai-star-small-2 {
    animation: star-twinkle-2 2.5s ease-in-out infinite 0.5s;
}

@keyframes star-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes star-twinkle-1 {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
}

@keyframes star-twinkle-2 {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    50% { transform: scale(1.5) rotate(-180deg); opacity: 1; }
}

.ai-chat-advanced:hover .ai-sparkle-icon {
    transform: rotate(360deg) scale(1.2);
    filter: drop-shadow(0 0 12px rgba(242, 34, 55, 0.8));
}

.ai-chat-advanced:hover .ai-icon-glow {
    opacity: 1;
}


/* Input area */
.ai-input-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.ai-placeholder-wrapper {
    position: relative;
}

.ai-placeholder-container {
    display: flex;
    align-items: center;
    color: rgba(0, 0, 0, 0.6);
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 0.02em;
    min-height: 24px;
}

.ai-placeholder-text {
    display: inline-block;
    opacity: 1; /* Fallback per visibilità */
    color: rgba(0, 0, 0, 0.6); /* Fallback color */
}

.ai-chat-advanced:hover .ai-placeholder-text {
    color: rgba(0, 0, 0, 0.9);
}

/* Typing cursor */
.ai-typing-cursor {
    display: inline-block;
    width: 2px;
    height: 20px;
    background: #f22237;
    margin-left: 2px;
    animation: cursor-blink 1s steps(2) infinite;
    animation-delay: 2000ms; /* Inizia a lampeggiare dopo il testo */
}

@keyframes cursor-blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
}

/* Typing indicators */
.ai-typing-indicators {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-typing-dot {
    width: 4px;
    height: 4px;
    background: #f22237;
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.ai-typing-dot:nth-child(1) { animation-delay: 0s; }
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Wave effect */
.ai-wave-effect {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
                transparent,
                #f22237,
                transparent);
    transform: scaleX(0);
    transform-origin: left;
    opacity: 0;
    transition: all 0.3s ease;
}

.ai-chat-advanced:hover .ai-wave-effect {
    opacity: 0.6;
    animation: wave-flow 2s ease-in-out infinite;
}

@keyframes wave-flow {
    0% { transform: scaleX(0) translateX(0); }
    50% { transform: scaleX(1) translateX(0); }
    100% { transform: scaleX(0) translateX(100%); }
}

/* Send button */
.ai-bar-content .ai-send-button {
    position: relative;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    background: linear-gradient(135deg, #f22237 0%, #ff5900 100%);
    border: none;
    border-radius: 50% !important;
    color: white;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 1;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(242, 34, 55, 0.2);
}

.ai-button-glow {
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle,
                rgba(242, 34, 55, 0.4) 0%,
                transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    filter: blur(10px);
}

.ai-button-icon {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: transform 0.3s ease;
}

.ai-send-icon {
    width: 100%;
    height: 100%;
}

/* Button pulse rings */
.ai-button-pulse,
.ai-button-pulse-2 {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(242, 34, 55, 0.3);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.ai-chat-advanced:hover .ai-send-button {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(242, 34, 55, 0.4),
                0 4px 12px rgba(255, 89, 0, 0.2);
}

.ai-chat-advanced:hover .ai-button-glow {
    opacity: 1;
    animation: button-glow-pulse 2s ease-in-out infinite;
}

.ai-chat-advanced:hover .ai-button-icon {
    transform: rotate(-5deg);
    animation: button-icon-float 3s ease-in-out infinite;
}

.ai-chat-advanced:hover .ai-button-pulse {
    animation: button-pulse-ring 2s ease-out infinite;
}

.ai-chat-advanced:hover .ai-button-pulse-2 {
    animation: button-pulse-ring 2s ease-out infinite 0.5s;
}

@keyframes button-glow-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.6; }
}

@keyframes button-icon-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes button-pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.ai-send-button:active {
    transform: scale(0.95);
}

.ai-send-button:active .ai-button-icon {
    transform: scale(0.9);
}

/* Progress bar */
.ai-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
                #f22237 0%,
                #ff5900 50%,
                #f22237 100%);
    transform: scaleX(0);
    transform-origin: left;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-chat-advanced.loading .ai-progress-bar {
    opacity: 1;
    animation: progress-load 2s ease-in-out;
}

@keyframes progress-load {
    0% { transform: scaleX(0); }
    50% { transform: scaleX(0.8); }
    100% { transform: scaleX(1); }
}

/* Responsive - Mobile Optimizations */
@media (max-width: 768px) {
    .ai-chat-advanced-wrapper {
        padding: 8px;
        margin-bottom: -2.5em !important;
    }

    .ai-chat-advanced-wrapper:not(.is-sticky):after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        display: block;
        width: 100%;
        height: 50px;
        background-color: #f22237;
        pointer-events: none;
        z-index: -100;
    }

    .ai-chat-advanced {
        max-width: 100%;
    }

    /* Disabilita animazioni pesanti su mobile per performance */
    .ai-glow-layer,
    .ai-gradient-shimmer,
    .ai-gradient-pulse,
    .ai-icon-glow,
    .ai-button-glow {
        display: none !important;
    }

    /* Semplifica le animazioni */
    .ai-sparkle-icon,
    .ai-star-main,
    .ai-star-small-1,
    .ai-star-small-2 {
        animation: none !important;
    }

    .ai-bar-container {
        border-radius: 40px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08),
                    0 4px 24px rgba(0, 0, 0, 0.06);
    }

    .ai-chat-advanced:hover .ai-bar-container {
        box-shadow: 0 4px 16px rgba(242, 34, 55, 0.12),
                    0 8px 32px rgba(242, 34, 55, 0.08);
    }

    /* Riduci border gradient su mobile */
    .ai-chat-advanced:hover .ai-bar-container::before {
        animation: none;
        background: linear-gradient(90deg, #f22237 0%, #ff5900 100%);
    }

    .ai-bar-content {
        padding: 10px 14px;
        gap: 10px;
    }

    .ai-placeholder-container {
        font-size: 14px;
    }

    /* Riduci dimensione testo typewriter */
    .ai-placeholder-text {
        font-size: 0.875rem;
    }

    .ai-icon-wrapper {
        width: 24px;
        height: 24px;
    }

    .ai-sparkle-icon {
        width: 18px;
        height: 18px;
    }

    .ai-send-button {
        width: 32px;
        height: 32px;
    }

    .ai-button-icon {
        width: 14px;
        height: 14px;
    }

    /* Ottimizza hover per touch devices */
    .ai-chat-advanced:hover {
        transform: none;
    }

    .ai-chat-advanced:active {
        transform: scale(0.98);
    }

    /* Sticky ottimizzato per mobile */
    .ai-chat-advanced-wrapper.is-sticky {
        padding: 6px 8px !important;
        backdrop-filter: blur(8px) saturate(160%);
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced {
        max-width: 100% !important;
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-bar-content {
        padding: 8px 12px !important;
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-icon-wrapper {
        width: 20px !important;
        height: 20px !important;
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-sparkle-icon {
        width: 16px !important;
        height: 16px !important;
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-placeholder-container {
        font-size: 13px !important;
    }

    .ai-chat-advanced-wrapper.is-sticky .ai-send-button {
        width: 28px !important;
        height: 28px !important;
    }

}


@media (min-width: 768px) {
    .ai-chat-advanced-wrapper.is-sticky {
        top: 60px !important;
    }
}
/* Sticky state quando l'utente scrolla - SFONDO FULL WIDTH */
.ai-chat-advanced-wrapper.is-sticky {
    /* Posizionamento base */
    position: fixed !important;
    top: 50px;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    -webkit-transform: none !important;
    -ms-transform: none !important;

    /* Dimensioni full width */
    width: 100% !important;
    max-width: none !important;

    /* Reset margini negativi del wrapper normale */
    margin: 0 !important;

    /* Styling sfondo */
    z-index: 99999 !important;
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(3px) saturate(180%);
    -webkit-backdrop-filter: blur(3px) saturate(180%);
    padding: 10px 0 !important; /* Padding solo verticale */
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05),
                0 2px 20px rgba(0, 0, 0, 0.08);
    border-radius: 0; /* Nessun bordo arrotondato per full width */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);

    /* Animazioni */
    animation: slideDown 0.3s ease-out forwards;

    /* Flex per centrare il contenuto */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* La barra interna in sticky mode - centrata con sfondo full */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced {
    max-width: 650px !important; /* Larghezza massima della barra */
    width: 100% !important;
    margin: 0 auto !important; /* Centra la barra */
    position: relative !important;
    transform: none !important;
    left: auto !important;
    right: auto !important;
    /* Mantieni il border radius solo per la barra interna */
    border-radius: 50px !important;
}

/* Disabilita completamente hover in sticky */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover {
    transform: none !important;
}

.ai-chat-advanced-wrapper.is-sticky .ai-bar-content {
    padding: 10px 20px;
}

.ai-chat-advanced-wrapper.is-sticky .ai-icon-wrapper {
    width: 32px !important;
    height: 32px !important;
}

.ai-chat-advanced-wrapper.is-sticky .ai-sparkle-icon {
    width: 24px !important;
    height: 24px !important;
}


.ai-chat-advanced-wrapper.is-sticky .ai-placeholder-container {
    font-size: 16px !important;
}

.ai-chat-advanced-wrapper.is-sticky .ai-send-button {
    width: 32px !important;
    height: 32px !important;
}

/* RIATTIVATO: Glow layers ora attivi anche in sticky per parità effetti */
.ai-chat-advanced-wrapper.is-sticky .ai-glow-layer {
    /* display: none !important; */ /* RIMOSSO - effetti ora attivi */
}

/* Icon glow attivo anche in sticky */
.ai-chat-advanced-wrapper.is-sticky .ai-icon-glow {
    /* Stesso comportamento della barra normale */
    position: absolute;
    inset: -8px;
    background: radial-gradient(circle,
                rgba(242, 34, 55, 0.3) 0%,
                transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: icon-glow-pulse 2s ease-in-out infinite;
}

/* Hover effects identici per sticky */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-sparkle-icon {
    transform: rotate(360deg) scale(1.2);
    filter: drop-shadow(0 0 12px rgba(242, 34, 55, 0.8));
}

.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-icon-glow {
    opacity: 1;
}

/* Glow layers hover in sticky */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-glow-1 {
    opacity: 0.8;
    transform: scale(1.1);
}

.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-glow-2 {
    opacity: 0.6;
    transform: scale(1.15);
}

.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-glow-3 {
    opacity: 0.4;
}

/* Box shadow hover identico */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-bar-container {
    transform: translateY(-1px);
    box-shadow: 0 12px 40px rgba(242, 34, 55, 0.2),
                0 24px 80px rgba(242, 34, 55, 0.15),
                0 0 120px rgba(255, 89, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* Border gradient hover in sticky */
.ai-chat-advanced-wrapper.is-sticky .ai-chat-advanced:hover .ai-bar-container::before {
    content: "";
    position: absolute;
    inset: -1px;
    padding: 1px;
    background: linear-gradient(90deg,
        #f22237 0%,
        #ff5900 25%,
        #f22237 50%,
        #ff5900 75%,
        #f22237 100%);
    background-size: 200% 100%;
    border-radius: 50px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box,
                   linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: gradient-shift 3s ease infinite;
    opacity: 1;
    z-index: -1;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   INTEGRAZIONE CHAT WIDGET
   ============================================ */

/* Nascondi SOLO i PULSANTI widget chat quando la barra AI è attiva (NON il pannello o container) */
#chat-widget-container #chat-button-mobile-element.move-chat-button,
.ai-chat-widget .chat-button,
.ai-chat-widget .zona-nuvoletta,
#chat-button-mobile-element:not(#chat-element):not(#chat-widget-container),
#chat-button-element:not(#chat-element):not(#chat-widget-container),
.chat-widget-button:not(#chat-element):not(#chat-widget-container),
.chatbot-button:not(#chat-element):not(#chat-widget-container) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Nascondi anche su mobile in modo più aggressivo - SOLO PULSANTI (NON container o pannello) */
@media (max-width: 768px) {
    #chat-button-mobile-element:not(#chat-element):not(#chat-widget-container),
    #chat-button-element:not(#chat-element):not(#chat-widget-container),
    .chat-widget-button:not(#chat-element):not(#chat-widget-container),
    .chatbot-button:not(#chat-element):not(#chat-widget-container),
    .ai-chat-widget:not(#chat-element):not(#chat-widget-container) {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: scale(0) !important;
        z-index: -9999 !important;
    }
}

/* Posizionamento chat quando aperta */
#chat-element.open-chat {
    bottom: 25px !important;
    transition: bottom 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animazione nascondere barra AI quando chat è aperta */
.ai-chat-advanced-wrapper.chat-active {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Nascondi anche quando è in modalità sticky */
.ai-chat-advanced-wrapper.is-sticky.chat-active {
    opacity: 0 !important;
    transform: translateY(-20px) !important; /* Slide up invece che down per sticky */
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), visibility 0s 0.4s !important;
}

/* Mostra barra sticky quando chat è chiusa - con animazione */
.ai-chat-advanced-wrapper.is-sticky:not(.chat-active) {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
    visibility: visible !important;
    transition: opacity 0.3s ease 0.1s, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s, visibility 0s 0s !important;
}

/* Animazione mostrare barra AI quando chat è chiusa */
.ai-chat-advanced-wrapper {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}