/* Root Variables for a Premium Feel */
:root {
    --chat-primary: #a80000;
    --chat-primary-hover: #800000;
    --chat-bg: rgba(255, 255, 255, 0.95);
    --chat-text: #1d1d1f;
    --chat-bot-bubble: #f2f2f7;
    --chat-user-bubble: #a80000;
    --chat-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    --chat-border: rgba(0, 0, 0, 0.05);
    --chat-radius: 24px;
    --chat-transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Floating Input Container */
#chat-boton {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    /* Above mobile navigation if any */
    width: 90%;
    max-width: 500px;
}

.chat-input-trigger-container {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 40px;
    padding: 3px 5px 3px 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    transition: var(--chat-transition);
}

.chat-input-trigger-container:focus-within {
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    border-color: var(--chat-primary);
}

.chat-trigger-btn {
    background: var(--chat-primary);
    color: white;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--chat-transition);
}

.chat-trigger-btn:hover {
    transform: scale(1.05);
    background: var(--chat-primary-hover);
}

.chat-trigger-btn i {
    width: 20px;
    height: 20px;
}

/* Chat Box inside Modal Wrapper */
#chat-box {
    position: absolute;
    bottom: 115px;
    /* Increased gap from input */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    /* Matches wrapper width handled in JS/CSS */
    max-width: 500px;
    height: 500px;
    background: var(--chat-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom center;
    animation: chat-appear-centered 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes chat-appear-centered {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1) translateY(0);
    }
}

/* Response Area */
#chat-respuesta {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bot {
    background: var(--chat-bot-bubble);
    color: var(--chat-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user {
    background: var(--chat-user-bubble);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.2);
}

/* Loader */
#loader_spin_chat {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin-chat 0.8s linear infinite;
}

@keyframes spin-chat {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Recording state for Mic */
#chat-mic.is-recording {
    background: var(--chat-primary) !important;
    color: white !important;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(168, 0, 0, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(168, 0, 0, 0);
    }

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

/* Responsive */
@media (max-width: 480px) {
    #chat-box {
        height: 60vh;
        bottom: 90px;
    }
}