/**
 * Popup AIWeb — CSS thuần, prefix .aiwp- để không đụng CSS của landing.
 * Màu nhấn truyền qua biến inline --aiwp-accent.
 */

.aiwp-root {
    --aiwp-accent: #d97706;
    --aiwp-radius: 16px;
    --aiwp-shadow: 0 18px 48px -12px rgba(15, 23, 42, .28);
    position: fixed;
    z-index: 2147483000;
    inset: auto;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
    color: #1f2937;
}

.aiwp-root[hidden] {
    display: none !important;
}

.aiwp-root *,
.aiwp-root *::before,
.aiwp-root *::after {
    box-sizing: border-box;
}

/* ── Backdrop ───────────────────────────────────────────────────────── */
.aiwp-backdrop {
    position: fixed;
    inset: 0;
    opacity: 0;
    transition: opacity .28s ease;
}

.aiwp-root.aiwp-open .aiwp-backdrop {
    opacity: 1;
}

.aiwp-overlay-light .aiwp-backdrop { background: rgba(15, 23, 42, .28); }
.aiwp-overlay-dark  .aiwp-backdrop { background: rgba(15, 23, 42, .62); }
.aiwp-overlay-blur  .aiwp-backdrop { background: rgba(15, 23, 42, .38); backdrop-filter: blur(4px); }

/* ── Panel chung ────────────────────────────────────────────────────── */
.aiwp-panel {
    position: fixed;
    background: #fff;
    border-radius: var(--aiwp-radius);
    box-shadow: var(--aiwp-shadow);
    overflow: hidden;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    opacity: 0;
    transition: opacity .3s ease, transform .3s cubic-bezier(.16, 1, .3, 1);
}

/* Popup nhiều thông điệp: chỉ panel được JS chọn mới bỏ hidden. */
.aiwp-panel[hidden] {
    display: none !important;
}

.aiwp-root.aiwp-open .aiwp-panel {
    opacity: 1;
    transform: none;
}

.aiwp-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aiwp-media {
    line-height: 0;
    background: #f8fafc;
}

.aiwp-media img {
    display: block;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
}

.aiwp-heading {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #0f172a;
}

.aiwp-body {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #475569;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.aiwp-body p { margin: 0 0 8px; }
.aiwp-body p:last-child { margin-bottom: 0; }
.aiwp-body a { color: var(--aiwp-accent); text-decoration: underline; }
.aiwp-body ul, .aiwp-body ol { margin: 0 0 8px; padding-left: 1.25em; }
.aiwp-body li { margin: 0 0 4px; }
.aiwp-body h1, .aiwp-body h2, .aiwp-body h3, .aiwp-body h4, .aiwp-body h5, .aiwp-body h6 {
    margin: 0 0 8px;
    color: #0f172a;
    line-height: 1.25;
    font-weight: 700;
}
.aiwp-body h1 { font-size: 1.35em; }
.aiwp-body h2 { font-size: 1.2em; }
.aiwp-body h3 { font-size: 1.08em; }
.aiwp-body h4, .aiwp-body h5, .aiwp-body h6 { font-size: 1em; }
.aiwp-body img { max-width: 100%; height: auto; border-radius: 8px; display: block; margin: 8px 0; }
.aiwp-body blockquote {
    margin: 8px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--aiwp-accent);
    color: #64748b;
    background: rgba(15, 23, 42, .03);
}
.aiwp-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .92em; }
.aiwp-body th, .aiwp-body td { border: 1px solid #e2e8f0; padding: 6px 8px; text-align: left; }
.aiwp-body th { background: #f8fafc; }
.aiwp-body code, .aiwp-body pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .9em;
    background: #f1f5f9;
    border-radius: 4px;
}
.aiwp-body code { padding: 1px 5px; }
.aiwp-body pre { padding: 10px; overflow-x: auto; margin: 8px 0; }
.aiwp-body hr { border: 0; border-top: 1px solid #e2e8f0; margin: 12px 0; }
.aiwp-body figure { margin: 8px 0; }
.aiwp-body figcaption { font-size: .85em; color: #94a3b8; margin-top: 4px; }

/* ── Nút ────────────────────────────────────────────────────────────── */
.aiwp-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .82);
    color: #475569;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    transition: background .18s ease, color .18s ease;
}

.aiwp-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.aiwp-close:focus-visible,
.aiwp-cta:focus-visible,
.aiwp-input:focus-visible,
.aiwp-dismiss:focus-visible,
.aiwp-coupon-copy:focus-visible {
    outline: 2px solid var(--aiwp-accent);
    outline-offset: 2px;
}

.aiwp-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    background: var(--aiwp-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: filter .18s ease, transform .18s ease;
}

.aiwp-cta:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
}

