/* ==========================================================================
   STW Exit Intent — Popup Styles
   ========================================================================== */

#stw-exit-popup {
    --stw-exit-accent: var(--bs-primary, #0d6efd);
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

#stw-exit-popup.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Backdrop */
.stw-exit-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

/* Card */
.stw-exit-popup__card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 12px;
    max-width: 440px;
    width: calc(100% - 2rem);
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.3s ease;
}

#stw-exit-popup.is-visible .stw-exit-popup__card {
    transform: translateY(0) scale(1);
}

/* Close button */
.stw-exit-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 0;
}

.stw-exit-popup__close:hover {
    background: #f0f0f0;
}

.stw-exit-popup__close:focus-visible {
    outline: 2px solid var(--stw-exit-accent);
    outline-offset: 2px;
}

/* Image */
.stw-exit-popup__image {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    margin-bottom: 1.25rem;
    border-radius: 8px;
}

/* Heading */
.stw-exit-popup__heading {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 0.5rem;
    line-height: 1.25;
}

/* Body */
.stw-exit-popup__body {
    font-size: 0.95rem;
    color: #555;
    margin: 0 0 1.5rem;
    line-height: 1.5;
}

/* Form */
.stw-exit-popup__form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stw-exit-popup__field {
    position: relative;
}

.stw-exit-popup__input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    outline: none;
    box-sizing: border-box;
}

.stw-exit-popup__input:focus {
    border-color: var(--stw-exit-accent);
}

.stw-exit-popup__input:focus-visible {
    outline: none;
    border-color: var(--stw-exit-accent);
    box-shadow: 0 0 0 1px var(--stw-exit-accent);
}

/* Error message below input */
.stw-exit-popup__error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 0.35rem;
    text-align: left;
}

/* Submit button */
.stw-exit-popup__submit {
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: var(--stw-exit-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.stw-exit-popup__submit:hover {
    opacity: 0.9;
}

.stw-exit-popup__submit:active {
    transform: scale(0.98);
}

.stw-exit-popup__submit:focus-visible {
    outline: 2px solid var(--stw-exit-accent);
    outline-offset: 2px;
}

.stw-exit-popup__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Dismiss link */
.stw-exit-popup__dismiss {
    background: none;
    border: none;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.5rem;
    text-decoration: underline;
}

.stw-exit-popup__dismiss:hover {
    color: #555;
}

.stw-exit-popup__dismiss:focus-visible {
    outline: 2px solid var(--stw-exit-accent);
    outline-offset: 2px;
}

/* Privacy note */
.stw-exit-popup__privacy {
    font-size: 0.75rem;
    color: #aaa;
    margin: 0.5rem 0 0;
}

/* Success state */
.stw-exit-popup__success {
    padding: 1rem 0;
}

.stw-exit-popup__success-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0.75rem 0 0;
}

.stw-exit-popup__coupon strong {
    display: inline-block;
    background: #f5f0fa;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    color: var(--stw-exit-accent);
    margin-top: 0.5rem;
    border: 2px dashed var(--stw-exit-accent);
}

/* Visually hidden (for a11y label) */
.stw-exit-popup .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Mobile — slide up from bottom
   ========================================================================== */

@media (max-width: 767px) {
    #stw-exit-popup {
        align-items: flex-end;
    }

    .stw-exit-popup__card {
        padding: 1.5rem 1.25rem;
        max-width: 100%;
        width: calc(100% - 1.5rem);
        border-radius: 12px 12px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
        overflow-y: auto;
        transform: translateY(100%);
    }

    #stw-exit-popup.is-visible .stw-exit-popup__card {
        transform: translateY(0);
    }

    .stw-exit-popup__image {
        max-height: 120px;
    }
}
