/* ============================================================
   Woo Free Item Offers — Frontend (trigger-link picker)
   Shared by the in-page modal and the standalone fallback page.
   ============================================================ */

:root {
    --wfio-t:       #0d9488;
    --wfio-th:      #0f766e;
    --wfio-ts:      #f0fdfb;
    --wfio-tb:      #99f6e4;
    --wfio-ink:     #0f172a;
    --wfio-muted:   #64748b;
    --wfio-border:  #e2e8f0;
    --wfio-red:     #dc2626;
    --wfio-redsoft: #fef2f2;
}

/* ── Modal shell (in-page picker) ── */
.wfio-trigger-overlay {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(15, 23, 42, .6);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    display: none; align-items: center; justify-content: center;
    padding: 20px; opacity: 0; transition: opacity .18s ease;
}
.wfio-trigger-overlay.is-open { display: flex; }
.wfio-trigger-overlay.is-visible { opacity: 1; }

.wfio-trigger-modal {
    background: #fff; border-radius: 12px; max-width: 640px; width: 100%;
    max-height: 88vh; overflow-y: auto; position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    transform: translateY(12px) scale(.98);
    transition: transform .18s ease;
}
.wfio-trigger-overlay.is-visible .wfio-trigger-modal { transform: translateY(0) scale(1); }

