/* ==========================================================================
   ÍNDICE CSS - CHATBOT
   1. VARIABLES GLOBALES (Colors, fonts)
   2. BOTÓN FLOTANTE (Toggle button)
   3. PANEL DEL CHAT (Chat Panel & Animations)
   4. CABECERA (Header)
   5. ÁREA DE MENSAJES Y SCROLLBAR (Messages Area & Scrollbar)
   6. BURBUJAS DE TEXTO (Bubbles)
   7. OPCIONES Y BOTONES (Options)
   8. ÁREA DE INPUT (Input Area)
   9. PIE Y BOTÓN VOLVER (Footer / Back to Menu)
   10. RESPONSIVO MÓVIL (Mobile Responsiveness)
   ========================================================================== */

:root {
    --chat-primary: #111111;
    --chat-bg: #ffffff;
    --chat-text: #333333;
    --chat-muted: #888888;
    --chat-border: #eaeaea;
    --chat-hover: #f5f5f5;
    --chat-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --chat-radius: 16px;
    --chat-font: 'Outfit', sans-serif;
}

#custom-chatbot {
    font-family: var(--chat-font);
    z-index: 99999;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
}

/* Floating Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease, background-color 0.3s ease, opacity 0.5s ease;

    /* Initial state for subtle entry */
    opacity: 0;
    transform: scale(0.8);
    animation: chatPulse 3s infinite;
}

@keyframes chatPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(17, 17, 17, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(17, 17, 17, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(17, 17, 17, 0);
    }
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    background-color: #333;
    animation: none;
}

.chatbot-toggle.hidden {
    opacity: 0 !important;
    transform: scale(0.5) !important;
    pointer-events: none;
}

/* Chat Panel */
.chatbot-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 450px;
    height: 400px;
    max-height: 80vh;
    background-color: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animation initial state */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    transform-origin: bottom right;
}

.chatbot-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

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

.chatbot-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.3s;
}

#chatbot-close:hover {
    opacity: 0.7;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #ffffff;
}

/* Scrollbar styling */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 10px;
}

/* Bubbles */
.chatbot-msg {
    display: flex;
    width: 100%;
}

.chatbot-msg.bot-msg {
    justify-content: flex-start;
}

.chatbot-msg.user-msg {
    justify-content: flex-end;
}

.chatbot-bubble {
    max-width: 90%;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.bot-msg .chatbot-bubble {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid var(--chat-border);
    border-bottom-left-radius: 4px;
}

.user-msg .chatbot-bubble {
    background-color: var(--chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Options */
.chatbot-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chatbot-option-btn {
    background-color: #fff;
    border: 1px solid var(--chat-border);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-align: left;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--chat-text);
    cursor: pointer;
    transition: all 0.3s;
}

.chatbot-option-btn:hover {
    background-color: var(--chat-hover);
    border-color: #ccc;
    transform: translateX(2px);
}

/* Input Area */
.chatbot-input-area {
    display: flex;
    padding: 1rem;
    background-color: #fff;
    border-top: 1px solid var(--chat-border);
    gap: 0.5rem;
}

.chatbot-input-area.hidden {
    display: none;
}

#chatbot-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    padding: 0.8rem 1rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

#chatbot-input:focus {
    border-color: var(--chat-primary);
}

#chatbot-send {
    background-color: var(--chat-primary);
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

#chatbot-send:hover {
    background-color: #333;
}

/* Footer / Back to Menu */
.chatbot-footer {
    padding: 0.5rem 1rem 1rem;
    background-color: #fff;
    text-align: center;
}

#chatbot-back {
    background: none;
    border: none;
    color: var(--chat-muted);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s;
}

#chatbot-back:hover {
    color: var(--chat-primary);
}

#chatbot-back.hidden {
    display: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: auto;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .chatbot-panel.open {
        transform: translateY(0);
    }

    #custom-chatbot {
        bottom: 1rem;
        right: 1rem;
        left: auto;
    }
    
    .chatbot-toggle {
        width: 44px;
        height: 44px;
    }
    
    .chatbot-toggle svg {
        width: 20px;
        height: 20px;
    }
}