/* AI Assistant Widget - Bar L'animalet */
:root {
    --ai-primary: #1a1a1a;
    --ai-accent: #d4a373;
    /* Un tono dorado/crema para premium feel */
    --ai-bg: rgba(255, 255, 255, 0.95);
    --ai-text: #333;
    --ai-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#ai-chat-widget {
    position: fixed !important;
    bottom: 2rem !important;
    right: 2rem !important;
    left: auto !important;
    z-index: 10000 !important;
    display: block !important;
    visibility: visible !important;
    font-family: 'Manrope', sans-serif;
}

/* Floating Bubble */
.ai-chat-bubble {
    width: 60px;
    height: 60px;
    background: var(--ai-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--ai-shadow);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    position: relative;
    border: none;
    /* Initial state for entrance animation */
    opacity: 0;
    visibility: hidden;
    transform: scale(0);
}

.ai-chat-bubble:hover {
    transform: scale(1.1) translateY(-1px) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.ai-chat-bubble i {
    color: white;
    font-size: 1.5rem;
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 0px;
    right: 0;
    width: 350px;
    height: 600px;
    background: var(--ai-bg);
    border-radius: 20px;
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 100;
    /* Ensure it's on top of children if needed, though they are inside */
}

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

/* Header */
.ai-chat-header {
    background: var(--ai-primary);
    padding: 0.4rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-header-info img {
    width: 230px;
    height: 50px;
}

.ai-chat-close {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.5s;
    margin-right: 1.2rem;
    margin-top: 0.6rem;
}

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

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-message {
    max-width: 85%;
    padding: 0.82rem 1.1rem;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-line;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease forwards;
}

.ai-message.bot {
    align-self: flex-start;
    background: #f0f0f0;
    color: var(--ai-text);
    border-bottom-left-radius: 2px;
}

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

/* Input Area */
.ai-chat-input-area {
    padding: 1rem;
    background: white;
    display: flex;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-chat-input-area input {
    flex: 1;
    min-width: 0;
    /* Allow shrinking */
    border: 1px solid #ddd;
    padding: 0.8rem 1rem;
    border-radius: 25px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.ai-chat-input-area input:focus {
    border-color: var(--ai-accent);
}

.ai-chat-send,
.ai-chat-mic {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--ai-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ai-chat-send:hover,
.ai-chat-mic:hover {
    background: #6e6e6e;
    transform: scale(1.1);
}

.ai-chat-mic.recording {
    background: #ff4b2b;
    color: white;
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 75, 43, 0.7);
    }

    70% {
        transform: scale(1.2);
        box-shadow: 0 0 0 10px rgba(255, 75, 43, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 75, 43, 0);
    }
}


/* Typing Indicator Dots */
.ai-chat-typing {
    padding: 0 1rem 1rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: #f0f0f0;
    width: fit-content;
    border-radius: 15px;
    border-bottom-left-radius: 2px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.ai-message strong {
    font-weight: 800;
    color: inherit;
}

.ai-btn-wa {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: white !important;
    padding: 10px 18px;
    border-radius: 25px;
    text-decoration: none !important;
    font-weight: 700;
    margin-top: 10px;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s;
}

.ai-btn-wa:hover {
    transform: scale(1.05);
    background: #20ba5a;
}

.ai-btn-carta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ai-primary);
    color: white !important;
    padding: 10px 18px;
    border-radius: 25px;
    text-decoration: none !important;
    font-weight: 700;
    margin-top: 10px;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.ai-btn-carta:hover {
    transform: scale(1.05);
    background: #333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    #ai-chat-widget {
        bottom: 1.2rem !important;
        right: 1.2rem !important;
    }

    .ai-chat-bubble {
        width: 55px;
        height: 55px;
    }

    .ai-chat-window {
        width: calc(100vw - 40px);
        height: 72vh;
        bottom: 62px;
        right: -1px;
    }

    .ai-chat-input-area {
        padding: 0.8rem;
        gap: 6px;
    }

    .ai-chat-input-area input {
        padding: 0.7rem 0.8rem;
        font-size: 0.85rem;
    }

    .ai-chat-send,
    .ai-chat-mic {
        width: 40px;
        /* Restored to original */
        height: 40px;
    }

    .ai-chat-header-info img {
        width: 180px;
        height: auto;
    }
}