/* ============================================================
   DrugsGeneral — Exit Intent Popup  v3.2  (Mobile-First)
   File: assets/css/exit-intent.css

   v3.2 changes (theme v98.1):
     - Full mobile-first rewrite. Default styles are for mobile
       (bottom-sheet: slides up from bottom, full-width, rounded
       top corners only, safe-area-inset padding).
     - Desktop (≥ 521px) overrides to centered floating card.
     - Touch targets enlarged to ≥ 44px on mobile.
     - Dismiss link moved into footer area (thumb-friendly zone).
     - iOS scroll-lock: uses touch-action instead of overflow:hidden
       on body (JS companion change required — see exit-intent.js).
     - safe-area-inset-bottom applied to dismiss wrap on mobile.
   ============================================================

   Design tokens (set by PHP as inline CSS vars on overlay):
     --ei-accent      Main brand colour for this segment
     --ei-alight      Light tint of accent (backgrounds, pills)
     --ei-adark       Dark shade of accent (text on light tint)
   ============================================================ */

/* ── Overlay ──────────────────────────────────────────────── */
.dgco-ei-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, .52);
    display: flex;
    align-items: flex-end;          /* ← mobile: sheet anchors to bottom */
    justify-content: stretch;
    padding: 0;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity .22s ease;
}

.dgco-ei-overlay[hidden] { display: none !important; }

.dgco-ei-overlay.dgco-ei-visible { opacity: 1; }

/* ── Box (mobile = bottom sheet) ─────────────────────────── */
.dgco-ei-box {
    position: relative;
    background: #fff;
    border-radius: 20px 20px 0 0;   /* ← rounded top only */
    width: 100%;
    max-width: 100%;                 /* ← full width on mobile */
    overflow: hidden;
    box-shadow: 0 -8px 40px rgba(0,0,0,.22), 0 -2px 8px rgba(0,0,0,.10);
    transform: translateY(100%);     /* ← slides in from below */
    opacity: 1;                      /* ← no opacity anim on mobile */
    transition: transform .32s cubic-bezier(.32,1,.56,1);
    /* max height so it never covers the whole screen */
    max-height: 92dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dgco-ei-overlay.dgco-ei-visible .dgco-ei-box {
    transform: translateY(0);
}

/* ── Drag handle (mobile affordance) ─────────────────────── */
.dgco-ei-box::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #E0E0E0;
    border-radius: 2px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

/* ── Accent top bar ───────────────────────────────────────── */
.dgco-ei-topbar {
    height: 3px;
    background: var(--ei-accent, #006070);
    margin-top: 8px;
}

/* ── Inner padding wrapper ───────────────────────────────── */
.dgco-ei-box > *:not(.dgco-ei-topbar):not(.dgco-ei-help):not(.dgco-ei-dismiss-wrap) {
    padding-left: 20px;
    padding-right: 20px;
}

/* ── Close button ────────────────────────────────────────── */
.dgco-ei-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: #F5F5F5;
    border: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #757575;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color .15s, background .15s;
    z-index: 2;
    /* min touch target */
    min-width: 44px;
    min-height: 44px;
    margin-right: -4px;
}
.dgco-ei-close:hover,
.dgco-ei-close:focus-visible {
    color: #212121;
    background: #EEEEEE;
}

/* ── Badge + Icon row ────────────────────────────────────── */
.dgco-ei-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    margin-bottom: 12px;
    padding-right: 48px;            /* clear close button */
}

