/* ==========================================================================
   Popup đăng ký nhận Ebook - xem inc/ebook-popup.php
   ========================================================================== */

html.vep-lock,
html.vep-lock body {
    overflow: hidden;
}

.vep[hidden] {
    display: none;
}

.vep {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity .25s ease;
}

.vep.is-open {
    opacity: 1;
}

.vep__overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 16, 32, .6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.vep__dialog {
    /* Chiều cao popup cố định vừa với nội dung form (không để banner dọc rất cao
       kéo giãn cả popup) -> ảnh bìa bên trái dùng object-fit: cover để lấp đầy khung,
       cắt bớt lề trên/dưới thay vì letterbox. */
    --vep-cover-w: 400px;
    position: relative;
    display: grid;
    grid-template-columns: var(--vep-cover-w) minmax(0, 1fr);
    width: 100%;
    max-width: calc(var(--vep-cover-w) + 560px);
    height: min(600px, calc(100vh - 48px));
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
    transform: translateY(16px) scale(.98);
    transition: transform .25s ease;
    outline: none;
}

.vep.is-open .vep__dialog {
    transform: none;
}

.vep__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #F1F4FA;
    color: #4A5270;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.vep__close:hover,
.vep__close:focus-visible {
    background: #E1E8F5;
    color: #1A1F36;
}

/* --- Banner (trái) -------------------------------------------------------- */

.vep__cover {
    min-height: 0;
    background: #E6EDFD;
}

.vep__cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Nội dung (phải) ------------------------------------------------------ */

.vep__body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 40px 40px 28px;
    color: #4B5563;
}

/* Căn giữa theo chiều dọc bằng margin auto (không dùng justify-content: center
   vì khi nội dung dài hơn khung, phần đầu bị cắt mất, không cuộn tới được). */
.vep__body > :first-child {
    margin-top: auto;
}

.vep__body > :last-child {
    margin-bottom: auto;
}

.vep__eyebrow {
    /* max-width (không phải margin-right) để chừa chỗ cho nút đóng: trong flex
       column, item bị stretch rồi mới cộng thêm margin -> margin-right ở đây sẽ
       làm item TRÀN ra ngoài .vep__body đúng bằng giá trị margin, gây cuộn ngang. */
    max-width: calc(100% - 44px);
    margin: 0 0 8px;
    color: #2563EB;
    font-size: 13px;
    font-weight: 700;
    line-height: 20px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.vep__title {
    max-width: calc(100% - 36px);
    margin: 0 0 8px;
    color: #1A1F36;
    font-size: 26px;
    font-weight: 700;
    line-height: 1.3;
}

.vep__desc {
    max-width: 430px;
    margin: 0 0 20px;
    color: #6B7280;
    font-size: 15px;
    line-height: 1.55;
}

/* --- Form (CF7, class vep-form gắn qua html_class) ---------------------- */

.vep .vep-form p {
    margin: 0;
}

.vep .vep-form br {
    display: none;
}

.vep .vep-form__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}

.vep .vep-form__field {
    min-width: 0;
}

.vep .vep-form__field--full {
    grid-column: 1 / -1;
}

.vep .vep-form .wpcf7-form-control-wrap {
    display: block;
}

