/* =========================================================
   RRSMART CHAT IA 3.0
   Widget flotante aislado, compacto y responsive
========================================================= */


/* =========================================================
   RESET LOCAL
========================================================= */

#rrsmart-chat-root,
#rrsmart-chat-root *,
#rrsmart-chat-root *::before,
#rrsmart-chat-root *::after {
    box-sizing: border-box !important;
}

#rrsmart-chat-root {
    position: fixed !important;

    right: 22px !important;
    bottom: 22px !important;
    left: auto !important;

    z-index: 2147483000 !important;

    width: auto !important;
    height: auto !important;

    margin: 0 !important;
    padding: 0 !important;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif !important;

    font-size: 14px !important;
    line-height: 1.4 !important;
}


/* Posición configurable */

#rrsmart-chat-root.rrsmart-pos-right {
    right: 22px !important;
    left: auto !important;
}

#rrsmart-chat-root.rrsmart-pos-left {
    left: 22px !important;
    right: auto !important;
}


/* Evitar estilos globales del tema */

#rrsmart-chat-root button,
#rrsmart-chat-root textarea {
    font: inherit !important;

    text-transform: none !important;
    letter-spacing: normal !important;

    box-shadow: none !important;
}

#rrsmart-chat-root svg {
    display: block !important;
    max-width: none !important;
}


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

#rrsmart-chat-launcher {
    width: 58px !important;
    height: 58px !important;

    min-width: 58px !important;
    min-height: 58px !important;

    margin: 0 !important;
    padding: 0 !important;

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

    border: 0 !important;
    border-radius: 50% !important;

    background:
        var(--rrsmart-primary, #D5A53C) !important;

    color: #ffffff !important;

    cursor: pointer !important;

    overflow: hidden !important;

    appearance: none !important;
    -webkit-appearance: none !important;

    box-shadow:
        0 10px 28px
        rgba(0, 0, 0, 0.26) !important;

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease !important;
}

#rrsmart-chat-launcher:hover {
    transform: translateY(-2px) !important;

    box-shadow:
        0 14px 32px
        rgba(0, 0, 0, 0.30) !important;
}

#rrsmart-chat-launcher svg {
    width: 26px !important;
    height: 26px !important;

    fill: currentColor !important;
}

#rrsmart-chat-launcher .rrsmart-launcher-open {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#rrsmart-chat-launcher .rrsmart-launcher-close {
    display: none !important;

    color: #ffffff !important;

    font-size: 28px !important;
    line-height: 1 !important;
}

#rrsmart-chat-root.chat-open
#rrsmart-chat-launcher .rrsmart-launcher-open {
    display: none !important;
}

#rrsmart-chat-root.chat-open
#rrsmart-chat-launcher .rrsmart-launcher-close {
    display: block !important;
}


/* =========================================================
   VENTANA DEL CHAT
========================================================= */

#rrsmart-chat-window {
    position: absolute !important;

    right: 0 !important;
    bottom: 72px !important;
    left: auto !important;

    width:
        min(370px, calc(100vw - 32px)) !important;

    height:
        min(570px, calc(100dvh - 110px)) !important;

    max-height:
        calc(100dvh - 110px) !important;

    margin: 0 !important;
    padding: 0 !important;

    display: flex !important;
    flex-direction: column !important;

    overflow: hidden !important;

    background: #f7f6f3 !important;

    border:
        1px solid
        rgba(0, 0, 0, 0.11) !important;

    border-radius: 18px !important;

    box-shadow:
        0 22px 65px
        rgba(0, 0, 0, 0.29) !important;

    opacity: 0 !important;
    visibility: hidden !important;

    pointer-events: none !important;

    transform:
        translateY(12px)
        scale(0.98) !important;

    transform-origin:
        bottom right !important;

    transition:
        opacity 0.20s ease,
        transform 0.20s ease,
        visibility 0.20s ease !important;
}

#rrsmart-chat-root.rrsmart-pos-left
#rrsmart-chat-window {
    left: 0 !important;
    right: auto !important;

    transform-origin:
        bottom left !important;
}

