/* --- Loader tech --- */
.alf-background-loader {
    position: absolute;
    z-index: 999999;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #0e0e0e;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #fff;
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    transition: opacity 0.3s ease;
    opacity: 1;
    overflow: hidden;
}
.alf-background-loader .alf-loader-bg-svg {
    position: absolute;
    width: 100%; height: 100%;
    left: 0; top: 0;
    object-fit: cover;
    opacity: 0.18;
    z-index: 0;
    pointer-events: none;
}
.alf-background-loader .alf-loader-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.alf-background-loader .alf-spinner {
    margin: 32px 0 16px 0;
    width: 48px; height: 48px;
    border: 6px solid #d32f2f;
    border-top: 6px solid #fff;
    border-radius: 50%;
    animation: alf-spin 1s linear infinite;
    box-shadow: 0 0 16px #d32f2f88;
}
@keyframes alf-spin {
    0% { transform: rotate(0deg);}
    100% { transform: rotate(360deg);}
}
.alf-background-loader .alf-loader-message {
    font-size: 1.1rem;
    color: #fff;
    margin-bottom: 0;
    text-shadow: 0 2px 8px #000a;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
}
.alf-background-loader .alf-loader-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 16px;
}
.alf-background-loader .alf-loader-error.hidden {
    display: none;
}
.alf-background-loader .alf-error-icon {
    width: 56px; height: 56px;
    margin-bottom: 12px;
    background: radial-gradient(circle at 60% 40%, #fff 0%, #d32f2f 80%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.alf-background-loader .alf-error-icon::before,
.alf-background-loader .alf-error-icon::after {
    content: '';
    position: absolute;
    width: 32px; height: 6px;
    background: #fff;
    border-radius: 3px;
    top: 25px; left: 12px;
}
.alf-background-loader .alf-error-icon::before {
    transform: rotate(45deg);
}
.alf-background-loader .alf-error-icon::after {
    transform: rotate(-45deg);
}
.alf-background-loader .alf-error-message {
    color: #fff;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 12px;
    font-weight: 500;
    text-shadow: 0 2px 8px #000a;
}
.alf-background-loader .alf-retry-btn {
    background: linear-gradient(90deg, #ad0000 0%, #d32f2f 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px #ad000088;
    transition: background 0.2s;
}
.alf-background-loader .alf-retry-btn:hover {
    background: linear-gradient(90deg, #d32f2f 0%, #ad0000 100%);
}

/*! Widget general centrado */
.chatbot-widget {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    pointer-events: none !important;
    z-index: 9999 !important;
}

/* ======================= BOTÓN FLOTANTE ======================= */

#chatbot-btn {
    width: 60px;
    height: 60px;
    font-size: 20px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    background: rgb(0, 94, 255);
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.7s cubic-bezier(.38, 1.07, .76, .97);
    position: absolute;
    z-index: 1;
}

#chatbot-btn:hover {
    background: rgb(51, 51, 255);
}

#chatbot-btn.enable-bell:hover {
    animation: bell-swing 0.7s cubic-bezier(.38, 1.07, .76, .97);
}

#chatbot-btn svg {
    width: 34px;
    height: 34px;
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 2;
}

/* ======================= ANIMACIONES DE BOTÓN======================= */

@keyframes bell-swing {
    0%   { transform: rotate(0deg); }
    15%  { transform: rotate(-18deg); }
    30%  { transform: rotate(14deg); }
    45%  { transform: rotate(-10deg); }
    60%  { transform: rotate(7deg); }
    75%  { transform: rotate(-4deg); }
    100% { transform: rotate(0deg); }
}

/* ======================= POSICIONES BOTÓN SIN ABRIR ======================= */

/*! 👉 Posición Inferior Derecha */
.chatbot-widget.position-bottom-right #chatbot-btn {
    bottom: 50px;
    right: 20px;
}

/*! 👉 Posición Inferior Izquierda */
.chatbot-widget.position-bottom-left #chatbot-btn{
    bottom: 50px;
    left: 20px;
}

/*! 👉 Posición Superior Derecha */
.chatbot-widget.position-top-right #chatbot-btn{
    top: 50px;
    right: 20px;
}

/*! 👉 Posición Superior Izquierda */
.chatbot-widget.position-top-left #chatbot-btn{
    top: 50px;
    left: 20px;
}
/* ======================= IFRAME ======================= */

#chatbot-iframe-container {
    height: 0px;
    background: #fff;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.20);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: all 0.7s cubic-bezier(.38, 1.07, .76, .97);
    position: absolute;
    z-index: 0;
}

#chatbot-iframe-container.open {
    opacity: 1;
    pointer-events: auto;
}

#chatbot-iframe-container .chatbot-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0px;
    display: block;
    background: #f8f9fa;
}

/* ======================= POSICIONES IFRAME SIN ABRIR ======================= */

