/*
 * BCE Advanced Popups - frontend.css
 * Phiên bản hoàn chỉnh, đã cập nhật tất cả các yêu cầu về giao diện mobile.
 */

/* =================================== */
/* == STYLE CHUNG & NỀN TẢNG          == */
/* =================================== */

.bce-popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99998;
    display: flex;
    padding: 20px;
    box-sizing: border-box;
    /* Ẩn ban đầu */
    visibility: hidden;
    opacity: 0;
    /* Hiệu ứng mờ dần cho nền */
    transition: visibility 0s 0.4s, opacity 0.4s ease;
}

.bce-popup-container.bce-popup-visible {
    visibility: visible;
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.6);
    transition-delay: 0s;
}

.bce-popup-content {
    background: #fff;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    position: relative;
    max-width: 100%;
    max-height: 100%;
    overflow-y: auto; /* Mặc định cho phép cuộn */
    box-sizing: border-box;
}

.bce-popup-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: #f1f1f1;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #555;
    line-height: 1;
    z-index: 10;
}

.bce-popup-close-button:hover { background: #e0e0e0; }

/* =================================== */
/* == GIAO DIỆN PC (Màn hình lớn)    == */
/* =================================== */

.bce-popup-container {
    justify-content: center;
    align-items: center;
}
.bce-popup-container.pos-top-left { justify-content: flex-start; align-items: flex-start; }
.bce-popup-container.pos-top-center { justify-content: center; align-items: flex-start; }
.bce-popup-container.pos-top-right { justify-content: flex-end; align-items: flex-start; }
.bce-popup-container.pos-bottom-left { justify-content: flex-start; align-items: flex-end; }
.bce-popup-container.pos-bottom-center { justify-content: center; align-items: flex-end; }
.bce-popup-container.pos-bottom-right { justify-content: flex-end; align-items: flex-end; }

.bce-popup-content {
    opacity: 0;
    transform: scale(0.95);
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.bce-popup-container.bce-popup-visible .bce-popup-content {
    opacity: 1;
    transform: scale(1);
}

/* ======================================================= */
/* == GIAO DIỆN MOBILE (Màn hình nhỏ) - ĐÃ SỬA ĐỔI      == */
/* ======================================================= */

@media (max-width: 768px) {
    .bce-popup-container {
        justify-content: center !important;
        align-items: flex-end !important;
        padding: 0 !important;
    }

    /*
     * **KHẮC PHỤC LỖI THANH CUỘN**
     * 1. Biến container chính thành flexbox.
     * 2. Tắt cuộn trên container chính.
     * 3. Bật cuộn trên khu vực nội dung Elementor.
    */
    .bce-popup-content {
        width: 100% !important;
        max-height: 85vh;
        border-radius: 16px 16px 0 0 !important;
        margin: 0 !important;
        padding: 60px 0 0 0 !important; /* Chỉ giữ padding-top để tạo không gian cho header */
        
        display: flex !important; /* Bật flexbox */
        flex-direction: column !important; /* Sắp xếp theo chiều dọc */
        overflow: hidden !important; /* Tắt cuộn ở container cha */
        
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .bce-popup-container.bce-popup-visible .bce-popup-content {
        transform: translateY(0);
    }
    
    /* Đường kẻ ngang */
    .bce-popup-content::before {
        content: '';
        position: absolute;
        top: 50px;
        left: 20px;
        right: 20px;
        height: 1px;
        background-color: #EAEAEA;
        z-index: 1;
    }
    
    /* Nút đóng (X) */
    .bce-popup-close-button {
        top: 12px;
        right: 15px;
        width: 28px !important;
        height: 28px !important;
        background: transparent !important;
        font-size: 0 !important;
        z-index: 2;
    }

    .bce-popup-close-button::before,
    .bce-popup-close-button::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 14px;
        height: 2px;
        background-color: #000000;
        transform-origin: center;
    }
    .bce-popup-close-button::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }
    .bce-popup-close-button::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }
    
    /*
     * **KHU VỰC NỘI DUNG CHÍNH (ELEMENTOR)**
     * Đây là khu vực sẽ có thanh cuộn.
    */
    .bce-popup-content .elementor {
        flex: 1; /* Cho phép co giãn để lấp đầy không gian còn lại */
        overflow-y: auto !important; /* BẬT CUỘN CHỈ Ở ĐÂY */
        padding: 0 20px 20px 20px; /* Thêm padding cho nội dung */
    }

    /*
     * Tùy chỉnh thanh cuộn cho khu vực nội dung
    */
    .bce-popup-content .elementor {
        scrollbar-width: thin;
        scrollbar-color: #C1C1C1 transparent;
    }

    .bce-popup-content .elementor::-webkit-scrollbar {
        width: 5px;
    }
    
    .bce-popup-content .elementor::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .bce-popup-content .elementor::-webkit-scrollbar-thumb {
        background-color: #CCCCCC;
        border-radius: 10px;
    }
}