#rrsmart-chat-root.chat-open
#rrsmart-chat-window {
    opacity: 1 !important;
    visibility: visible !important;

    pointer-events: auto !important;

    transform:
        translateY(0)
        scale(1) !important;
}


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

#rrsmart-chat-root .rrsmart-chat-header {
    flex: 0 0 auto !important;

    min-height: 58px !important;

    margin: 0 !important;
    padding: 9px 12px !important;

    display: flex !important;
    align-items: center !important;

    gap: 9px !important;

    background: #292929 !important;

    color: #ffffff !important;

    border: 0 !important;
}


/* =========================================================
   ICONO DEL AGENTE
========================================================= */

#rrsmart-chat-root .rrsmart-agent-icon {
    width: 34px !important;
    height: 34px !important;

    min-width: 34px !important;

    margin: 0 !important;
    padding: 0 !important;

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

    border-radius: 9px !important;

    background:
        rgba(213, 165, 60, 0.15) !important;
}

#rrsmart-chat-root .rrsmart-agent-icon svg {
    width: 20px !important;
    height: 20px !important;

    fill:
        var(--rrsmart-primary, #D5A53C) !important;
}


/* =========================================================
   INFORMACIÓN DEL AGENTE
========================================================= */

#rrsmart-chat-root .rrsmart-agent-info {
    flex: 1 1 auto !important;

    min-width: 0 !important;

    margin: 0 !important;
    padding: 0 !important;
}

#rrsmart-chat-root .rrsmart-agent-name {
    margin: 0 !important;
    padding: 0 !important;

    color: #ffffff !important;

    font-size: 13.5px !important;
    line-height: 17px !important;

    font-weight: 700 !important;
}

#rrsmart-chat-root .rrsmart-agent-status {
    margin: 2px 0 0 0 !important;
    padding: 0 !important;

    display: flex !important;
    align-items: center !important;

    gap: 5px !important;

    color: #d9d9d9 !important;

    font-size: 10.5px !important;
    line-height: 13px !important;
}

#rrsmart-chat-root .rrsmart-status-dot {
    width: 7px !important;
    height: 7px !important;

    min-width: 7px !important;

    border-radius: 50% !important;

    background: #49d174 !important;
}


/* =========================================================
   CERRAR
========================================================= */

#rrsmart-chat-root .rrsmart-chat-header-close {
    width: 30px !important;
    height: 30px !important;

    min-width: 30px !important;

    margin: 0 !important;
    padding: 0 !important;

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

    border: 0 !important;

    background: transparent !important;

    color: #bbbbbb !important;

    font-size: 24px !important;
    line-height: 1 !important;

    cursor: pointer !important;
}

#rrsmart-chat-root .rrsmart-chat-header-close:hover {
    color: #ffffff !important;
}


/* =========================================================
   ÁREA DE MENSAJES
========================================================= */

#rrsmart-chat-messages,
#rrsmart-chat-root .rrsmart-chat-messages {
    flex: 1 1 auto !important;

    min-height: 0 !important;

    width: 100% !important;

    margin: 0 !important;
    padding: 10px 10px !important;

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

    overscroll-behavior: contain !important;

    background: #f7f6f3 !important;

    scroll-behavior: smooth !important;

    scrollbar-width: thin !important;
    scrollbar-color:
        #aaa transparent !important;
}

#rrsmart-chat-messages::-webkit-scrollbar {
    width: 5px !important;
}

#rrsmart-chat-messages::-webkit-scrollbar-track {
    background: transparent !important;
}

#rrsmart-chat-messages::-webkit-scrollbar-thumb {
    background: #aaa !important;

    border-radius: 999px !important;
}

#rrsmart-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #888 !important;
}


/* =========================================================
   FILAS DE MENSAJES
========================================================= */

#rrsmart-chat-root .rrsmart-message-row {
    width: 100% !important;

    margin: 0 0 7px 0 !important;
    padding: 0 !important;

    display: flex !important;
}

#rrsmart-chat-root .rrsmart-message-row:last-child {
    margin-bottom: 0 !important;
}

#rrsmart-chat-root .rrsmart-message-row.bot {
    justify-content: flex-start !important;
}

