/* Estilo general del widget */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 360px;
    font-family: Arial, sans-serif;
    z-index: 9999;
}

/* Responsive */
@media (max-width: 480px) {
    #chat-widget {
        width: 95vw;
        right: 2.5vw;
        bottom: 15px;
    }

    #chat-header {
        width: 60px;
        height: 60px;
    }

    #ferti-icon {
        width: 85%;
        height: 85%;
    }

    #chat-box {
        font-size: 14px;
    }

    #chat-body input[type="text"],
    #chat-body button {
        padding: 12px;
        font-size: 15px;
    }
}

/* Contenedor del botón flotante + mensaje */
#chat-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    bottom: 0;
    right: 0;
    margin: 10px;
}

/* Mensaje sutil al lado del botón */
#chat-tooltip {
    background-color: #f0f7ec;
    color: #4e6b43;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 1s ease;
    z-index: 10000;
    position: absolute;
    right: 90px;
    bottom: 30px;
    pointer-events: none;
}

/* Botón con imagen */
#chat-header {
    background-color: #ffc400e3;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

/* Imagen de Ferti */
#ferti-icon {
    width: 90%;
    height: 90%;
    object-fit: cover;
    border-radius: 50%;
}

/* Ocultar botón cuando el chat está activo */
#chat-header.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Animación de botón */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(107, 142, 35, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(107, 142, 35, 0); }
    100% { box-shadow: 0 0 0 0 rgba(107, 142, 35, 0); }
}

/* Cuerpo del chat */
#chat-body {
    max-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    background: #ffffff;
    border-radius: 10px 10px 0 0;
}

#chat-body.active {
    max-height: 500px;
    opacity: 1;
    pointer-events: auto;
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* Cabecera del chat */
.chat-header-bar {
    background-color: #6B8E23;
    color: white;
    padding: 14px 16px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 10px 10px 0 0;
    font-size: 18px;
}

#close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
}

/* Caja de mensajes */
#chat-box {
    padding: 14px 20px;
    height: 240px;
    overflow-y: auto;
    font-size: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat-box div {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Entrada de texto */
#chat-body input[type="text"] {
    border: none;
    padding: 14px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px solid #ccc;
    outline: none;
}

/* Botón de enviar */
#chat-body button {
    background: #6B8E23;
    color: white;
    border: none;
    padding: 14px;
    font-size: 16px;
    width: 100%;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s ease;
}

/* Estilos diferenciados para los mensajes */
.bot-message,
.user-message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
}

.bot-message {
    background-color: #eef8e5;
    color: #2d3d1a;
    align-self: flex-start;
    margin-right: auto;
}

.user-message {
    background-color: #f0f0f0;
    color: #111;
    align-self: flex-end;
    margin-left: auto;
}

/* Ocultar tooltip si el chat está activo */
#chat-body.active ~ #chat-toggle-container #chat-tooltip {
    display: none !important;
}

/* Desvanecimiento automático */
#chat-tooltip.fade-out {
    opacity: 0;
    pointer-events: none;
}
