/* ===== ESTILOS DEL CHATBOT BGL ===== */

/* Chatbot Wrapper - Botón flotante */
.chatbot-wrapper {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    display: block !important;
}

/* Botón principal del chatbot */
.chatbot-toggle-btn {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.6);
    background: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
}

.chatbot-toggle-btn:hover .chatbot-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Tooltip/Popup de hover */
.chatbot-tooltip {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    color: #333;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 10001;
    border: 1px solid #e0e0e0;
}

.chatbot-tooltip::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.chatbot-tooltip span {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    display: block;
    margin-bottom: 5px;
}

.chatbot-tooltip p {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Contenedor del chatbot - OCULTO POR DEFECTO */
#chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none !important; /* CRÍTICO: oculto al inicio */
    flex-direction: column;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    transform-origin: bottom right;
}

/* Clase para mostrar el chatbot */
#chatbot-container.visible {
    display: flex !important;
    animation: chatbot-fadeIn 0.3s ease;
}

@keyframes chatbot-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Clase para ocultar el chatbot (backup) */
.chatbot-hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Header del chatbot */
.chatbot-header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-title {
    flex: 1;
}

.chatbot-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

#close-chatbot {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

#close-chatbot:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Área de mensajes */
#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
    animation: chatbot-messageIn 0.3s ease;
}

@keyframes chatbot-messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.bot-message {
    background: white;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

/* Input del chatbot */
.chatbot-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    background: white;
    gap: 10px;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border 0.3s;
}

#chatbot-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#send-message {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

#send-message:hover {
    transform: scale(1.05);
}

/* Botones rápidos */
.quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-reply {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    color: #1976d2;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-reply:hover {
    background: #bbdefb;
    transform: translateY(-1px);
}

/* Indicador de escritura */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #3498db;
    border-radius: 50%;
    animation: chatbot-typing 1.4s infinite;
}

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

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

@keyframes chatbot-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-5px);
    }
}

/* Responsive para chatbot */
@media (max-width: 768px) {
    #chatbot-container {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        max-width: 350px;
        margin: 0 auto;
    }
    
    .chatbot-tooltip {
        width: 250px;
        right: -80px;
    }
    
    .chatbot-tooltip::before {
        right: 90px;
    }
}