.boton-flotante-soporte {
    position: fixed;
    right: 30px;
    bottom: 30px;
    width: 60px !important;
    height: 60px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    z-index: 1090;
    background-color: var(--cta-blue) !important;
}

.boton-flotante-soporte i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 28px;
    line-height: 1;
    color: #ffffff !important;
}

.boton-flotante-soporte:hover {
    background-color: var(--cta-blue-hover) !important;
}

.boton-flotante-soporte:active {
    background-color: var(--cta-blue-active) !important;
}

.fondo-modal-soporte-flotante {
    z-index: 1091;
    background-color: transparent !important;
}

/* Panel flotante anclado al borde inferior derecho, encima del botón */
#modal-crear-soporte-flotante {
    z-index: 1095;
}

#modal-crear-soporte-flotante .modal-panel-soporte-flotante {
    position: fixed;
    right: 31px;
    bottom: 30px;
    margin: 0;
    width: 494px;
    max-width: calc(100vw - 40px);
    /* Aprovechar el alto disponible sin desplazar el panel fuera de la pantalla. */
    height: min(712px, calc(100dvh - 40px));
    max-height: calc(100dvh - 40px);
    display: flex;
}

#modal-crear-soporte-flotante .modal-content {
    padding: 0 !important;
    border: 0;
    border-radius: 12px !important;
    box-shadow: 0 6px 12px 2px rgba(0, 0, 0, 0.25) !important;
    overflow: hidden;
    width: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

/* El header por defecto de crearModal() no se usa: se reemplaza por el header propio dentro
   de modal_body para lograr el degradado y el layout exactos del diseño. */
#modal-crear-soporte-flotante .modal-header {
    display: none;
}

#modal-crear-soporte-flotante .modal-body {
    padding: 0 !important;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modal-crear-soporte-flotante .modal-body > .row {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
}

/* Sin el margen negativo del row, el gutter del col dejaba franjas blancas alrededor del header */
#modal-crear-soporte-flotante .modal-body .contenedor-chatbot-soporte {
    padding: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Dentro del panel de altura fija, el chatbot llena el espacio (anula el tope de 420px del componente) */
#modal-crear-soporte-flotante .chatbot {
    flex: 1;
    min-height: 0;
    max-height: none;
}

/* Header del panel: degradado y título + botón cerrar */
.chatbot-soporte-panel-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(-32.13deg, rgb(97, 44, 104) 33.76%, rgb(85, 41, 123) 42.84%, rgb(61, 48, 122) 56.62%, rgb(52, 62, 132) 67.43%, rgb(43, 76, 142) 77.8%, rgb(29, 97, 158) 94.17%);
}

.chatbot-soporte-panel-titulo {
    flex: 1;
    min-width: 0;
    font-size: 20px;
    line-height: 28px;
    font-weight: var(--fs-bold);
    color: #ffffff;
}

.chatbot-soporte-boton-cerrar {
    flex: 0 0 auto;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 50%;
    color: #ffffff !important;
    font-size: 24px !important;
}

.chatbot-soporte-boton-cerrar:hover {
    background-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: none !important;
}

