/* ==========================================================================
   Beautiful Back to Top Plugin Stylesheet
   ========================================================================== */

/* Ẩn triệt để nút Back to Top mặc định của Flatsome và các theme khác */
#toTop, 
.back-to-top, 
.scroll-to-top,
a[href="#top"].back-to-top {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Nút Back to Top chính */
.beautiful-back-to-top {
    position: fixed;
    right: 30px;
    bottom: 30px;
    height: 46px;
    width: 46px;
    cursor: pointer;
    display: block;
    border-radius: 50%;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(0.9);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: 
        opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
        visibility 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
        transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
        box-shadow 0.3s ease,
        background-color 0.3s ease;
}

/* Khi nút được kích hoạt hiển thị */
.beautiful-back-to-top.active-progress {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Tương tác khi Hover */
.beautiful-back-to-top:hover {
    background-color: #ffffff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px) scale(1.05);
}

/* Cấu trúc SVG tiến độ hình tròn */
.beautiful-back-to-top svg.progress-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.beautiful-back-to-top svg.progress-circle path {
    fill: none;
    stroke: rgba(0, 0, 0, 0.06); /* Vòng tròn nền xám mờ trung tính */
    stroke-width: 3.5;
    box-sizing: border-box;
}

/* Nét vẽ tiến độ lấy động theo màu chủ đạo của website */
.beautiful-back-to-top svg.progress-circle path.progress-path {
    stroke: var(--bbtt-primary-color, #4f46e5); /* Sử dụng biến CSS động */
    stroke-width: 3.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 10ms linear;
}

/* Biểu tượng mũi tên */
.beautiful-back-to-top .arrow-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    color: var(--bbtt-primary-color, #4f46e5); /* Sử dụng biến CSS động */
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.beautiful-back-to-top .arrow-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hiệu ứng trượt mũi tên khi Hover */
.beautiful-back-to-top:hover .arrow-icon svg {
    animation: arrowSlideUp 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes arrowSlideUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    49% {
        transform: translateY(-18px);
        opacity: 0;
    }
    50% {
        transform: translateY(18px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive trên thiết bị di động (Mobile) */
@media (max-width: 767px) {
    .beautiful-back-to-top {
        right: 20px;
        bottom: 20px;
        height: 40px;
        width: 40px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    }
    
    .beautiful-back-to-top .arrow-icon {
        width: 14px;
        height: 14px;
    }

    .beautiful-back-to-top:hover {
        /* Tránh phóng to quá mức hoặc hiệu ứng quá nhạy trên cảm ứng */
        transform: translateY(0) scale(1);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    }
    
    .beautiful-back-to-top:hover .arrow-icon svg {
        animation: none; /* Tắt micro-animation trên di động để tối ưu hiệu năng */
    }
}
