/* =========================================================
   SiteMind Assistant
   Frontend styles - v0.1.0
   ========================================================= */

/* ---------------------------------------------------------
   Variables
   --------------------------------------------------------- */

#ssa-chat {
    --ssa-primary: #2563eb;
    --ssa-primary-hover: #1d4ed8;
    --ssa-background: #ffffff;
    --ssa-surface: #f7f8fa;
    --ssa-border: #e5e7eb;
    --ssa-text: #1f2937;
    --ssa-muted: #6b7280;
    --ssa-user-background: #2563eb;
    --ssa-user-text: #ffffff;
    --ssa-assistant-background: #f3f4f6;
    --ssa-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
    --ssa-radius: 16px;
    --ssa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;

    font-family: var(--ssa-font);
}


/* ---------------------------------------------------------
   Botón flotante
   --------------------------------------------------------- */

#ssa-button {
    position: fixed;
    right: 24px;
    bottom: 24px;

    width: 58px;
    height: 58px;

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

    background: var(--ssa-primary);
    color: #ffffff;

    border-radius: 50%;

    font-size: 25px;
    line-height: 1;

    cursor: pointer;

    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);

    z-index: 999998;

    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

#ssa-button:hover {
    background: var(--ssa-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

#ssa-button:active {
    transform: scale(0.96);
}


/* ---------------------------------------------------------
   Ventana principal
   --------------------------------------------------------- */

#ssa-window {
    position: fixed;

    right: 24px;
    bottom: 94px;

    width: 370px;
    max-width: calc(100vw - 32px);

    height: 560px;
    max-height: calc(100vh - 120px);

    display: flex;
    flex-direction: column;

    background: var(--ssa-background);

    border: 1px solid var(--ssa-border);
    border-radius: var(--ssa-radius);

    box-shadow: var(--ssa-shadow);

    overflow: hidden;

    z-index: 999999;

    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);

    transform-origin: bottom right;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease;
}


/* ---------------------------------------------------------
   Estado oculto
   --------------------------------------------------------- */

#ssa-window.ssa-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(12px) scale(0.97);
}


/* ---------------------------------------------------------
   Cabecera
   --------------------------------------------------------- */

.ssa-header {
    flex-shrink: 0;

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

    min-height: 62px;
    padding: 0 18px;

    background: var(--ssa-primary);
    color: #ffffff;
}

.ssa-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.1px;
}

#ssa-close {
    width: 34px;
    height: 34px;

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

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: #ffffff;

    font-size: 18px;
    line-height: 1;

    cursor: pointer;

    transition: background-color 0.2s ease;
}

#ssa-close:hover {
    background: rgba(255, 255, 255, 0.16);
}


/* ---------------------------------------------------------
   Área de mensajes
   --------------------------------------------------------- */

#ssa-messages {
    flex: 1;

    min-height: 0;

    padding: 18px;

    overflow-y: auto;
    overflow-x: hidden;

    background: var(--ssa-background);

    scroll-behavior: smooth;
}


/* ---------------------------------------------------------
   Mensajes
   --------------------------------------------------------- */

.ssa-message {
    max-width: 86%;

    margin-bottom: 12px;
    padding: 11px 14px;

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

    border-radius: 14px;

    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ssa-message:last-child {
    margin-bottom: 0;
}


/* Mensaje del asistente */

.ssa-message.ssa-assistant {
    margin-right: auto;

    background: var(--ssa-assistant-background);
    color: var(--ssa-text);

    border-bottom-left-radius: 5px;
}


/* Mensaje del usuario */

.ssa-message.ssa-user {
    margin-left: auto;

    background: var(--ssa-user-background);
    color: var(--ssa-user-text);

    border-bottom-right-radius: 5px;
}


/* ---------------------------------------------------------
   Sugerencias
   --------------------------------------------------------- */

#ssa-suggestions {
    flex-shrink: 0;

    display: flex;
    gap: 7px;

    padding: 10px 14px;

    background: var(--ssa-background);

    border-top: 1px solid var(--ssa-border);

    overflow-x: auto;
    overflow-y: hidden;

    scrollbar-width: thin;
}