/* Cuerpo del panel */
.chatbot-soporte-panel-cuerpo {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Card CTA "Chatear con soporte" */
.chatbot-soporte-cta-chat {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    border-radius: 52px;
    background: linear-gradient(-41deg, rgb(29, 97, 158) 34.97%, rgb(43, 76, 142) 51.34%, rgb(52, 62, 132) 61.71%, rgb(61, 48, 122) 72.52%, rgb(85, 41, 123) 86.3%, rgb(97, 44, 104) 95.38%);
}

.chatbot-soporte-cta-avatar {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--cta-blue);
    border: 1px solid var(--gray-80);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-soporte-cta-avatar-imagen {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-soporte-cta-textos {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.chatbot-soporte-cta-titulo {
    font-size: 20px;
    line-height: 28px;
    font-weight: var(--fs-bold);
    color: #ffffff;
}

.chatbot-soporte-cta-subtitulo {
    color: #ffffff;
}

.chatbot-soporte-cta-icono {
    flex: 0 0 auto;
    font-size: 24px;
    color: #ffffff;
}

/* Buscador píldora de la deflexión */
.chatbot-soporte-buscador {
    margin-bottom: 0 !important;
    background-color: #ffffff;
    border-radius: 52px;
    padding: 12px 24px;
    filter: drop-shadow(0 6px 6px rgba(64, 64, 173, 0.25));
}

.chatbot-soporte-buscador input.input-filtro {
    height: auto;
    border: 1px solid var(--gray-40);
    border-radius: 8px;
    padding: 10px 8px 10px 44px;
    font-size: 16px;
    line-height: 24px;
    font-weight: var(--fs-medium);
    color: var(--gray-30);
}

.chatbot-soporte-buscador input.input-filtro::placeholder {
    color: var(--gray-30);
    opacity: 1;
}

.chatbot-soporte-buscador .input-icono1 {
    left: 32px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--gray-30);
}

/* Grilla "Problemas más comunes" */
.chatbot-soporte-grid-categorias {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.chatbot-soporte-card-categoria {
    min-height: 80px;
    min-width: 0;
    box-sizing: border-box;
    background-color: #ffffff;
    border: 1px solid var(--gray-60);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.chatbot-soporte-card-categoria-icono {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--cta-blue);
}

.chatbot-soporte-alerta-avance {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 4px;
    background-color: rgba(27, 184, 243, 0.25);
    color: #003e68;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.chatbot-soporte-alerta-avance > i {
    flex: 0 0 24px;
    font-size: 24px;
    line-height: 24px;
    color: inherit;
}

.chatbot-soporte-card-categoria-texto {
    flex: 1;
    min-width: 0;
    color: var(--gray-10);
    overflow-wrap: break-word;
}

/* Card "Manuales" */
.chatbot-soporte-card-manuales {
    display: flex;
    align-items: center;
    gap: 24px;
    border: 1px solid var(--gray-60);
    border-radius: 12px;
    padding: 16px 20px;
    text-decoration: none;
}

.chatbot-soporte-card-manuales-icono {
    flex: 0 0 auto;
    font-size: 24px;
    color: var(--gray-10);
}

.chatbot-soporte-card-manuales-texto {
    flex: 1;
    min-width: 0;
    color: var(--gray-10);
    overflow-wrap: break-word;
}

.chatbot-soporte-card-manuales-boton {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--gray-60);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--gray-10);
}

.contenedor-chatbot-soporte {
    min-height: 220px;
}

.chatbot-soporte-asistente-distintivo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 12px;
    background-color: var(--blue-80);
    color: var(--blue-40);
    font-weight: 600;
}

.chatbot-soporte-asistente-respuesta {
    color: var(--gray-10);
    overflow-wrap: break-word;
}

/* El paso del asistente suma la caja de repregunta a los dos botones de cierre: sin
   acotarle el alto, el composer se come el espacio de la conversación. */
.input-container textarea.chatbot-soporte-repregunta-campo {
    min-height: 64px;
    height: 64px;
}

/* Reservar espacio para leer el hilo, incluso al adjuntar archivos o grabar audio. */
#modal-crear-soporte-flotante .chatbot {
    min-height: 0;
}

#chatbot-soporte-composer {
    flex: 0 1 auto;
    max-height: 48%;
    overflow-y: auto;
    overflow-x: hidden;
}

#chatbot-soporte-composer > .row {
    margin-right: 0;
    margin-left: 0;
}

.chatbot-soporte-editor {
    border: 1px solid var(--gray-60);
    border-radius: 12px;
    padding: 12px;
}

.chatbot-soporte-editor:focus-within {
    border-color: var(--cta-blue);
}