.wfio-trigger-modal-close {
    all: revert !important;
    position: absolute !important; top: 14px !important; right: 14px !important;
    width: 30px !important; height: 30px !important; margin: 0 !important; padding: 0 !important;
    border: none !important; background: #f1f5f9 !important; border-radius: 50% !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 18px !important; font-weight: 400 !important; line-height: 1 !important;
    cursor: pointer !important; color: var(--wfio-muted) !important;
    display: flex !important; align-items: center !important; justify-content: center !important; z-index: 2 !important;
}
.wfio-trigger-modal-close:hover { background: #e2e8f0 !important; color: var(--wfio-ink) !important; }

.wfio-trigger-modal-body { min-height: 80px; }
.wfio-trigger-modal-body .wfio-picker-card { box-shadow: none; border: none; }

.wfio-trigger-loading {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 48px 24px; color: var(--wfio-muted); font-size: 13.5px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.wfio-trigger-spinner {
    width: 18px; height: 18px; border: 2px solid var(--wfio-border);
    border-top-color: var(--wfio-t); border-radius: 50%;
    animation: wfio-trigger-spin .7s linear infinite;
}
@keyframes wfio-trigger-spin { to { transform: rotate(360deg); } }

/* Subtle "working" cursor while a check is in flight, before we know
   whether a modal is needed — avoids a dead-feeling click with no
   feedback on slower connections, without flashing the modal open
   for the common (no-picker) case. */
body.wfio-trigger-pending, body.wfio-trigger-pending * { cursor: progress !important; }

/* ── Picker card ──
   The card renders inside the live theme's DOM (as modal content), so it's
   exposed to whatever global element styles the theme/page-builder applies
   — often high-specificity or !important rules on headings, buttons, links,
   inputs and lists. We can't control cascade order against an arbitrary
   theme, so every such element is force-reset to the browser default
   ("all: revert") and then explicitly restyled — both as the FIRST and
   subsequent declarations of the *same* rule (never a separate blanket
   reset rule). That matters: a separate reset rule scoped by tag name
   (e.g. ".wfio-picker-card input") has higher specificity than a single
   utility class (e.g. ".wfio-step-input"), so it would silently win over
   — and undo — the real styling below it. Keeping reset+restyle in one
   rule per element sidesteps that entirely, since within a single rule the
   last-declared value for a property always wins regardless of specificity. */
.wfio-picker-card {
    all: revert;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--wfio-ink);
    background: #fff; border: 1px solid var(--wfio-border); border-radius: 10px;
    padding: 24px; box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    display: block;
}
.wfio-picker-card h1 {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 19px !important; font-weight: 700 !important; line-height: 1.3 !important;
    text-transform: none !important; letter-spacing: normal !important;
    color: var(--wfio-ink) !important; margin: 0 28px 4px 0 !important; display: block !important;
}
.wfio-picker-sub {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 13.5px !important; font-weight: 400 !important; text-transform: none !important;
    letter-spacing: normal !important; line-height: 1.5 !important;
    color: var(--wfio-muted) !important; margin: 0 0 20px !important; display: block !important;
}

.wfio-picker-group {
    all: revert;
    box-sizing: border-box;
    border: 1px solid var(--wfio-border); border-radius: 8px;
    padding: 14px 16px; margin-bottom: 14px; transition: border-color .15s;
    display: block;
}
.wfio-picker-group.is-complete { border-color: var(--wfio-t); }
.wfio-picker-group h2 {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 14.5px !important; font-weight: 600 !important; line-height: 1.3 !important;
    text-transform: none !important; letter-spacing: normal !important;
    color: var(--wfio-ink) !important; margin: 0 0 10px !important;
    display: flex !important; align-items: center !important; justify-content: space-between !important;
    gap: 8px !important; flex-wrap: wrap !important;
}
.wfio-picker-group-name {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: inherit !important; font-weight: inherit !important; text-transform: none !important;
    letter-spacing: normal !important; color: inherit !important; display: inline !important;
}
.wfio-picker-req {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 11px !important; font-weight: 700 !important; text-transform: uppercase !important;
    letter-spacing: .04em !important; line-height: 1.4 !important;
    color: var(--wfio-th) !important; background: var(--wfio-ts) !important; border: 1px solid var(--wfio-tb) !important;
    padding: 2px 8px !important; border-radius: 20px !important; display: inline-block !important; margin: 0 !important;
}
.wfio-picker-progress { all: revert; box-sizing: border-box; height: 5px; background: var(--wfio-border); border-radius: 4px; overflow: hidden; margin-bottom: 6px; display: block; }
.wfio-picker-progress-fill { all: revert; box-sizing: border-box; display: block; height: 100%; background: var(--wfio-t); transition: width .15s; }
.wfio-picker-count {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 12px !important; font-weight: 400 !important; text-transform: none !important;
    color: var(--wfio-muted) !important; margin: 0 0 10px !important; display: block !important;
}
.wfio-picker-count .cur { all: revert !important; font: inherit !important; color: inherit !important; }

.wfio-picker-options { all: revert; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px; }
.wfio-picker-option {
    all: revert;
    box-sizing: border-box;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border: 1px solid var(--wfio-border); border-radius: 6px;
}
.wfio-picker-option.is-oos { opacity: .55; }
.wfio-picker-option-label {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    flex: 1 !important; font-size: 13.5px !important; font-weight: 400 !important; text-transform: none !important;
    letter-spacing: normal !important; color: var(--wfio-ink) !important; display: inline-block !important; margin: 0 !important;
}
.wfio-picker-option-price {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 12.5px !important; font-weight: 400 !important; color: var(--wfio-muted) !important;
    display: inline-block !important; margin: 0 !important;
}
.wfio-picker-oos {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 11.5px !important; font-weight: 400 !important; color: var(--wfio-red) !important; display: inline-block !important;
}

.wfio-picker-stepper { all: revert; box-sizing: border-box; display: flex; align-items: center; gap: 4px; }
.wfio-picker-stepper button {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    width: 26px !important; height: 26px !important; border: 1px solid var(--wfio-border) !important;
    background: #fff !important; border-radius: 5px !important; font-size: 15px !important;
    font-weight: 400 !important; text-transform: none !important; cursor: pointer !important;
    line-height: 1 !important; color: var(--wfio-ink) !important; padding: 0 !important; margin: 0 !important;
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
}
.wfio-picker-stepper button:hover { background: var(--wfio-ts) !important; border-color: var(--wfio-tb) !important; }
.wfio-step-input {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    width: 44px !important; text-align: center !important; padding: 5px 2px !important;
    border: 1px solid var(--wfio-border) !important; border-radius: 5px !important; font-size: 13px !important;
    font-weight: 400 !important; color: var(--wfio-ink) !important; background: #fff !important; margin: 0 !important;
    display: inline-block !important; height: auto !important; line-height: normal !important; -webkit-appearance: auto !important; appearance: auto !important;
}

.wfio-picker-select {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    width: 100% !important; padding: 8px 10px !important; border: 1px solid var(--wfio-border) !important;
    border-radius: 6px !important; font-size: 13.5px !important; font-weight: 400 !important;
    text-transform: none !important; background: #fff !important; color: var(--wfio-ink) !important;
    display: block !important; height: auto !important; margin: 0 !important;
}

.wfio-picker-auto {
    all: revert;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 14px 0; padding: 10px 14px; background: #f8fafc;
    border: 1px dashed var(--wfio-border); border-radius: 8px;
    font-size: 12.5px; color: var(--wfio-muted); display: block;
}
.wfio-picker-auto p {
    all: revert !important; box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    margin: 0 0 4px !important; font-weight: 600 !important; font-size: 12.5px !important;
    text-transform: none !important; color: var(--wfio-muted) !important; display: block !important;
}
.wfio-picker-auto ul {
    all: revert !important; box-sizing: border-box !important;
    margin: 0 !important; padding-left: 18px !important; list-style: disc !important; display: block !important;
}
.wfio-picker-auto li {
    all: revert !important; box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 12.5px !important; font-weight: 400 !important; text-transform: none !important;
    color: var(--wfio-muted) !important; display: list-item !important; margin: 0 !important;
}

.wfio-picker-error {
    all: revert; box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--wfio-redsoft); color: #7f1d1d; border-left: 3px solid var(--wfio-red);
    padding: 9px 12px; border-radius: 5px; font-size: 13px; margin-bottom: 14px; display: block;
}

.wfio-picker-actions { all: revert; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.wfio-picker-cancel {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    color: var(--wfio-muted) !important; font-size: 13px !important; font-weight: 400 !important;
    text-transform: none !important; text-decoration: none !important; display: inline-block !important;
    padding: 0 !important; margin: 0 !important; background: none !important; border: none !important;
}
.wfio-picker-cancel:hover { color: var(--wfio-ink) !important; text-decoration: underline !important; }
.wfio-picker-submit {
    all: revert !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    background: var(--wfio-t) !important; border: 1px solid var(--wfio-t) !important; color: #fff !important;
    font-weight: 600 !important; font-size: 13.5px !important; text-transform: none !important;
    letter-spacing: normal !important; padding: 10px 20px !important; border-radius: 6px !important;
    cursor: pointer !important; line-height: 1.4 !important; display: inline-block !important; margin: 0 !important;
}
.wfio-picker-submit:hover { background: var(--wfio-th) !important; }
.wfio-picker-submit:disabled { opacity: .5 !important; cursor: default !important; }

@media (max-width: 480px) {
    .wfio-trigger-modal { max-height: 94vh; }
    .wfio-picker-card { padding: 20px 16px; }
}
