
:root {
    --chat-primary: #123456;
    --chat-secondary: #1d527b;
    --chat-background: #f5f7fa;
    --chat-text: #263445;
    --chat-border: #e5e9ef;
}

/* Botón flotante */

.chatbot-toggle {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(0,0,0,.25);
    z-index: 9998;
    transition: .3s;
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    background: var(--chat-secondary);
}

/* Modal */

.chatbot-modal {
    position: fixed;
    bottom: 100px;
    left: 25px;
    right: auto;
    width: 390px;
    max-width: calc(100vw - 30px);
    height: 570px;
    max-height: calc(100dvh - 125px);
    z-index: 9999;

    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: .3s ease;
}

.chatbot-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Ventana */

.chatbot-window {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 8px 35px rgba(0,0,0,.20);
}

/* Encabezado */

.chatbot-header {
    background: var(--chat-primary);
    color: white;
    padding: 17px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-avatar,
.message-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.18);
    font-size: 20px;
}

.chatbot-header h3 {
    font-size: 16px;
    margin: 0 0 4px;
    color: white;
}

.chatbot-header span {
    font-size: 12px;
    color: #dce8f3;
}

.chatbot-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 4px;
}

.chatbot-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

/* Mensajes */

.chatbot-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: var(--chat-background);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chatbot-message {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    max-width: 95%;
}

.chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message .message-avatar {
    background: var(--chat-primary);
    color: white;
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 15px;
}

.message-content {
    padding: 12px 14px;
    border-radius: 12px;
    background: white;
    color: var(--chat-text);
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 2px 6px rgba(0,0,0,.04);
    overflow-wrap: anywhere;
}

.user .message-content {
    background: var(--chat-primary);
    color: white;
}

/* Opciones */

.chatbot-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 39px;
}

.chatbot-option {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid #cbd7e3;
    border-radius: 9px;
    background: white;
    color: var(--chat-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}

.chatbot-option:hover {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: white;
}

/* Formulario */

.chatbot-form {
    background: white;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--chat-border);
    width: calc(100% - 39px);
    margin-left: 39px;
}

.chatbot-form h4 {
    font-size: 14px;
    color: var(--chat-primary);
    margin: 0 0 10px;
}

.chatbot-form input {
    display: block;
    width: 100%;
    padding: 10px;
    margin-bottom: 9px;
    border: 1px solid #dce2e8;
    border-radius: 7px;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
}

.chatbot-form input:focus {
    border-color: var(--chat-secondary);
}

.chatbot-form button {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 7px;
    background: var(--chat-primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.chatbot-form button:hover {
    background: var(--chat-secondary);
}

/* Pie */

.chatbot-footer {
    text-align: center;
    padding: 10px;
    border-top: 1px solid var(--chat-border);
    color: #8994a1;
    font-size: 10px;
    background: white;
}

/* Contenedor del botón y bienvenida */
.chatbot-launcher {
    position: fixed;
    bottom: 25px;
    left: 25px;
    right: auto;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

/* Burbuja de bienvenida */
.chatbot-welcome {
    position: relative;
    width: 270px;
    bottom: 85px;
    padding: 16px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 5px 25px rgba(0,0,0,.15);
    color: #263445;
}

.chatbot-welcome::after {
    content: "";
    position: absolute;
    bottom: -9px;
    left: 20px;
    width: 20px;
    height: 18px;
    background: white;
    transform: rotate(45deg);
}

.chatbot-welcome-title {
    font-size: 16px;
    font-weight: 700;
    color: #123456;
    margin-bottom: 5px;
}

.chatbot-welcome p {
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 9px;
    padding-right: 5px;
}

.chatbot-welcome span {
    font-size: 10px;
    color: #8994a1;
}

/* Cerrar bienvenida */
.chatbot-welcome-close {
    position: absolute;
    top: 7px;
    right: 9px;
    border: none;
    background: transparent;
    color: #8994a1;
    font-size: 20px;
    cursor: pointer;
}

.chatbot-welcome {
    animation: chatbotPulse 5s ease-in-out infinite;
    transform-origin: bottom left;
}

/* Animación de entrada */
@keyframes chatbotPulse {
    0%, 85%, 100% {
        transform: scale(1);
    }

    90% {
        transform: scale(1.06);
    }
}

/* Ocultar bienvenida */
.chatbot-welcome.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 480px) {

    .chatbot-launcher {
        left: 15px;
        right: auto;
        bottom: 15px;
    }

    .chatbot-toggle {
        width: 55px;
        height: 55px;
    }

    .chatbot-welcome {
        width: 225px;
    }

    .chatbot-modal {
        width: auto;
        left: 10px;
        right: 10px;
        bottom: 85px;
        max-width: none;
        height: min(600px, calc(100dvh - 105px));
    }

    .chatbot-messages {
        padding: 13px;
    }
}