.aiwp-cta[disabled] {
    opacity: .6;
    cursor: progress;
    transform: none;
}

.aiwp-dismiss {
    align-self: center;
    padding: 4px;
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.aiwp-dismiss:hover { color: #64748b; }

/* ── Form thu lead ──────────────────────────────────────────────────── */
.aiwp-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.aiwp-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d8dee9;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: #1f2937;
    background: #fff;
}

.aiwp-input:focus {
    border-color: var(--aiwp-accent);
    outline: none;
}

.aiwp-msg {
    margin: 0;
    font-size: 13px;
    color: #475569;
}

.aiwp-msg.aiwp-msg-error { color: #dc2626; }
.aiwp-msg.aiwp-msg-ok { color: #16a34a; }

.aiwp-embed iframe {
    width: 100%;
    min-height: 420px;
    border: none;
}

/* ── Coupon ─────────────────────────────────────────────────────────── */
.aiwp-coupon {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.aiwp-coupon code {
    flex: 1;
    padding: 11px 14px;
    border: 1px dashed var(--aiwp-accent);
    border-radius: 10px;
    background: #fffbeb;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    color: #0f172a;
    word-break: break-all;
}

.aiwp-coupon-copy {
    padding: 0 14px;
    border: 1px solid #d8dee9;
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
}

.aiwp-coupon-copy:hover { background: #f8fafc; }

/* ── Countdown ──────────────────────────────────────────────────────── */
.aiwp-countdown {
    display: flex;
    gap: 8px;
}

.aiwp-cd-unit {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-radius: 10px;
    background: #f8fafc;
}

.aiwp-cd-unit b {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--aiwp-accent);
}

.aiwp-cd-unit i {
    font-size: 11px;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
}

/* ── Kiểu: slide_in ─────────────────────────────────────────────────── */
.aiwp-type-slide_in .aiwp-panel {
    width: 380px;
}

.aiwp-type-slide_in.aiwp-size-sm .aiwp-panel { width: 320px; }
.aiwp-type-slide_in.aiwp-size-lg .aiwp-panel { width: 440px; }
.aiwp-type-slide_in.aiwp-size-xl .aiwp-panel { width: 520px; }

.aiwp-type-slide_in.aiwp-pos-bottom-right .aiwp-panel { right: 20px; bottom: 20px; transform: translateY(16px); }
.aiwp-type-slide_in.aiwp-pos-bottom-left  .aiwp-panel { left: 20px;  bottom: 20px; transform: translateY(16px); }
.aiwp-type-slide_in.aiwp-pos-top-right    .aiwp-panel { right: 20px; top: 20px;    transform: translateY(-16px); }
.aiwp-type-slide_in.aiwp-pos-top-left     .aiwp-panel { left: 20px;  top: 20px;    transform: translateY(-16px); }

/* ── Kiểu: bar ──────────────────────────────────────────────────────── */
.aiwp-type-bar .aiwp-panel {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-shadow: 0 2px 18px rgba(15, 23, 42, .14);
}

.aiwp-type-bar.aiwp-pos-top .aiwp-panel { top: 0; transform: translateY(-100%); }
.aiwp-type-bar.aiwp-pos-bottom .aiwp-panel { bottom: 0; transform: translateY(100%); }

.aiwp-type-bar .aiwp-content {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 14px 56px 14px 20px;
}

.aiwp-type-bar .aiwp-heading { font-size: 16px; }
.aiwp-type-bar .aiwp-body { font-size: 14px; }
.aiwp-type-bar .aiwp-cta { padding: 9px 18px; font-size: 14px; }
.aiwp-type-bar .aiwp-form { flex-direction: row; align-items: center; flex-wrap: wrap; }
.aiwp-type-bar .aiwp-input { width: auto; min-width: 200px; }
.aiwp-type-bar .aiwp-close { top: 50%; right: 12px; transform: translateY(-50%); }
.aiwp-type-bar .aiwp-msg { flex-basis: 100%; text-align: center; }

/* ── Kiểu: modal ────────────────────────────────────────────────────── */
.aiwp-type-modal .aiwp-panel {
    width: 460px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(.96);
}

.aiwp-type-modal.aiwp-size-sm .aiwp-panel { width: 380px; }
.aiwp-type-modal.aiwp-size-lg .aiwp-panel { width: 560px; }
.aiwp-type-modal.aiwp-size-xl .aiwp-panel { width: 680px; }

.aiwp-type-modal.aiwp-open .aiwp-panel {
    transform: translate(-50%, -50%) scale(1);
}

.aiwp-type-modal.aiwp-pos-top-center .aiwp-panel {
    top: 8vh;
    transform: translate(-50%, -12px) scale(.98);
}

.aiwp-type-modal.aiwp-pos-top-center.aiwp-open .aiwp-panel {
    transform: translate(-50%, 0) scale(1);
}

.aiwp-type-modal .aiwp-content { padding: 28px; }
.aiwp-type-modal .aiwp-heading { font-size: 23px; }

/* ── Kiểu: sheet (bottom sheet) ─────────────────────────────────────── */
.aiwp-type-sheet .aiwp-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.aiwp-type-sheet .aiwp-panel::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: #e2e8f0;
}

/* ── Animation override ─────────────────────────────────────────────── */
.aiwp-root[data-aiwp-anim="none"] .aiwp-panel,
.aiwp-root[data-aiwp-anim="none"] .aiwp-backdrop {
    transition: none;
    transform: none;
}

.aiwp-root[data-aiwp-anim="fade"] .aiwp-panel {
    transform: none;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .aiwp-type-slide_in .aiwp-panel,
    .aiwp-type-modal .aiwp-panel {
        width: auto;
        left: 12px;
        right: 12px;
    }

    .aiwp-type-modal .aiwp-panel,
    .aiwp-type-modal.aiwp-pos-top-center .aiwp-panel {
        top: 50%;
        transform: translateY(-50%) scale(.96);
    }

    .aiwp-type-modal.aiwp-open .aiwp-panel,
    .aiwp-type-modal.aiwp-pos-top-center.aiwp-open .aiwp-panel {
        transform: translateY(-50%) scale(1);
    }

    .aiwp-type-bar .aiwp-content { padding: 12px 48px 12px 16px; }
    .aiwp-type-bar .aiwp-input { min-width: 0; flex: 1; }
    .aiwp-content { padding: 20px; }
    .aiwp-heading { font-size: 18px; }
    .aiwp-type-modal .aiwp-heading { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .aiwp-panel,
    .aiwp-backdrop,
    .aiwp-cta {
        transition: none !important;
        transform: none !important;
    }

    .aiwp-type-modal .aiwp-panel,
    .aiwp-type-modal.aiwp-open .aiwp-panel {
        transform: translate(-50%, -50%) !important;
    }
}

/* Modal trên mobile căn giữa bằng translateY, giữ đúng khi tắt animation. */
@media (prefers-reduced-motion: reduce) and (max-width: 767px) {
    .aiwp-type-modal .aiwp-panel,
    .aiwp-type-modal.aiwp-open .aiwp-panel {
        transform: translateY(-50%) !important;
    }
}