.vep .vep-form input.wpcf7-form-control:not(.wpcf7-submit),
.vep .vep-form select.wpcf7-form-control {
    display: block;
    width: 100%;
    height: 46px;
    min-height: 0;
    margin: 0;
    padding: 0 16px;
    border: 1px solid #D5DAE3;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: none;
    color: #1A1F36;
    font-size: 15px;
    font-weight: 400;
    line-height: 44px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.vep .vep-form select.wpcf7-form-control {
    padding-right: 44px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

/* Option đầu (value rỗng) đóng vai placeholder -> cùng màu với placeholder của input */
.vep .vep-form select.wpcf7-form-control:has(option[value=""]:checked) {
    color: #6B7280;
}

.vep .vep-form select.wpcf7-form-control option {
    color: #1A1F36;
}

.vep .vep-form .wpcf7-form-control::placeholder {
    color: #6B7280;
    opacity: 1;
    /* đè rule ::placeholder global của theme -> cùng cỡ chữ với input/select */
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.vep .vep-form input.wpcf7-form-control:not(.wpcf7-submit):focus,
.vep .vep-form select.wpcf7-form-control:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
}

.vep .vep-form .wpcf7-form-control-wrap .wpcf7-form-control.wpcf7-not-valid {
    border-color: #E5484D;
}

/* Flatsome vẽ tip thành bong bóng nền xám (.wpcf7 .wpcf7-not-valid-tip) -> đổi về dòng chữ gọn */
.vep .vep-form .wpcf7-not-valid-tip {
    display: block;
    margin: 4px 0 0 2px;
    padding: 0;
    border-radius: 0;
    background: none;
    opacity: 1;
    color: #E5484D;
    font-size: 12px;
    line-height: 16px;
}

.vep .vep-form .wpcf7-not-valid-tip::after {
    display: none;
}

.vep .vep-form__actions {
    margin-top: 20px;
}

.vep .vep-form .wpcf7-submit {
    display: block;
    width: 100%;
    height: 52px;
    margin: 0;
    padding: 0 24px;
    border: 0;
    border-radius: 30px;
    background: linear-gradient(90deg, #4F8DFD 0%, #2563EB 100%);
    box-shadow: 0 10px 24px rgba(37, 99, 235, .35);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    line-height: 52px;
    letter-spacing: .3px;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter .2s ease, transform .2s ease;
}

.vep .vep-form .wpcf7-submit:hover {
    filter: brightness(1.06);
}

.vep .vep-form .wpcf7-submit:active {
    transform: translateY(1px);
}

.vep .vep-form.submitting .wpcf7-submit {
    opacity: .6;
    pointer-events: none;
}

.vep .vep-form .wpcf7-spinner {
    display: none;
}

/* Đè bằng cách lặp .vep-form (thay vì !important): rule .vep .vep-form p ở trên
   có thêm bộ chọn thẻ "p" nên độ ưu tiên cao hơn .vep-form__note, luôn ghi đè
   mất margin-top đặt ở đây. */
.vep .vep-form .vep-form__note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 0;
    color: #6B7280;
    font-size: 14px;
    line-height: 20px;
}

.vep .vep-form__note::before {
    content: "";
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%236B7280' d='M12 2 4 5v6c0 5.25 3.4 10.15 8 11.4 4.6-1.25 8-6.15 8-11.4V5l-8-3Z'/%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E") no-repeat center / contain;
}

.vep .vep-form .wpcf7-response-output {
    margin: 12px 0 0;
    padding: 0;
    border: 0;
    color: #E5484D;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
}

.vep .vep-form.sent .wpcf7-response-output {
    color: #0FA44A;
}

@media (max-width: 1023px) {
    .vep__dialog {
        --vep-cover-w: 320px;
        height: min(560px, calc(100vh - 48px));
    }

    .vep__body {
        padding: 32px 28px 22px;
    }

    .vep__title {
        font-size: 22px;
    }
}

/* Dưới 900px không đủ chỗ cho banner + form -> chỉ còn form, cao theo nội dung. */
@media (max-width: 899px) {
    .vep {
        padding: 16px;
    }

    .vep__dialog {
        grid-template-columns: 1fr;
        max-width: 560px;
        height: auto;
        max-height: calc(100vh - 32px);
        max-height: calc(100dvh - 32px);
        border-radius: 12px;
    }

    .vep__cover {
        display: none;
    }
}

@media (max-width: 767px) {
    .vep__body {
        padding: 32px 18px 22px;
    }

    .vep__title {
        font-size: 22px;
    }

    .vep__desc {
        margin-bottom: 20px;
        font-size: 14px;
    }

    .vep .vep-form__grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .vep .vep-form input.wpcf7-form-control:not(.wpcf7-submit),
    .vep .vep-form select.wpcf7-form-control {
        height: 48px;
        line-height: 46px;
    }

    .vep .vep-form .wpcf7-submit {
        height: 52px;
        font-size: 17px;
        line-height: 52px;
    }

    .vep .vep-form__note {
        font-size: 13px;
    }
}
