/* Accanto Float Buttons - Direct Overlay with Stacked Buttons */

#afb-float-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Posiciones del contenedor */
#afb-float-container.afb-bottom-right {
    bottom: 20px;
    right: 20px;
}

#afb-float-container.afb-bottom-left {
    bottom: 20px;
    left: 20px;
}

#afb-float-container.afb-top-right {
    top: 20px;
    right: 20px;
}

#afb-float-container.afb-top-left {
    top: 20px;
    left: 20px;
}

/* === BOTÓN PRINCIPAL === */

#afb-main-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: #007cba;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: none;
    outline: none;
    z-index: 10003;
    /* Por encima del overlay y botones */
}

#afb-main-button.active {
    display: none;
}

#afb-main-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

#afb-main-button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 3px;
}

/* Iconos del botón principal */
.afb-main-icon {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 1;
    transform: scale(1) rotate(0deg);
    width: 45px;
    height: 45px;
}

.afb-close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0) rotate(-90deg);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Estados activos del botón principal */
#afb-main-button.active .afb-main-icon {
    opacity: 0;
    transform: scale(0) rotate(90deg);
}

#afb-main-button.active .afb-close-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
}

#afb-main-button.active {
    background-color: #333333;
}

#afb-main-button.active:hover {
    transform: scale(1.05);
}

/* Efecto de pulso en el botón principal */
#afb-main-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: inherit;
    opacity: 0;
    transform: scale(1);
    animation: pulse 3s ease-in-out infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
        transform: scale(1);
    }

    50% {
        opacity: 0.2;
        transform: scale(1.2);
    }

    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

/* === OVERLAY NEGRO DE PANTALLA COMPLETA === */

#afb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#afb-overlay.active {
    display: block;
    opacity: 1;
}

/* Contenedor de botones apilados sobre el overlay */
.afb-stacked-buttons {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(30px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10002;
    bottom: 57px;
    right: 50px;
    gap: 30px;
}

/* Posicionamiento dinámico de botones apilados */
#afb-float-container.afb-bottom-right .afb-stacked-buttons {
    bottom: 95px;
    /* Encima del botón principal */
    right: 20px;
}

#afb-float-container.afb-bottom-left .afb-stacked-buttons {
    bottom: 95px;
    left: 20px;
}

#afb-float-container.afb-top-right .afb-stacked-buttons {
    top: 95px;
    right: 20px;
    flex-direction: column-reverse;
    transform: translateY(-30px);
}

#afb-float-container.afb-top-left .afb-stacked-buttons {
    top: 95px;
    left: 20px;
    flex-direction: column-reverse;
    transform: translateY(-30px);
}

.afb-stacked-buttons.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Botones individuales apilados */
.afb-stacked-button-wrapper {
    display: flex;
    align-items: center;
    flex-direction: column;
    width: 72px;
    gap: 10px;
}

.afb-stacked-button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: #007cba;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    color: white !important;
    font-weight: 600;
    font-size: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.afb-stacked-button-title {
    color: #FFF;
    text-align: center;
    font-family: Roboto;
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 16px;
}

.afb-stacked-button-close {
    background-color: transparent;
    border: 1px solid #fff;
}

.afb-stacked-button:hover {
    transform: scale(1.01);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    text-decoration: none !important;
    color: white !important;
    border-color: rgba(255, 255, 255, 0.3);
}

.afb-stacked-button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}