.chatbot-widget.position-bottom-right #chatbot-iframe-container{
    border-radius: 22px 22px 0 0;
    bottom: 0;
    right: 0;
}

.chatbot-widget.position-bottom-left #chatbot-iframe-container{
    border-radius: 22px 22px 0 0;
    bottom: 0;
    left: 0;
}

.chatbot-widget.position-top-right #chatbot-iframe-container{
    border-radius: 0 0 22px 22px;
    top: 0;
    right: 0;
}

.chatbot-widget.position-top-left #chatbot-iframe-container{
    border-radius: 0 0 22px 22px;
    top: 0;
    left: 0;
}

/* ======================= NOTIFICACIONES ======================= */

#alf-notification-bubble {
    position: absolute;
    z-index: 2;
    pointer-events: auto;
    cursor: pointer;
    color: white;
    font-family: sans-serif;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    transition: opacity 0.4s cubic-bezier(.38,1.07,.76,.97);
    display: none;
}

#alf-notification-bubble.isCompact {
    animation: bell-swing 2s cubic-bezier(.38, 1.07, .76, .97) infinite;
}

#alf-notification-bubble.isCompact:hover {
    animation: bell-swing 0.7s cubic-bezier(.38, 1.07, .76, .97);
}

#alf-notification-bubble.isVisible {
    display: flex;
    pointer-events: auto;
}

#alf-notification-bubble .alf-notification-content {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(255, 0, 0);
    color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-weight: 200;
    transition:
        min-width 0.5s cubic-bezier(.38,1.07,.76,.97),
        min-height 0.5s cubic-bezier(.38,1.07,.76,.97),
        width 0.5s cubic-bezier(.38,1.07,.76,.97),
        height 0.5s cubic-bezier(.38,1.07,.76,.97),
        font-size 0.5s cubic-bezier(.38,1.07,.76,.97),
        border-radius 0.5s cubic-bezier(.38,1.07,.76,.97),
        padding 0.5s cubic-bezier(.38,1.07,.76,.97);
    min-width: 40px;
    max-width: 150px;
    min-height: 32px;
    padding: 0px 4px;
    font-size: 16px;
}

#alf-notification-bubble.isCompact .alf-notification-content {
    min-width: 20px;
    min-height: 20px;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50%;
}

/* ======================= POSICIONES NOTIFICACIONES SIN ABRIR ======================= */

.chatbot-widget.position-bottom-right #alf-notification-bubble{
    bottom: 90px;
    right: 70px;
}

.chatbot-widget.position-bottom-left #alf-notification-bubble{
    bottom: 90px;
    left: 70px;
}

.chatbot-widget.position-top-right #alf-notification-bubble{
    top: 90px;
    right: 70px;
}

.chatbot-widget.position-top-left #alf-notification-bubble{
    top: 90px;
    left: 70px;
}

/* ======================= RESPONSIVE ======================= */

/* Responsive para móviles */
@media (min-width: 320px) and (max-width: 767px) {
    #chatbot-iframe-container {
        width: 100%;
    }
    #chatbot-iframe-container.open{
        height: 80%;
    }

    /*! 👉 Posición Inferior Derecha e izquierda apertura */
    .chatbot-widget.position-bottom-right #chatbot-btn.open,
    .chatbot-widget.position-bottom-left #chatbot-btn.open{
        bottom: 83%;
    }

    /*! 👉 Posición Superior Derecha e izquierda apertura */
    .chatbot-widget.position-top-right #chatbot-btn.open,
    .chatbot-widget.position-top-left #chatbot-btn.open{
        top: 83%;
    }
}

/* Responsive para tablets */
@media (min-width: 768px) and (max-width: 1023px) {
    #chatbot-iframe-container {
        width: 80%;
    }

    #chatbot-iframe-container.open {
        height: 80%;
    }

    /*! 👉 Posición Inferior Derecha e izquierda apertura */
    .chatbot-widget.position-bottom-right #chatbot-btn.open,
    .chatbot-widget.position-bottom-left #chatbot-btn.open{
        bottom: 83%;
    }

    /*! 👉 Posición Superior Derecha e izquierda apertura */
    .chatbot-widget.position-top-right #chatbot-btn.open,
    .chatbot-widget.position-top-left #chatbot-btn.open{
        top: 83%;
    }

}

/* Responsive para pantallas grandes */
@media (min-width: 1024px) {
    #chatbot-iframe-container {
        width: 80%;
        width: 420px;
    }

    #chatbot-iframe-container.open {
        height: 95%;
    }

    /*! 👉 Posición Derecha apertura */
    .chatbot-widget.position-top-right #chatbot-btn.open,
    .chatbot-widget.position-bottom-right #chatbot-btn.open {
        right: 430px;
    }

    /*! 👉 Posición Izquierda apertura */
    .chatbot-widget.position-top-left #chatbot-btn.open,
    .chatbot-widget.position-bottom-left #chatbot-btn.open {
        left: 430px;
    }

}