/* ================= CSS CHO CONTACT WIDGET SECTION ================= */

.modal.fade {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1055;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

.modal-dialog {
    position: relative;
    width: auto;
    margin: 1.75rem auto;
    pointer-events: none;
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    outline: 0;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 3.5rem);
}

#myModalCallAuto,
#trialRegistrationModal {
    display: none;
}

/* --- CỤM NÚT LIÊN HỆ NỔI (Stack từ dưới lên: Zalo -> Messenger -> Call) --- */
.master-contact-widget {
    position: fixed;
    bottom: 20px; /* Điều chỉnh để tất cả nút có vị trí đồng nhất */
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

/* --- NÚT CHUNG --- */
.contact-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease-in-out;
}

.contact-btn:hover {
    transform: scale(1.1);
    color: #fff;
}

.contact-btn i {
    font-size: 26px;
}

.contact-btn img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

/* --- TỪNG LOẠI NÚT --- */
.messenger-btn {
    background-color: #0084ff;
}

.call-btn {
    background-color: #16a500;
}

.zalo-btn {
    background-color: #0068ff;
    display: none; /* Ẩn mặc định */
}

/* --- NỘI DUNG TRONG NÚT GỌI --- */
.call-btn-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.call-btn-content i {
    font-size: 22px;
}

.call-btn-content span {
    font-size: 13px;
    font-weight: 500;
    margin-top: 2px;
}

/* --- VỊ TRÍ WIDGET ZALO SDK (Ở DƯỚI CÙNG, bên dưới master-contact-widget) --- */
.zalo-chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99998 !important; /* Cao hơn để hiển thị trên cùng */
    pointer-events: auto !important;
    display: none !important; /* Ẩn Zalo SDK widget mặc định */
}

/* Hiển thị nút Zalo custom trên cả mobile và desktop */
.zalo-btn.mobile-only {
    display: flex !important; /* Hiển thị trên tất cả màn hình */
}

/* MOBILE: Ẩn Zalo SDK, hiện nút redirect */
@media (max-width: 768px) {
    .zalo-chat-widget {
        display: none !important;
    }

    .master-contact-widget {
        bottom: 20px;
    }
}

/* DESKTOP: Hiện Zalo SDK, ẩn nút redirect */
@media (min-width: 769px) {
    .zalo-chat-widget {
        display: none !important;
    }

    .master-contact-widget {
        bottom: 20px;
    }
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .master-contact-widget {
        right: 10px;
        bottom: 20px !important; /* Override trên mobile */
        gap: 10px;
        margin-bottom: 40px;
    }

    .contact-btn {
        width: 48px;
        height: 48px;
    }

    .contact-btn i {
        font-size: 22px;
    }
    
    .contact-btn img {
        width: 24px;
        height: 24px;
    }
    
    /* Điều chỉnh icon trong nút Call trên mobile */
    .call-btn-content i {
        font-size: 20px;
    }
    
    .call-btn-content span {
        font-size: 11px;
    }
}

/* --- POPUP GỌI LẠI --- */
#myModalCallAuto .modal-dialog {
    max-width: 400px;
    margin: 1.75rem auto;
}

#myModalCallAuto .modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: left;
}

#myModalCallAuto .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 12px;
    border-bottom: none;
}

#myModalCallAuto .title-call-1 {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    margin: 0;
}

#myModalCallAuto .close {
    opacity: 0.6;
    font-size: 24px;
    border: none;
    background: transparent;
}

#myModalCallAuto .close:hover {
    opacity: 1;
}

#myModalCallAuto .modal-body {
    padding: 0 24px 24px;
}

#myModalCallAuto .desc-call-1 {
    font-size: 15px;
    color: #555;
    margin-bottom: 20px;
    display: block;
}

#myModalCallAuto .form-group {
    margin-bottom: 16px;
}

#myModalCallAuto .form-control {
    background-color: #f5f5f5;
    border: 1px solid #f5f5f5;
    border-radius: 12px;
    height: 52px;
    padding: 0 16px;
    font-size: 16px;
    width: 100%;
}

#myModalCallAuto .form-control:focus {
    background-color: #fff;
    border-color: #ff416c;
    box-shadow: none;
}

.submit-btn-modal {
    width: 100%;
    background: linear-gradient(to right, #ff4b2b, #ff416c);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 14px;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}

.submit-btn-modal:hover {
    opacity: 0.9;
}

.desc-call-footer {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: #666;
}

.modal.fade {
    transition: opacity 0.15s linear;
}

.modal.fade:not(.show) {
    opacity: 0;
}

/* --- FIX: Backdrop mặc định không chặn click khi chưa mở modal --- */
#modal-backdrop {
    display: none;           /* Ẩn mặc định để không che trang */
    position: fixed;
    inset: 0;
    opacity: 0;              /* Trong suốt khi chưa mở */
    pointer-events: none;    /* Không bắt sự kiện chuột */
    background: #000;        /* Màu nền khi mở */
}
#modal-backdrop.show {
    display: block;          /* Hiện khi mở modal */
    opacity: .5;             /* Độ mờ backdrop */
    pointer-events: auto;    /* Cho phép chặn click nền */
}

/* Giữ hiệu ứng fade nếu dùng class .fade */
.modal-backdrop.fade {
    transition: opacity 0.15s linear;
}
.modal-backdrop.fade:not(.show) {
    opacity: 0;
}