#rrsmart-chat-root .rrsmart-message-row.user {
    justify-content: flex-end !important;
}


/* =========================================================
   BURBUJAS
========================================================= */

#rrsmart-chat-root .rrsmart-message {
    width: auto !important;

    max-width: 88% !important;

    margin: 0 !important;

    padding: 9px 11px !important;

    font-size: 12.5px !important;
    line-height: 1.42 !important;

    text-align: left !important;

    overflow-wrap: anywhere !important;

    /*
     * Conserva saltos simples de las respuestas generadas
     * sin preservar grandes bloques de espacios.
     */
    white-space: pre-line !important;
}

#rrsmart-chat-root .bot-message {
    background: #ffffff !important;

    color: #383838 !important;

    border:
        1px solid
        #dfdbd2 !important;

    border-radius:
        7px 14px 14px 14px !important;

    box-shadow:
        0 2px 5px
        rgba(0, 0, 0, 0.04) !important;
}

#rrsmart-chat-root .user-message {
    background: #292929 !important;

    color: #ffffff !important;

    border: 0 !important;

    border-radius:
        14px 14px 5px 14px !important;
}


/* =========================================================
   CONTENIDO DE LAS BURBUJAS
========================================================= */

#rrsmart-chat-root .rrsmart-message p {
    margin: 0 0 6px 0 !important;
    padding: 0 !important;

    color: inherit !important;

    font-size: inherit !important;
    line-height: inherit !important;
}

#rrsmart-chat-root .rrsmart-message p:last-child {
    margin-bottom: 0 !important;
}


/*
 * MUY IMPORTANTE:
 * Las listas deben usar white-space normal.
 * Evita que la indentación del HTML genere
 * enormes espacios verticales entre <li>.
 */

#rrsmart-chat-root .rrsmart-message ul,
#rrsmart-chat-root .rrsmart-message ol {
    margin: 5px 0 7px 0 !important;

    padding-left: 18px !important;

    white-space: normal !important;
}

#rrsmart-chat-root .rrsmart-message li {
    margin: 0 0 3px 0 !important;
    padding: 0 !important;

    color: inherit !important;

    font-size: inherit !important;
    line-height: 1.38 !important;

    white-space: normal !important;
}

#rrsmart-chat-root .rrsmart-message li:last-child {
    margin-bottom: 0 !important;
}

#rrsmart-chat-root .rrsmart-message br {
    line-height: 1 !important;
}


/* =========================================================
   MENSAJE INICIAL
========================================================= */

#rrsmart-chat-root .rrsmart-welcome-title {
    margin: 0 0 7px 0 !important;
    padding: 0 !important;

    font-weight: 600 !important;

    white-space: normal !important;
}


/* =========================================================
   ENLACES
========================================================= */

#rrsmart-chat-root .rrsmart-chat-link {
    display: inline !important;

    color: #00a9c0 !important;

    text-decoration: underline !important;

    text-decoration-thickness: 1px !important;
    text-underline-offset: 2px !important;

    font-weight: 600 !important;

    cursor: pointer !important;

    overflow-wrap: anywhere !important;
    word-break: break-word !important;

    white-space: normal !important;

    transition:
        color 0.15s ease !important;
}

#rrsmart-chat-root .rrsmart-chat-link:hover {
    color: #007f91 !important;
}

#rrsmart-chat-root .rrsmart-chat-link:focus {
    outline:
        2px solid
        rgba(0, 169, 192, 0.28) !important;

    outline-offset: 2px !important;
}


/* =========================================================
   INDICADOR ESCRIBIENDO
========================================================= */

#rrsmart-chat-root .rrsmart-typing {
    min-width: 58px !important;

    display: flex !important;
    align-items: center !important;

    gap: 4px !important;

    white-space: normal !important;
}

#rrsmart-chat-root .rrsmart-typing span {
    display: block !important;

    width: 6px !important;
    height: 6px !important;

    border-radius: 50% !important;

    background: #999999 !important;

    animation:
        rrsmartTyping
        1.3s
        infinite
        ease-in-out !important;
}