.dgco-ei-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .1em;
    padding: 4px 10px;
    border-radius: 4px;
    background: var(--ei-alight, #E0F4F6);
    color: var(--ei-adark, #004050);
    text-transform: uppercase;
}

.dgco-ei-icon-emoji {
    font-size: 24px;
    line-height: 1;
}

/* ── Headline ────────────────────────────────────────────── */
.dgco-ei-headline {
    font-size: 22px;
    font-weight: 800;
    color: #0F1111;
    margin: 0 0 8px;
    line-height: 1.2;
    letter-spacing: -.02em;
}

/* ── Subtext ─────────────────────────────────────────────── */
.dgco-ei-subtext {
    font-size: 14px;
    color: #555;
    margin: 0 0 14px;
    line-height: 1.55;
}

/* ── Countdown timer ─────────────────────────────────────── */
.dgco-ei-timer-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ei-accent, #006070);
    margin-bottom: 12px;
}
.dgco-ei-timer-wrap svg { flex-shrink: 0; stroke: var(--ei-accent, #006070); }
.dgco-ei-timer-wrap strong { font-variant-numeric: tabular-nums; }

/* ── Discount pill ───────────────────────────────────────── */
.dgco-ei-discount-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ei-alight, #E0F4F6);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 14px;
}

.dgco-ei-discount-label {
    font-size: 14px;
    color: var(--ei-adark, #004050);
}

.dgco-ei-discount-pct {
    font-size: 26px;
    font-weight: 900;
    color: var(--ei-accent, #006070);
    line-height: 1;
    letter-spacing: -.02em;
}

/* ── Get coupon wrap ─────────────────────────────────────── */
.dgco-ei-get-coupon-wrap {
    margin-bottom: 4px;
    text-align: center;
}

.dgco-ei-get-coupon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    background: var(--ei-accent, #006070);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 17px 20px;             /* taller CTA on mobile */
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: .01em;
    transition: filter .15s, transform .1s;
    font-family: inherit;
    box-shadow: 0 4px 18px rgba(0,0,0,.18);
    min-height: 56px;               /* large touch target */
}
.dgco-ei-get-coupon-btn:hover  { filter: brightness(1.08); }
.dgco-ei-get-coupon-btn:active { transform: scale(.98); }
.dgco-ei-get-coupon-btn.loading { opacity: .6; pointer-events: none; }

.dgco-ei-get-coupon-hint {
    font-size: 12px;
    color: #9E9E9E;
    margin: 9px 0 0;
    line-height: 1.4;
}

/* ── Coupon revealed section ─────────────────────────────── */
.dgco-ei-coupon-section {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 4px;
}

.dgco-ei-coupon-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dgco-ei-code-block {
    flex: 1;
    background: var(--ei-alight, #E0F4F6);
    border: 1.5px dashed var(--ei-accent, #006070);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: all;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dgco-ei-code-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--ei-adark, #004050);
    margin-bottom: 2px;
    text-transform: uppercase;
}

.dgco-ei-coupon-code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: .08em;
    color: #0F1111;
}

.dgco-ei-copy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--ei-accent, #006070);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: filter .15s;
    flex-shrink: 0;
    min-height: 56px;               /* match code-block height */
    min-width: 72px;
}
.dgco-ei-copy-btn:hover { filter: brightness(1.1); }
.dgco-ei-copy-btn.dgco-ei-copied { background: #2E7D32; }

.dgco-ei-validity-note {
    font-size: 11px;
    color: #9E9E9E;
    margin: 5px 0 0;
    text-align: center;
}

/* ── Feedback line ───────────────────────────────────────── */
.dgco-ei-feedback {
    font-size: 12px;
    min-height: 1.2em;
    margin: 5px 0;
    color: #2E7D32;
    font-weight: 600;
    text-align: center;
}
.dgco-ei-feedback.dgco-ei-error { color: #C62828; }

/* ── Shop CTA (post-reveal) ──────────────────────────────── */
.dgco-ei-cta-btn {
    display: block;
    width: 100%;
    background: var(--ei-accent, #006070);
    color: #fff !important;
    font-size: 15px;
    font-weight: 800;
    text-align: center;
    padding: 17px 20px;
    border-radius: 12px;
    text-decoration: none !important;
    margin-bottom: 4px;
    transition: filter .15s, transform .1s;
    border: none;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: .01em;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dgco-ei-cta-btn:hover  { filter: brightness(1.08); }
.dgco-ei-cta-btn:active { transform: scale(.98); }

/* ── Trust row ───────────────────────────────────────────── */
.dgco-ei-trust-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 10px 0 14px;
    background: var(--ei-alight, #E0F4F6);
    border-radius: 10px;
    padding: 8px 14px;
}
.dgco-ei-trust-row svg { stroke: var(--ei-accent, #006070); flex-shrink: 0; }
.dgco-ei-trust-row span {
    font-size: 12px;
    color: var(--ei-adark, #004050);
    letter-spacing: .01em;
    font-weight: 600;
    line-height: 1.4;
}

/* ── WhatsApp section ────────────────────────────────────── */
.dgco-ei-help {
    border-top: 1px solid #EEEEEE;
    padding: 14px 20px 6px;
}

.dgco-ei-help-text {
    display: block;
    font-size: 12px;
    color: #9E9E9E;
    text-align: center;
    margin-bottom: 10px;
}

.dgco-ei-whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #F0FBF4;
    color: #1B5E20 !important;
    border: 1px solid #C8E6C9;
    font-size: 14px;
    font-weight: 700;
    padding: 13px 16px;
    border-radius: 10px;
    text-decoration: none !important;
    transition: background .15s;
    min-height: 50px;
}
.dgco-ei-whatsapp-btn:hover { background: #E8F5E9; }

/* ── Dismiss (thumb-zone footer) ─────────────────────────── */
.dgco-ei-dismiss-wrap {
    text-align: center;
    padding: 12px 20px;
    /* push above home indicator on notched phones */
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
}

.dgco-ei-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #BDBDBD;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 8px 16px;              /* generous tap area */
    font-family: inherit;
    transition: color .15s;
    display: inline-block;
    min-height: 44px;
    line-height: 28px;
}
.dgco-ei-dismiss:hover { color: #757575; }

/* ══════════════════════════════════════════════════════════
   DESKTOP OVERRIDES  (≥ 521px — centered floating card)
══════════════════════════════════════════════════════════ */
@media (min-width: 521px) {

    .dgco-ei-overlay {
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    .dgco-ei-box {
        border-radius: 18px;
        max-width: 420px;
        max-height: 90vh;
        width: 100%;
        transform: translateY(20px) scale(.96);
        opacity: 0;
        transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
        box-shadow: 0 24px 64px rgba(0,0,0,.28), 0 4px 16px rgba(0,0,0,.12);
    }

    /* hide drag handle pill on desktop */
    .dgco-ei-box::before { display: none; }

    .dgco-ei-overlay.dgco-ei-visible .dgco-ei-box {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    .dgco-ei-topbar { margin-top: 0; }

    .dgco-ei-box > *:not(.dgco-ei-topbar):not(.dgco-ei-help):not(.dgco-ei-dismiss-wrap) {
        padding-left: 24px;
        padding-right: 24px;
    }

    .dgco-ei-help {
        padding-left: 24px;
        padding-right: 24px;
    }

    .dgco-ei-dismiss-wrap {
        padding: 10px 24px 20px;
        padding-bottom: 20px;       /* no safe-area needed on desktop */
    }

    .dgco-ei-headline { font-size: 21px; }
    .dgco-ei-subtext  { font-size: 13.5px; }

    .dgco-ei-get-coupon-btn { font-size: 15px; padding: 15px 20px; min-height: 52px; }
    .dgco-ei-cta-btn        { font-size: 14px; padding: 14px 20px; min-height: 52px; }

    .dgco-ei-copy-btn { min-height: 52px; }
    .dgco-ei-code-block { min-height: 52px; }

    .dgco-ei-dismiss { font-size: 11.5px; }
    .dgco-ei-discount-pct { font-size: 24px; }

    .dgco-ei-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 22px;
        background: none;
    }
    .dgco-ei-close:hover { background: #F5F5F5; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .dgco-ei-overlay,
    .dgco-ei-box { transition: none; }
}

/* ── iOS-safe scroll lock ─────────────────────────────────── */
/* Applied to <html> element when popup is open.
   Avoids the double-scroll bug that body{overflow:hidden} causes
   on iOS Safari (momentum scrolling continues under the overlay). */
html.dgco-ei-scroll-locked {
    overflow: hidden;
    /* on iOS we also need to fix position to truly block scroll */
    position: fixed;
    width: 100%;
    /* keep current scroll position so page doesn't jump to top */
    top: calc(-1 * var(--dgco-scroll-y, 0px));
}