/* CSS cho ảnh nền tạm thời trong lúc chờ video */
#youtube-video-placeholder {
    /* Đặt ảnh nền chất lượng cao của video của bạn ở đây */
    background-image: url('https://i.ytimg.com/vi/kC2Ptm2TBoE/maxresdefault.jpg');
    background-size: cover;
    background-position: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform: scale(1.5); /* Giữ nguyên hiệu ứng phóng to */
}

/* --- POPUP ĐĂNG KÝ  --- */
#trialRegistrationModal {
    z-index: 1055;
}

#trialRegistrationModal .modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
}

#trialRegistrationModal .trial-modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    background: #fff;
    overflow: hidden;
}

#trialRegistrationModal .trial-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 30px 20px;
    border-bottom: none;
    background: #fff;
}

#trialRegistrationModal .trial-modal-logo {
    text-align: center;
    flex: 1;
}

#trialRegistrationModal .trial-logo-image {
    max-width: 120px;
    height: auto;
    margin: 0 auto 8px;
    display: block;
}

#trialRegistrationModal .trial-logo-tagline {
    font-size: 14px;
    color: var(--color-font);
    font-weight: 400;
}

#trialRegistrationModal .trial-modal-header .close {
    opacity: 0.6;
    font-size: 28px;
    border: none;
    background: transparent;
    color: #000;
    padding: 0;
    margin: 0;
    line-height: 1;
    position: absolute;
    right: 20px;
    top: 20px;
}

#trialRegistrationModal .trial-modal-header .close:hover {
    opacity: 1;
}

#trialRegistrationModal .trial-modal-body {
    padding: 0 30px 30px;
    text-align: center;
}

#trialRegistrationModal .trial-modal-title {
    font-size: 28px;
    font-weight: 700;
    color: #000;
    margin: 0 0 10px;
    line-height: 1.2;
}

#trialRegistrationModal .trial-modal-subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 30px;
}

#trialRegistrationModal .trial-form-group {
    margin-bottom: 20px;
    position: relative;
}

#trialRegistrationModal .trial-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
    z-index: 1;
}

#trialRegistrationModal .trial-form-control {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    height: 52px;
    padding: 0 16px;
    padding-left: 45px;
    font-size: 16px;
    width: 100%;
    transition: all 0.3s;
}

#trialRegistrationModal .trial-form-control:focus {
    background-color: #fff;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(0, 167, 94, 0.1);
    outline: none;
}

#trialRegistrationModal select.trial-form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

#trialRegistrationModal .trial-submit-btn {
    width: 100%;
    background: linear-gradient(90deg, #00A75E 0%, #6FE69A 84.67%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    padding: 16px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s;
}

#trialRegistrationModal .trial-submit-btn:hover {
    box-shadow: 0px 1px 20px 0px #17B46B;
    transform: translateY(-1px);
}

#trialRegistrationModal .trial-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

#trialRegistrationModal .trial-modal-footer {
    margin-top: 20px;
}

#trialRegistrationModal .trial-login-link {
    font-size: 14px;
    color: #666;
    margin: 0;
}

#trialRegistrationModal .trial-login-link a {
    color: var(--green);
    font-weight: 500;
    text-decoration: none;
}

#trialRegistrationModal .trial-login-link a:hover {
    text-decoration: underline;
}

/* Backdrop for Trial Modal */
#trial-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    background: #000;
    z-index: 1050;
}

#trial-modal-backdrop.show {
    display: block;
    opacity: .5;
    pointer-events: auto;
}

/* --- Thanh CTA cố định đáy màn hình (mobile) --- */
.mobile-sticky-bar {
    display: none;
}

@media (max-width: 768px) {
    body:has(.mobile-sticky-bar) {
        padding-bottom: 76px;
    }

    .mobile-sticky-bar {
        display: flex;
        align-items: stretch;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99998;
        background: linear-gradient(180deg, #1a7f3c 0%, #155f2e 100%);
        border-radius: 16px 16px 0 0;
        padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
        gap: 0;
    }

    .mobile-sticky-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-width: 0;
        padding: 4px 6px;
        border: none;
        border-left: 1px solid rgba(255, 255, 255, 0.25);
        background: transparent;
        color: #fff;
        text-decoration: none;
        cursor: pointer;
        font-family: inherit;
        text-align: left;
    }

    .mobile-sticky-item:first-child {
        border-left: none;
    }

    .mobile-sticky-icon {
        flex-shrink: 0;
        font-size: 18px;
        line-height: 1;
        display: flex;
        align-items: center;
    }

    .mobile-sticky-icon i {
        font-size: 20px;
    }

    .mobile-sticky-text {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .mobile-sticky-text strong {
        font-size: 11px;
        font-weight: 700;
        line-height: 1.25;
        white-space: nowrap;
    }

    .mobile-sticky-text small {
        font-size: 9px;
        opacity: 0.9;
        line-height: 1.2;
        white-space: nowrap;
    }

    .mobile-sticky-cta {
        flex-shrink: 0;
        align-self: center;
        margin-left: 6px;
        padding: 10px 12px;
        border: none;
        border-radius: 10px;
        background: #f59e0b;
        color: #111;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.02em;
        white-space: nowrap;
        cursor: pointer;
        font-family: inherit;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .mobile-sticky-cta:active {
        transform: scale(0.98);
    }

    /* Nút liên hệ nổi nằm trên thanh CTA */
    .master-contact-widget {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}