.ssa-suggestion {
    flex-shrink: 0;

    padding: 7px 11px;

    border: 1px solid var(--ssa-border);
    border-radius: 999px;

    background: var(--ssa-background);
    color: var(--ssa-text);

    font-family: inherit;
    font-size: 12px;
    line-height: 1.2;

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.ssa-suggestion:hover {
    background: var(--ssa-primary);
    border-color: var(--ssa-primary);
    color: #ffffff;
}


/* ---------------------------------------------------------
   Pie / formulario
   --------------------------------------------------------- */

.ssa-footer {
    flex-shrink: 0;

    display: flex;
    gap: 8px;

    padding: 12px;

    background: var(--ssa-surface);

    border-top: 1px solid var(--ssa-border);
}


/* Campo de texto */

#ssa-input {
    flex: 1;

    min-width: 0;
    height: 42px;

    padding: 0 13px;

    border: 1px solid var(--ssa-border);
    border-radius: 10px;

    background: var(--ssa-background);
    color: var(--ssa-text);

    font-family: inherit;
    font-size: 14px;

    outline: none;

    box-sizing: border-box;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

#ssa-input::placeholder {
    color: var(--ssa-muted);
}

#ssa-input:focus {
    border-color: var(--ssa-primary);

    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}


/* Botón enviar */

#ssa-send {
    flex-shrink: 0;

    height: 42px;

    padding: 0 15px;

    border: 0;
    border-radius: 10px;

    background: var(--ssa-primary);
    color: #ffffff;

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
}

#ssa-send:hover {
    background: var(--ssa-primary-hover);
}

#ssa-send:active {
    transform: scale(0.97);
}


/* ---------------------------------------------------------
   Scrollbar
   --------------------------------------------------------- */

#ssa-messages::-webkit-scrollbar {
    width: 6px;
}

#ssa-messages::-webkit-scrollbar-track {
    background: transparent;
}

#ssa-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 999px;
}


/* ---------------------------------------------------------
   Responsive - tablets
   --------------------------------------------------------- */

@media (max-width: 600px) {

    #ssa-button {
        right: 18px;
        bottom: 18px;

        width: 54px;
        height: 54px;

        font-size: 23px;
    }

    #ssa-window {
        right: 16px;
        bottom: 84px;

        width: calc(100vw - 32px);

        height: min(560px, calc(100vh - 105px));

        border-radius: 14px;
    }

}


/* ---------------------------------------------------------
   Responsive - teléfonos pequeños
   --------------------------------------------------------- */

@media (max-width: 400px) {

    #ssa-window {
        right: 8px;
        bottom: 76px;

        width: calc(100vw - 16px);

        height: calc(100vh - 90px);

        max-height: none;

        border-radius: 12px;
    }

    #ssa-button {
        right: 14px;
        bottom: 14px;
    }

    .ssa-footer {
        padding: 9px;
    }

    #ssa-send {
        padding: 0 12px;
    }

}


/* ---------------------------------------------------------
   Accesibilidad
   --------------------------------------------------------- */

#ssa-button:focus-visible,
#ssa-close:focus-visible,
#ssa-send:focus-visible,
.ssa-suggestion:focus-visible,
#ssa-input:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}


/* ---------------------------------------------------------
   Respeto por reducción de movimiento
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    #ssa-button,
    #ssa-window,
    #ssa-close,
    #ssa-send,
    #ssa-input,
    .ssa-suggestion {
        transition: none;
    }

    #ssa-messages {
        scroll-behavior: auto;
    }

}
/* ---------------------------------------------------------
   Resultados de búsqueda
   --------------------------------------------------------- */

.ssa-results {
    display: flex;
    flex-direction: column;
    gap: 8px;

    margin-top: 12px;
}


/*
 * Cada resultado funciona como una tarjeta/enlace.
 */

.ssa-result {
    display: flex;
    flex-direction: column;
    gap: 4px;

    padding: 11px 12px;

    background: #ffffff;

    border: 1px solid var(--ssa-border);
    border-radius: 10px;

    color: var(--ssa-text);

    text-decoration: none !important;

    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}


/*
 * Título.
 */

.ssa-result strong {
    display: block;

    color: var(--ssa-primary);

    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}


/*
 * Extracto del contenido.
 */

.ssa-result span {
    display: block;

    color: var(--ssa-muted);

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


/*
 * Hover.
 */

.ssa-result:hover {
    background: var(--ssa-surface);

    border-color: var(--ssa-primary);

    transform: translateY(-1px);
}


/*
 * Enlace visitado.
 */

.ssa-result:visited {
    color: var(--ssa-text);
}


/*
 * Evitar estilos que pueda aplicar el tema
 * sobre los enlaces del chatbot.
 */

#ssa-chat .ssa-result,
#ssa-chat .ssa-result:hover,
#ssa-chat .ssa-result:focus,
#ssa-chat .ssa-result:visited {
    text-decoration: none;
}


/*
 * Separación entre el texto introductorio
 * y los resultados.
 */

.ssa-message.ssa-assistant > div:first-child {
    margin-bottom: 4px;
}