/* =============================================================
   QuicForm – Popup Mode (PRO feature, 5.3.2+)
   Clean modern UI · Shopify-inspired · Mobile-first

   This stylesheet is enqueued ONLY when:
     - the active license is valid (qf_is_pro() === true), AND
     - the saved display mode is 'popup'
   See QuicForm_Assets::enqueue() for the gate.
   ============================================================= */

/* ── Trigger button (replaces the inline form on the product) ── */
.qf-popup-trigger {
    --qf-accent:     #16a34a;
    --qf-accent-rgb: 22, 163, 74;

    display:        flex;
    align-items:    center;
    justify-content: center;
    gap:            10px;
    width:          100%;
    margin-top:     28px;
    padding:        16px 24px;
    min-height:     54px;
    background:     var(--qf-accent);
    color:          #fff;
    border:         none;
    border-radius:  12px;
    font-family:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size:      16px;
    font-weight:    600;
    letter-spacing: .01em;
    cursor:         pointer;
    box-shadow:     0 1px 2px rgba(16, 24, 40, .08),
                    0 4px 12px rgba(var(--qf-accent-rgb), .25);
    transition:     transform .15s cubic-bezier(.4,0,.2,1),
                    box-shadow .15s cubic-bezier(.4,0,.2,1),
                    filter     .15s cubic-bezier(.4,0,.2,1);
}
.qf-popup-trigger:hover {
    transform:  translateY(-1px);
    filter:     brightness(1.05);
    box-shadow: 0 2px 4px rgba(16, 24, 40, .1),
                0 8px 20px rgba(var(--qf-accent-rgb), .35);
}
.qf-popup-trigger:active {
    transform:  translateY(0);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .08),
                0 2px 6px rgba(var(--qf-accent-rgb), .25);
}
.qf-popup-trigger:focus-visible {
    outline:        2px solid var(--qf-accent);
    outline-offset: 3px;
}
.qf-popup-trigger-icon {
    flex-shrink:  0;
    stroke-width: 2.25;
}

/* ── Popup container (overlay + dialog) ─────────────────────── */
.qf-popup {
    position:        fixed;
    inset:           0;
    z-index:         999999;
    display:         flex;
    align-items:     center;
    justify-content: center;
    opacity:         0;
    visibility:      hidden;
    pointer-events:  none;
    transition:      opacity    .2s cubic-bezier(.4,0,.2,1),
                     visibility .2s cubic-bezier(.4,0,.2,1);
}
.qf-popup[hidden] { display: none !important; }
.qf-popup.is-open {
    opacity:        1;
    visibility:     visible;
    pointer-events: auto;
}

/* ── Overlay backdrop ───────────────────────────────────────── */
.qf-popup-overlay {
    position:               absolute;
    inset:                  0;
    background:             rgba(15, 23, 42, .55);
    backdrop-filter:        blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor:                 pointer;
}

/* ── Dialog box ─────────────────────────────────────────────── */
.qf-popup-dialog {
    position:       relative;
    z-index:        1;
    width:          100%;
    max-width:      500px;
    max-height:     calc(100vh - 40px);
    max-height:     calc(100dvh - 40px);
    margin:         20px;
    background:     #fff;
    border-radius:  16px;
    box-shadow:     0 20px 25px -5px rgba(0, 0, 0, .1),
                    0 10px 10px -5px rgba(0, 0, 0, .04),
                    0 0 0 1px rgba(0, 0, 0, .03);
    overflow:       hidden;
    display:        flex;
    flex-direction: column;
    transform:      translateY(12px) scale(.98);
    opacity:        0;
    transition:     transform .25s cubic-bezier(.16, 1, .3, 1),
                    opacity   .2s  cubic-bezier(.16, 1, .3, 1);
}
.qf-popup.is-open .qf-popup-dialog {
    transform: translateY(0) scale(1);
    opacity:   1;
}

