/* ==========================================================================
   CHATBOT WIDGET STYLING - IA PERFORMANCE LAB (PREMIUM GLASSMORPHISM)
   ========================================================================== */

#chatbot-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 2100;
    font-family: 'Inter', sans-serif;
}

/* 1. Toggle Button */
.chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066FF 0%, #33b3ff 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 102, 255, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 30px rgba(0, 102, 255, 0.6), 0 0 15px rgba(51, 179, 255, 0.4);
}

.chatbot-toggle-btn:active {
    transform: scale(0.95);
}

/* Pulse animation around toggle */
.chatbot-pulse {
    position: absolute;
    inset: -4px;
    border: 2px solid rgba(51, 179, 255, 0.4);
    border-radius: 50%;
    animation: chatbot-pulse-anim 2s infinite;
    pointer-events: none;
}

@keyframes chatbot-pulse-anim {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* 2. Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: rgba(0, 26, 51, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 102, 255, 0.3);
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 102, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s ease;
}

.chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* 3. Header */
.chatbot-header {
    background: linear-gradient(135deg, rgba(0, 34, 68, 0.95) 0%, rgba(0, 20, 40, 0.95) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 102, 255, 0.2);
    border: 1px solid rgba(51, 179, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #33b3ff;
    font-size: 18px;
}

.chatbot-name {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: #FFFFFF;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.chatbot-status {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
    box-shadow: 0 0 8px #10b981;
}

.chatbot-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chatbot-close-btn:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
}

/* 4. Message Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 102, 255, 0.4);
}

/* Bubble Styles */
.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    animation: msg-appear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes msg-appear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.bot {
    background: rgba(0, 34, 68, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    background: #0066FF;
    color: #FFFFFF;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.2);
}

.chat-msg.bot strong {
    color: #FFFFFF;
}

/* 5. Quick Actions Container */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    animation: msg-appear 0.4s ease;
    align-self: flex-start;
    width: 100%;
}

.quick-action-btn {
    background: rgba(0, 102, 255, 0.1);
    border: 1px solid rgba(0, 102, 255, 0.3);
    border-radius: 18px;
    padding: 8px 14px;
    color: #33b3ff;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quick-action-btn:hover {
    background: rgba(0, 102, 255, 0.2);
    border-color: #33b3ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(51, 179, 255, 0.1);
}

/* 6. Input Area */
.chatbot-input-container {
    padding: 16px 20px;
    background: rgba(0, 10, 20, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 12px;
}

.chatbot-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    color: #FFFFFF;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    outline: none;
    border-color: #0066FF;
    box-shadow: 0 0 8px rgba(0, 102, 255, 0.25);
}

.chatbot-input::placeholder {
    color: #4b5e78;
}

.chatbot-send-btn {
    background: #0066FF;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-send-btn:hover {
    background: #33b3ff;
    box-shadow: 0 4px 10px rgba(0, 102, 255, 0.3);
}

/* 7. Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #94a3b8;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==========================================================================
   RESPONSIVE LAYOUT & HACK CONFLICTS PREVENTION
   ========================================================================== */

/* Reglas de la habilidad:
   1. Ocultar el toggle cuando el chat está activo en pantallas móviles
   2. Ajustar el z-index a 2500 en pantallas pequeñas
   3. Aumentar tamaño táctil del botón de cerrar a 36px */

#chatbot-widget-container:has(.chatbot-window.active) .chatbot-toggle-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

@media (max-width: 480px) {
    #chatbot-widget-container {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        /* Si la ventana no está activa, el contenedor no debe capturar clics (los punteros pasan de largo) */
        pointer-events: none;
    }
    
    #chatbot-widget-container:has(.chatbot-window.active) {
        pointer-events: all;
    }
    
    .chatbot-toggle-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        pointer-events: all;
    }
    
    .chatbot-window {
        bottom: 0;
        right: 0;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        border: none;
        z-index: 2500 !important;
    }
    
    .chatbot-close-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 24px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .chatbot-header {
        padding: 16px 20px;
    }
}