.afb-stacked-button img {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.afb-button-initials {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    letter-spacing: 1px;
}

/* Animaciones de entrada secuenciales */
.afb-stacked-buttons.active .afb-stacked-button {
    animation: slideInScale 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(1) {
    animation-delay: 0.1s;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(2) {
    animation-delay: 0.2s;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(3) {
    animation-delay: 0.3s;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(4) {
    animation-delay: 0.4s;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(5) {
    animation-delay: 0.5s;
}

.afb-stacked-buttons.active .afb-stacked-button:nth-child(6) {
    animation-delay: 0.6s;
}

@keyframes slideInScale {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.7);
    }

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

/* Para posiciones superiores */
#afb-float-container.afb-top-right .afb-stacked-button,
#afb-float-container.afb-top-left .afb-stacked-button {
    animation-name: slideInScaleTop;
}

@keyframes slideInScaleTop {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.7);
    }

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

/* Tooltips para botones (solo desktop) */
@media (min-width: 769px) {
    .afb-stacked-button::after {
        content: attr(title);
        position: absolute;
        right: 100%;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(255, 255, 255, 0.95);
        color: #333;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        white-space: nowrap;
        margin-right: 12px;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        pointer-events: none;
        z-index: 10003;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }

    .afb-stacked-button::before {
        content: '';
        position: absolute;
        right: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-right: 6px;
        border: 6px solid transparent;
        border-left-color: rgba(255, 255, 255, 0.95);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 10003;
    }

    .afb-stacked-button:hover::after,
    .afb-stacked-button:hover::before {
        opacity: 1;
        visibility: visible;
    }

    /* Ajustar tooltips para posiciones izquierdas */
    #afb-float-container.afb-bottom-left .afb-stacked-button::after,
    #afb-float-container.afb-top-left .afb-stacked-button::after {
        right: auto;
        left: 100%;
        margin-right: 0;
        margin-left: 12px;
    }

    #afb-float-container.afb-bottom-left .afb-stacked-button::before,
    #afb-float-container.afb-top-left .afb-stacked-button::before {
        right: auto;
        left: 100%;
        margin-right: 0;
        margin-left: 6px;
        border-left-color: transparent;
        border-right-color: rgba(255, 255, 255, 0.95);
    }
}

/* Estados de loading */
.afb-stacked-button.afb-loading {
    pointer-events: none;
    opacity: 0.7;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

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

@media (max-width: 768px) {
    #afb-main-button {
        width: 50px;
        height: 50px;
    }

    #afb-main-button img,
    #afb-main-button svg {
        width: 35px;
        height: 35px;
    }

    .afb-stacked-button {
        width: 52px;
        height: 52px;
        gap: 30px;
    }

    .afb-stacked-button img,
    .afb-stacked-button svg {
        width: 24px;
        height: 24px;
    }

    .afb-main-icon img {
        width: 24px;
        height: 24px;
    }

    .afb-button-initials {
        font-size: 12px;
    }

    .afb-stacked-buttons {
        gap: 25px;
        bottom: 20px;
        right: 20px;
    }

    /* Ajustar posiciones para móviles */
    #afb-float-container.afb-bottom-right .afb-stacked-buttons {
        bottom: 85px;
        right: 15px;
    }

    #afb-float-container.afb-bottom-left .afb-stacked-buttons {
        bottom: 85px;
        left: 15px;
    }

    #afb-float-container.afb-top-right .afb-stacked-buttons {
        top: 85px;
        right: 15px;
    }

    #afb-float-container.afb-top-left .afb-stacked-buttons {
        top: 85px;
        left: 15px;
    }
}



/* === MEJORAS DE ACCESIBILIDAD === */

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

    #afb-main-button,
    .afb-stacked-button,
    .afb-stacked-buttons,
    #afb-overlay {
        transition: none !important;
        animation: none !important;
    }

    #afb-main-button::before {
        animation: none !important;
    }
}

/* Ocultar scroll cuando overlay está activo y asegurar cobertura completa */
body.afb-no-scroll {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Asegurar que el overlay esté por encima de todo */
#afb-overlay {
    pointer-events: auto;
    user-select: none;
}

/* Prevenir cualquier interferencia de otros elementos */
#afb-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: auto;
}

/* High contrast mode */
@media (prefers-contrast: high) {

    .afb-stacked-button,
    #afb-main-button {
        border: 3px solid white !important;
    }

    #afb-overlay {
        background: rgba(0, 0, 0, 0.95) !important;
    }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .afb-stacked-button::after {
        background: rgba(40, 40, 40, 0.95);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    .afb-stacked-button::before {
        border-left-color: rgba(40, 40, 40, 0.95);
    }

    #afb-float-container.afb-bottom-left .afb-stacked-button::before,
    #afb-float-container.afb-top-left .afb-stacked-button::before {
        border-left-color: transparent;
        border-right-color: rgba(40, 40, 40, 0.95);
    }
}