/* ── Close button ───────────────────────────────────────────── */
.qf-popup-close {
    position:        absolute;
    top:             12px;
    right:           12px;
    z-index:         2;
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    width:           36px;
    height:          36px;
    padding:         0;
    background:      rgba(255, 255, 255, .9);
    border:          1px solid rgba(0, 0, 0, .06);
    border-radius:   50%;
    color:           #4b5563;
    cursor:          pointer;
    box-shadow:      0 1px 2px rgba(0, 0, 0, .06);
    transition:      background .15s, color .15s, transform .15s;
}
.qf-popup-close:hover {
    background: #f3f4f6;
    color:      #111827;
    transform:  rotate(90deg);
}
.qf-popup-close:focus-visible {
    outline:        2px solid #2563eb;
    outline-offset: 2px;
}
.qf-popup-close svg { pointer-events: none; }

/* ── SR-only popup title (for accessibility) ────────────────── */
.qf-popup-sr-only {
    position:    absolute !important;
    width:       1px !important;
    height:      1px !important;
    padding:     0 !important;
    margin:      -1px !important;
    overflow:    hidden !important;
    clip:        rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border:      0 !important;
}

/* ── Scrollable content area ────────────────────────────────── */
.qf-popup-content {
    flex:                       1 1 auto;
    overflow-y:                 auto;
    overflow-x:                 hidden;
    -webkit-overflow-scrolling: touch;
    padding:                    0;
}
.qf-popup-content::-webkit-scrollbar { width: 8px; }
.qf-popup-content::-webkit-scrollbar-track { background: transparent; }
.qf-popup-content::-webkit-scrollbar-thumb {
    background:    rgba(0, 0, 0, .15);
    border-radius: 4px;
}
.qf-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, .25);
}

/* ── Reset card chrome when rendered inside the popup ───────── */
.qf-card.qf-card--in-popup {
    margin:        0 !important;
    border:        none !important;
    border-radius: 0 !important;
    box-shadow:    none !important;
}

/* Give the close button room over the header */
.qf-card.qf-card--in-popup .qf-header {
    padding-right: 56px;
}

/* ── Body scroll lock ───────────────────────────────────────── */
body.qf-popup-lock {
    overflow:            hidden !important;
    overscroll-behavior: contain;
}

/* ── Mobile (≤ 600px) – bottom-sheet style ──────────────────── */
@media (max-width: 600px) {
    .qf-popup { align-items: flex-end; }

    .qf-popup-dialog {
        margin:        0;
        width:         100%;
        max-width:     100%;
        max-height:    92vh;
        max-height:    92dvh;
        border-radius: 18px 18px 0 0;
        transform:     translateY(100%);
        transition:    transform .3s  cubic-bezier(.16, 1, .3, 1),
                       opacity   .25s cubic-bezier(.16, 1, .3, 1);
    }
    .qf-popup.is-open .qf-popup-dialog {
        transform: translateY(0);
    }

    /* Bottom-sheet drag handle (visual cue) */
    .qf-popup-dialog::before {
        content:        '';
        position:       absolute;
        top:            8px;
        left:           50%;
        transform:      translateX(-50%);
        width:          40px;
        height:         4px;
        background:     #d1d5db;
        border-radius:  2px;
        z-index:        3;
        pointer-events: none;
    }

    .qf-popup-close {
        top:    14px;
        right:  14px;
        width:  34px;
        height: 34px;
    }

    .qf-card.qf-card--in-popup .qf-header {
        padding-top:   28px; /* room for the sheet handle */
        padding-right: 56px;
    }
}

/* ── Landscape mobile – use full screen ─────────────────────── */
@media (max-width: 600px) and (orientation: landscape) {
    .qf-popup-dialog {
        max-height:    100vh;
        max-height:    100dvh;
        border-radius: 0;
    }
    .qf-popup-dialog::before { display: none; }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .qf-popup,
    .qf-popup-dialog,
    .qf-popup-trigger,
    .qf-popup-close { transition: none !important; }
    .qf-popup-dialog { transform: none !important; }
}