.chatbot-soporte-editor #chatbot-soporte-descripcion {
    height: 80px;
    min-height: 64px;
    max-height: 140px;
    border: 0;
    box-shadow: none;
}

.chatbot-soporte-editor .input-container {
    margin-bottom: 0;
}

.chatbot-soporte-editor .chatbot-adjuntos-barra {
    margin-top: 12px;
    margin-bottom: 0 !important;
}

.chatbot-soporte-editor .chatbot-boton-grabar {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.chatbot-soporte-editor .input-file[data-base64=""] + .file-container .nombre-archivo {
    display: none;
}

.chatbot-soporte-editor .input-file[data-base64=""] + .file-container {
    width: 36px !important;
    height: 36px;
    min-width: 0;
    padding: 0;
    border-radius: 50% !important;
    justify-content: center;
}

.chatbot-soporte-editor .input-file[data-base64=""] + .file-container .elegir-archivo {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.chatbot-soporte-editor .file-container {
    min-height: 36px;
    width: auto;
    gap: 4px;
}

.chatbot-soporte-editor .elegir-archivo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    width: auto;
}

@media (max-height: 600px) {
    #modal-crear-soporte-flotante .chatbot-soporte-panel-cuerpo {
        padding: 12px;
    }

    .chatbot-soporte-editor #chatbot-soporte-descripcion {
        height: 64px;
    }
}

.chatbot-soporte-editor .chatbot-boton-grabar i,
.chatbot-soporte-editor .elegir-archivo i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 1;
}

.chatbot-soporte-editor .chatbot-boton-grabar i::before,
.chatbot-soporte-editor .elegir-archivo i::before {
    vertical-align: 0;
}

#modal-crear-soporte-flotante:has(.chatbot-soporte-editor) .modal-panel-soporte-flotante {
    height: min(880px, calc(100dvh - 40px));
}

/* En móvil el panel ocupa el área visible, incluso al abrir el teclado. */
@media (max-width: 767.98px) {
    .boton-flotante-soporte {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    #modal-crear-soporte-flotante .modal-panel-soporte-flotante,
    #modal-crear-soporte-flotante:has(.chatbot-soporte-editor) .modal-panel-soporte-flotante {
        top: var(--soporte-ventana-superior, 0px);
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        max-width: none;
        height: var(--soporte-ventana-alto, 100dvh);
        max-height: var(--soporte-ventana-alto, 100dvh);
    }

    #modal-crear-soporte-flotante .modal-content {
        height: 100%;
        border-radius: 0 !important;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-panel-header {
        padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
        gap: 8px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-panel-titulo,
    #modal-crear-soporte-flotante .chatbot-soporte-cta-titulo {
        font-size: 18px;
        line-height: 24px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-panel-cuerpo {
        padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        overscroll-behavior: contain;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-panel-cuerpo > * {
        flex-shrink: 0;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-grid-categorias {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-card-categoria,
    #modal-crear-soporte-flotante .chatbot-soporte-card-manuales {
        min-height: 60px;
        padding: 12px 16px;
        gap: 12px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-cta-chat {
        padding: 12px;
        border-radius: 20px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-buscador {
        padding: 8px 12px;
        border-radius: 16px;
    }

    #modal-crear-soporte-flotante .chatbot-soporte-buscador .input-icono1 {
        left: 20px;
    }

    #modal-crear-soporte-flotante .chatbot-burbuja {
        max-width: 100%;
        min-width: 0;
    }

    #modal-crear-soporte-flotante .chatbot-conversacion {
        overscroll-behavior: contain;
    }

    #modal-crear-soporte-flotante .chatbot .col-6 {
        width: 100%;
    }

    #modal-crear-soporte-flotante .chatbot .btn {
        height: auto;
        min-height: 44px;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #modal-crear-soporte-flotante input,
    #modal-crear-soporte-flotante textarea {
        font-size: 16px;
    }

    #chatbot-soporte-composer {
        max-height: 55%;
        overscroll-behavior: contain;
    }
}