#rrsmart-chat-root .rrsmart-typing span:nth-child(2) {
    animation-delay: 0.15s !important;
}

#rrsmart-chat-root .rrsmart-typing span:nth-child(3) {
    animation-delay: 0.30s !important;
}

@keyframes rrsmartTyping {

    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }

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


/* =========================================================
   RESPUESTAS RÁPIDAS
========================================================= */

#rrsmart-quick-actions {
    flex: 0 0 auto !important;

    width: 100% !important;

    max-height: 82px !important;

    margin: 0 !important;

    padding: 6px 9px 7px !important;

    display: flex !important;
    flex-wrap: wrap !important;

    gap: 5px !important;

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

    background: #f7f6f3 !important;

    border-top:
        1px solid
        rgba(0, 0, 0, 0.04) !important;
}

#rrsmart-quick-actions button {
    width: auto !important;
    height: auto !important;

    min-width: 0 !important;

    margin: 0 !important;

    padding: 5px 9px !important;

    border:
        1px solid
        #ead8ad !important;

    border-radius: 16px !important;

    background: #ffffff !important;

    color: #414141 !important;

    font-size: 10.5px !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;

    white-space: nowrap !important;

    cursor: pointer !important;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease !important;
}

#rrsmart-quick-actions button:hover {
    background: #fffaf0 !important;

    border-color:
        var(--rrsmart-primary, #D5A53C) !important;

    transform:
        translateY(-1px) !important;
}


/* =========================================================
   PIE DEL CHAT
========================================================= */

#rrsmart-chat-root .rrsmart-chat-footer {
    flex: 0 0 auto !important;

    width: 100% !important;

    margin: 0 !important;
    padding: 8px !important;

    background: #ffffff !important;

    border-top:
        1px solid
        #e1ddd4 !important;
}


/* =========================================================
   INPUT
========================================================= */

#rrsmart-chat-root .rrsmart-input-wrap {
    width: 100% !important;

    min-height: 42px !important;

    margin: 0 !important;

    padding:
        3px 4px 3px 12px !important;

    display: flex !important;
    align-items: center !important;

    gap: 6px !important;

    background: #fafafa !important;

    border:
        1.5px solid
        #e6d5ae !important;

    border-radius: 22px !important;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease !important;
}

#rrsmart-chat-root .rrsmart-input-wrap:focus-within {
    border-color:
        var(--rrsmart-primary, #D5A53C) !important;

    box-shadow:
        0 0 0 2px
        rgba(213, 165, 60, 0.10) !important;
}

#rrsmart-chat-input {
    flex: 1 1 auto !important;

    width: 100% !important;

    height: auto !important;

    min-height: 28px !important;
    max-height: 82px !important;

    margin: 0 !important;
    padding: 6px 0 !important;

    border: 0 !important;
    outline: 0 !important;

    resize: none !important;

    overflow-y: auto !important;

    background: transparent !important;

    color: #333333 !important;

    font-size: 12px !important;
    line-height: 1.35 !important;
}

#rrsmart-chat-input::placeholder {
    color: #969ca4 !important;
}


/* =========================================================
   BOTÓN ENVIAR
========================================================= */

#rrsmart-chat-send {
    width: 34px !important;
    height: 34px !important;

    min-width: 34px !important;
    min-height: 34px !important;

    margin: 0 !important;
    padding: 0 !important;

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

    border: 0 !important;
    border-radius: 50% !important;

    background: #dfc891 !important;

    color: #ffffff !important;

    cursor: pointer !important;

    transition:
        background 0.15s ease,
        transform 0.15s ease !important;
}

#rrsmart-chat-send:hover {
    background:
        var(--rrsmart-primary, #D5A53C) !important;

    transform: scale(1.04) !important;
}

#rrsmart-chat-send:disabled {
    opacity: 0.55 !important;

    cursor: not-allowed !important;
}

#rrsmart-chat-send svg {
    width: 16px !important;
    height: 16px !important;

    fill: currentColor !important;

    transform:
        rotate(-20deg) !important;
}


/* =========================================================
   TABLET / VENTANAS ESTRECHAS
========================================================= */

