
/* ==========================================
   CHATBOT LOGOPEDIAAPP
========================================== */

#chatbot-widget {
    --chatbot-primary: #3978c6;
    --chatbot-primary-dark: #2863aa;
    --chatbot-bg: #ffffff;
    --chatbot-text: #263445;
    --chatbot-muted: #718096;
    --chatbot-border: #e7edf4;

    position: fixed;
    right: 25px;
    bottom: 25px;
    z-index: 9999;
    font-family: inherit;
}

/* ==========================================
   BOTÓN FLOTANTE
========================================== */

#chatbot-widget .chatbot-toggle {
    position: absolute;
    right: 0;
    bottom: 0;

    width: 82px;
    height: 82px;

    padding: 0;
    border: none;
    border-radius: 50%;

    background: transparent;
    box-shadow: none;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    z-index: 9999;

    transition: transform .25s ease;
}

#chatbot-widget .chatbot-toggle:hover {
    transform: translateY(-3px);
}

#chatbot-widget .chatbot-toggle:active {
    transform: scale(.96);
}

#chatbot-widget .chatbot-toggle-image {
    display: block;
    width: 100%;
    height: 100%;

    object-fit: contain;
    border-radius: 50%;

    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, .18));

    transition: transform .25s ease;
}

#chatbot-widget .chatbot-toggle:hover .chatbot-toggle-image {
    transform: scale(1.08);
}

/* ==========================================
   PANEL
========================================== */

.chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 96px;

    width: 370px;
    height: 540px;
    max-height: calc(100dvh - 140px);

    display: none;
    flex-direction: column;

    overflow: hidden;

    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    border-radius: 16px;

    box-shadow: 0 10px 40px rgba(0, 0, 0, .16);
}

.chatbot-panel.is-open {
    display: flex;
    animation: chatbotAppear .2s ease;
}

@keyframes chatbotAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   CABECERA
========================================== */

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px 16px;

    background: var(--chatbot-primary);
    color: white;
}

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

/* Avatar corporativo */

.chatbot-avatar {
    width: 46px;
    height: 46px;
    min-width: 46px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, .8);
    border-radius: 50%;
}

.chatbot-avatar-image {
    display: block;
    width: 100%;
    height: 100%;

    object-fit: contain;
    border-radius: 50%;
}

.chatbot-header-info strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.chatbot-header-info small {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    opacity: .85;
}

.chatbot-close {
    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 50%;

    background: transparent;
    color: white;

    font-size: 18px;
    cursor: pointer;

    transition: background .2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, .15);
}

/* ==========================================
   MENSAJES
========================================== */

.chatbot-messages {
    flex: 1;

    display: flex;
    flex-direction: column;
    gap: 14px;

    overflow-y: auto;
    padding: 18px 14px;

    background: #f8fafc;
    scroll-behavior: smooth;
}

.chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

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

.chatbot-message.assistant {
    align-self: flex-start;
}

.chatbot-message-content {
    padding: 11px 14px;

    border-radius: 13px;

    font-size: 13px;
    line-height: 1.55;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chatbot-message.user .chatbot-message-content {
    background: var(--chatbot-primary);
    color: white;
    border-bottom-right-radius: 3px;
}

.chatbot-message.assistant .chatbot-message-content {
    background: white;
    color: var(--chatbot-text);

    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 3px;
}

.chatbot-message-time {
    margin-top: 4px;
    padding: 0 4px;

    color: var(--chatbot-muted);
    font-size: 10px;
}

/* ==========================================
   MENSAJE DE BIENVENIDA
========================================== */

.chatbot-welcome {
    padding: 14px;
    margin-bottom: 5px;

    background: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 12px;

    color: var(--chatbot-text);
    font-size: 13px;
    line-height: 1.6;
}

/* ==========================================
   INDICADOR DE ESCRITURA
========================================== */

.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 5px;

    padding: 0 18px 12px;

    background: #f8fafc;
}

.chatbot-typing[hidden] {
    display: none;
}

.chatbot-typing span {
    width: 7px;
    height: 7px;

    background: var(--chatbot-muted);
    border-radius: 50%;

    animation: chatbotTyping 1s infinite ease-in-out;
}

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

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

@keyframes chatbotTyping {
    0%, 60%, 100% {
        opacity: .35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* ==========================================
   FOOTER
========================================== */

.chatbot-footer {
    padding: 12px;

    background: white;
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatbot-form input {
    flex: 1;
    min-width: 0;
    height: 42px;

    padding: 0 13px;

    border: 1px solid var(--chatbot-border);
    border-radius: 22px;

    outline: none;

    font-size: 13px;

    background: white;
    color: var(--chatbot-text);
}

.chatbot-form input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 2px rgba(57, 120, 198, .08);
}

/* Botón enviar */

.chatbot-form button {
    width: 42px;
    height: 42px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    border-radius: 50%;

    background: var(--chatbot-primary);
    color: white;

    cursor: pointer;

    transition: background .2s ease, transform .2s ease;
}

.chatbot-form button:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-form button:disabled,
.chatbot-form input:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Finalizar conversación */

.chatbot-finish {
    display: block;
    width: 100%;

    margin-top: 9px;
    padding: 8px;

    border: 1px solid var(--chatbot-border);
    border-radius: 8px;

    background: white;
    color: var(--chatbot-muted);

    font-size: 11px;
    cursor: pointer;

    transition: border-color .2s ease, color .2s ease;
}

.chatbot-finish:hover:not(:disabled) {
    border-color: var(--chatbot-primary);
    color: var(--chatbot-primary);
}

.chatbot-finish:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Aviso de privacidad */

.chatbot-privacy {
    margin: 8px 2px 0;

    color: var(--chatbot-muted);

    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

/* ==========================================
   ESTADO FINALIZADO
========================================== */

.chatbot-finished {
    padding: 14px;
    margin: 8px 0;

    background: #edf7f0;
    color: #28643b;

    border-radius: 10px;

    font-size: 12px;
    line-height: 1.5;
}

/* ==========================================
   RESPONSIVE
========================================== */

@media (max-width: 576px) {

    #chatbot-widget {
        right: 16px;
        bottom: 18px;
    }

    #chatbot-widget .chatbot-toggle {
        width: 70px;
        height: 70px;
    }

    .chatbot-panel {
        position: fixed;

        right: 10px;
        bottom: 96px;
        left: 10px;

        width: auto;
        height: min(600px, calc(100dvh - 120px));
        max-height: none;

        border-radius: 15px;
    }
}

@media (max-width: 360px) {

    .chatbot-panel {
        right: 6px;
        left: 6px;
    }

    .chatbot-header {
        padding: 12px;
    }

    .chatbot-messages {
        padding: 14px 10px;
    }

    .chatbot-footer {
        padding: 10px;
    }
}