@media (max-width: 900px) {

    #rrsmart-chat-root {
        right: 16px !important;
        bottom: 16px !important;
    }

    #rrsmart-chat-window {
        width:
            min(360px, calc(100vw - 28px)) !important;

        height:
            min(560px, calc(100dvh - 100px)) !important;

        max-height:
            calc(100dvh - 100px) !important;
    }

}


/* =========================================================
   MÓVIL
========================================================= */

@media (max-width: 600px) {

    #rrsmart-chat-root,
    #rrsmart-chat-root.rrsmart-pos-right,
    #rrsmart-chat-root.rrsmart-pos-left {
        right: 10px !important;
        left: 10px !important;
        bottom: 10px !important;
    }

    #rrsmart-chat-launcher {
        width: 52px !important;
        height: 52px !important;

        min-width: 52px !important;
        min-height: 52px !important;
    }

    #rrsmart-chat-launcher svg {
        width: 23px !important;
        height: 23px !important;
    }

    #rrsmart-chat-window {
        position: fixed !important;

        left: 8px !important;
        right: 8px !important;

        top: max(8px, env(safe-area-inset-top)) !important;

        bottom:
            calc(
                70px +
                env(safe-area-inset-bottom)
            ) !important;

        width: auto !important;

        height: auto !important;

        max-width: none !important;
        max-height: none !important;

        border-radius: 16px !important;
    }

    #rrsmart-chat-root .rrsmart-chat-header {
        min-height: 55px !important;

        padding:
            8px 10px !important;
    }

    #rrsmart-chat-root .rrsmart-agent-icon {
        width: 32px !important;
        height: 32px !important;

        min-width: 32px !important;
    }

    #rrsmart-chat-root .rrsmart-agent-icon svg {
        width: 18px !important;
        height: 18px !important;
    }

    #rrsmart-chat-root .rrsmart-chat-messages {
        padding:
            9px 9px !important;
    }

    #rrsmart-chat-root .rrsmart-message {
        max-width: 92% !important;

        padding:
            8px 10px !important;

        font-size:
            12.5px !important;

        line-height:
            1.4 !important;
    }

    #rrsmart-chat-root .rrsmart-message p {
        margin-bottom:
            5px !important;
    }

    #rrsmart-chat-root .rrsmart-message ul,
    #rrsmart-chat-root .rrsmart-message ol {
        margin:
            4px 0 6px 0 !important;

        padding-left:
            17px !important;
    }

    #rrsmart-chat-root .rrsmart-message li {
        margin:
            0 0 2px 0 !important;
    }

    #rrsmart-quick-actions {
        max-height:
            72px !important;

        padding:
            5px 8px 6px !important;

        gap:
            4px !important;
    }

    #rrsmart-quick-actions button {
        padding:
            5px 8px !important;

        font-size:
            10px !important;
    }

    #rrsmart-chat-root .rrsmart-chat-footer {
        padding:
            7px !important;
    }

}


/* =========================================================
   MÓVILES MUY PEQUEÑOS
========================================================= */

@media (max-width: 380px) {

    #rrsmart-chat-window {
        left: 5px !important;
        right: 5px !important;
    }

    #rrsmart-chat-root .rrsmart-message {
        max-width: 95% !important;

        font-size:
            12px !important;
    }

    #rrsmart-quick-actions button {
        font-size:
            9.5px !important;
    }

}


/* =========================================================
   PANTALLAS CON POCA ALTURA
========================================================= */

@media (max-height: 700px) and (min-width: 601px) {

    #rrsmart-chat-window {
        height:
            calc(100dvh - 90px) !important;

        max-height:
            calc(100dvh - 90px) !important;
    }

    #rrsmart-chat-root .rrsmart-chat-header {
        min-height:
            54px !important;

        padding:
            7px 10px !important;
    }

    #rrsmart-chat-root .rrsmart-chat-messages {
        padding:
            8px 9px !important;
    }

    #rrsmart-quick-actions {
        max-height:
            70px !important;
    }

    #rrsmart-chat-root .rrsmart-chat-footer {
        padding:
            7px !important;
    }

}
