/**
 * Cancellation Retention Flow — Modal Styles.
 *
 * Design tokens from premium-shared.css:
 *   --strp-primary:          #8444F9
 *   --strp-primary-light:    #6C63FF
 *   --strp-primary-bg:       rgba(132, 68, 249, 0.08)
 *   --strp-primary-border:   rgba(132, 68, 249, 0.2)
 *   --strp-text-primary:     #1e293b
 *   --strp-text-secondary:   #64748b
 *   --strp-text-muted:       #94a3b8
 *   --strp-surface:          #ffffff
 *   --strp-surface-secondary:#f8fafc
 *   --strp-surface-tertiary: #f1f5f9
 *   --strp-border:           #e2e8f0
 *   --strp-radius-sm:        8px
 *   --strp-shadow-md:        0 4px 12px rgba(0, 0, 0, 0.1)
 *   --strp-shadow-lg:        0 8px 24px rgba(0, 0, 0, 0.12)
 *   --strp-transition:       200ms ease
 *
 * @package StripeSubManager
 * @since   2.2.0
 */

/* ---------------------------------------------------------------
   Overlay — Fixed fullscreen backdrop
   --------------------------------------------------------------- */
.strp-retention-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* ---------------------------------------------------------------
   Modal — Centered white card
   --------------------------------------------------------------- */
.strp-retention-modal {
    position: relative;
    background: var(--strp-surface, #ffffff);
    max-width: 520px;
    width: 100%;
    padding: 32px;
    border-radius: var(--strp-radius-sm, 8px);
    box-shadow: var(--strp-shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.12));
    max-height: 90vh;
    overflow-y: auto;
    animation: strp-retention-slide-in 200ms ease-out;
}

@keyframes strp-retention-slide-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------------------------------------------------------------
   Close button — Absolute top-right
   --------------------------------------------------------------- */
.strp-retention-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: var(--strp-text-muted, #94a3b8);
    cursor: pointer;
    border-radius: var(--strp-radius-sm, 8px);
    transition: background var(--strp-transition, 200ms ease),
                color var(--strp-transition, 200ms ease);
}

.strp-retention-close:hover {
    background: var(--strp-surface-tertiary, #f1f5f9);
    color: var(--strp-text-primary, #1e293b);
}

/* ---------------------------------------------------------------
   Step container
   --------------------------------------------------------------- */
.strp-retention-step {
    /* Each step fades in/out via JS */
}

.strp-retention-step h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--strp-text-primary, #1e293b);
    margin: 0 0 8px;
    line-height: 1.3;
}

.strp-retention-step p {
    font-size: 14px;
    color: var(--strp-text-secondary, #64748b);
    margin: 0 0 20px;
    line-height: 1.6;
}

/* ---------------------------------------------------------------
   Reason options — Styled radio labels
   --------------------------------------------------------------- */
.strp-retention-reasons {
    margin: 0 0 24px;
}

.strp-retention-reason-option {
    display: block;
    position: relative;
    padding: 12px 16px 12px 40px;
    margin-bottom: 8px;
    border: 1px solid var(--strp-border, #e2e8f0);
    border-radius: var(--strp-radius-sm, 8px);
    background: var(--strp-surface, #ffffff);
    cursor: pointer;
    font-size: 14px;
    color: var(--strp-text-primary, #1e293b);
    line-height: 1.5;
    transition: border-color var(--strp-transition, 200ms ease),
                background var(--strp-transition, 200ms ease),
                box-shadow var(--strp-transition, 200ms ease);
}

.strp-retention-reason-option:hover {
    border-color: var(--strp-primary-border, rgba(132, 68, 249, 0.2));
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
}

/* :has() requires Safari 15.4+, Chrome 105+, Firefox 121+. */
.strp-retention-reason-option:has(input:checked) {
    border-color: #8444F9;
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
    box-shadow: 0 0 0 1px #8444F9;
}

/* Fallback for browsers without :has() support (Firefox < 121) */
.strp-retention-reason-option--selected {
    border-color: #8444F9;
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
    box-shadow: 0 0 0 1px #8444F9;
}

.strp-retention-reason-option input[type="radio"] {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    accent-color: #8444F9;
    width: 16px;
    height: 16px;
}

.strp-retention-reason-option span {
    display: block;
}

/* ---------------------------------------------------------------
   Other reason textarea
   --------------------------------------------------------------- */
.strp-retention-other-text {
    display: block;
    width: 100%;
    min-height: 80px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--strp-border, #e2e8f0);
    border-radius: var(--strp-radius-sm, 8px);
    background: var(--strp-surface, #ffffff);
    font-family: inherit;
    font-size: 14px;
    color: var(--strp-text-primary, #1e293b);
    resize: vertical;
    transition: border-color var(--strp-transition, 200ms ease),
                box-shadow var(--strp-transition, 200ms ease);
    box-sizing: border-box;
}

.strp-retention-other-text:focus {
    outline: none;
    border-color: #8444F9;
    box-shadow: 0 0 0 2px rgba(132, 68, 249, 0.2);
}

.strp-retention-other-text::placeholder {
    color: var(--strp-text-muted, #94a3b8);
}

/* ---------------------------------------------------------------
   Offer card — Highlighted card with left border accent
   --------------------------------------------------------------- */
.strp-retention-offer-card {
    background: var(--strp-surface-secondary, #f8fafc);
    border: 1px solid var(--strp-border, #e2e8f0);
    border-left: 4px solid #8444F9;
    border-radius: var(--strp-radius-sm, 8px);
    padding: 20px;
    margin-bottom: 24px;
}

.strp-retention-offer-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--strp-text-primary, #1e293b);
    margin: 0 0 8px;
}

.strp-retention-offer-card p {
    font-size: 14px;
    color: var(--strp-text-secondary, #64748b);
    margin: 0 0 12px;
    line-height: 1.5;
}

.strp-retention-offer-card p:last-child {
    margin-bottom: 0;
}

/* ---------------------------------------------------------------
   Per-type offer cards (discount, pause, downgrade, trial)
   --------------------------------------------------------------- */
.strp-retention-offer {
    padding: 16px;
    border-radius: var(--strp-radius-sm, 8px);
    margin-bottom: 12px;
}

.strp-retention-offer:last-child {
    margin-bottom: 0;
}

.strp-retention-offer--discount {
    background: rgba(132, 68, 249, 0.06);
    border: 1px solid var(--strp-primary-border, rgba(132, 68, 249, 0.2));
}

.strp-retention-offer--pause {
    background: rgba(0, 212, 170, 0.06);
    border: 1px solid var(--strp-teal-border, rgba(0, 212, 170, 0.2));
}

.strp-retention-offer--downgrade {
    background: rgba(100, 116, 139, 0.06);
    border: 1px solid var(--strp-border, #e2e8f0);
}

.strp-retention-offer--trial {
    background: rgba(219, 166, 23, 0.06);
    border: 1px solid rgba(219, 166, 23, 0.2);
}

.strp-retention-offer__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--strp-text-primary, #1e293b);
    margin: 0 0 4px;
}

.strp-retention-offer__desc {
    font-size: 13px;
    color: var(--strp-text-secondary, #64748b);
    margin: 0;
    line-height: 1.5;
}

/* ---------------------------------------------------------------
   Pause option buttons
   --------------------------------------------------------------- */
.strp-retention-pause-option {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--strp-border, #e2e8f0);
    border-radius: var(--strp-radius-sm, 8px);
    background: var(--strp-surface, #ffffff);
    font-size: 14px;
    font-weight: 500;
    color: var(--strp-text-primary, #1e293b);
    cursor: pointer;
    margin: 8px 8px 0 0;
    transition: border-color var(--strp-transition, 200ms ease),
                background var(--strp-transition, 200ms ease),
                box-shadow var(--strp-transition, 200ms ease);
}

.strp-retention-pause-option:hover {
    border-color: var(--strp-primary-border, rgba(132, 68, 249, 0.2));
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
}

.strp-retention-pause-option.selected {
    border-color: #8444F9;
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
    box-shadow: 0 0 0 1px #8444F9;
    color: #8444F9;
}

/* ---------------------------------------------------------------
   Downgrade option buttons
   --------------------------------------------------------------- */
.strp-retention-downgrade-option {
    display: block;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--strp-border, #e2e8f0);
    border-radius: var(--strp-radius-sm, 8px);
    background: var(--strp-surface, #ffffff);
    font-size: 14px;
    color: var(--strp-text-primary, #1e293b);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color var(--strp-transition, 200ms ease),
                background var(--strp-transition, 200ms ease),
                box-shadow var(--strp-transition, 200ms ease);
}

.strp-retention-downgrade-option:hover {
    border-color: var(--strp-primary-border, rgba(132, 68, 249, 0.2));
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
}

.strp-retention-downgrade-option.selected {
    border-color: #8444F9;
    background: var(--strp-primary-bg, rgba(132, 68, 249, 0.08));
    box-shadow: 0 0 0 1px #8444F9;
}

.strp-retention-downgrade-option:last-child {
    margin-bottom: 0;
}

/* ---------------------------------------------------------------
   Buttons — Primary (brand purple)
   --------------------------------------------------------------- */
.strp-retention-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--strp-radius-sm, 8px);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--strp-transition, 200ms ease),
                box-shadow var(--strp-transition, 200ms ease),
                transform var(--strp-transition, 200ms ease),
                opacity var(--strp-transition, 200ms ease);
    text-decoration: none;
    line-height: 1.4;
}

.strp-retention-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.strp-retention-btn--primary {
    background: #8444F9;
    color: #ffffff;
}

.strp-retention-btn--primary:hover:not(:disabled) {
    background: #7338e0;
    box-shadow: 0 4px 12px rgba(132, 68, 249, 0.35);
    transform: translateY(-1px);
}

.strp-retention-btn--primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(132, 68, 249, 0.25);
}

/* ---------------------------------------------------------------
   Buttons — Success (green)
   --------------------------------------------------------------- */
.strp-retention-btn--success {
    background: #22c55e;
    color: #ffffff;
}

.strp-retention-btn--success:hover:not(:disabled) {
    background: #16a34a;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
    transform: translateY(-1px);
}

.strp-retention-btn--success:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.25);
}

/* ---------------------------------------------------------------
   Buttons — Danger (red)
   --------------------------------------------------------------- */
.strp-retention-btn--danger {
    background: #ef4444;
    color: #ffffff;
}

.strp-retention-btn--danger:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

.strp-retention-btn--danger:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}

/* ---------------------------------------------------------------
   Buttons — Link (text-only subtle)
   --------------------------------------------------------------- */
.strp-retention-btn--link {
    background: transparent;
    color: var(--strp-text-secondary, #64748b);
    padding: 10px 16px;
}

.strp-retention-btn--link:hover:not(:disabled) {
    color: var(--strp-text-primary, #1e293b);
    background: var(--strp-surface-tertiary, #f1f5f9);
}

/* ---------------------------------------------------------------
   Button row — Actions container with gap
   --------------------------------------------------------------- */
.strp-retention-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

/* ---------------------------------------------------------------
   Loading overlay with spinner
   --------------------------------------------------------------- */
.strp-retention-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--strp-radius-sm, 8px);
    z-index: 10;
}

/* ---------------------------------------------------------------
   CSS-only spinner
   --------------------------------------------------------------- */
.strp-retention-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--strp-border, #e2e8f0);
    border-top-color: #8444F9;
    border-radius: 50%;
    animation: strp-retention-spin 0.7s linear infinite;
}

@keyframes strp-retention-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------------------------------------------------------------
   Success icon — Large green checkmark
   --------------------------------------------------------------- */
.strp-retention-success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 50%;
    color: #22c55e;
    line-height: 1;
}

.strp-retention-success-icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

/* ---------------------------------------------------------------
   Toast notices (error / success variants)
   --------------------------------------------------------------- */
.strp-retention-notice {
    padding: 12px 16px;
    border-radius: var(--strp-radius-sm, 8px);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
    animation: strp-retention-notice-in 200ms ease-out;
}

@keyframes strp-retention-notice-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.strp-retention-notice--error {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.strp-retention-notice--success {
    background: rgba(34, 197, 94, 0.08);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ---------------------------------------------------------------
   Focus outlines for accessibility
   --------------------------------------------------------------- */
.strp-retention-modal *:focus-visible {
    outline: 2px solid #8444F9;
    outline-offset: 2px;
}

.strp-retention-reason-option:focus-within {
    outline: 2px solid #8444F9;
    outline-offset: 2px;
}

.strp-retention-reason-option input[type="radio"]:focus-visible {
    outline: none;
}

/* ---------------------------------------------------------------
   Reduced motion — Disable animations for users who prefer it
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .strp-retention-modal {
        animation: none;
    }
    .strp-retention-spinner {
        animation: none;
    }
    .strp-retention-notice {
        animation: none;
    }
    .strp-retention-step {
        transition: none;
    }
}

/* ---------------------------------------------------------------
   RTL support — Mirror layout for right-to-left languages
   --------------------------------------------------------------- */
[dir="rtl"] .strp-retention-close,
.strp-retention-close:dir(rtl) {
    right: auto;
    left: 12px;
}

[dir="rtl"] .strp-retention-reason-option,
.strp-retention-reason-option:dir(rtl) {
    padding-left: 16px;
    padding-right: 40px;
}

[dir="rtl"] .strp-retention-reason-option input[type="radio"],
.strp-retention-reason-option:dir(rtl) input[type="radio"] {
    left: auto;
    right: 14px;
}

[dir="rtl"] .strp-retention-offer-card,
.strp-retention-offer-card:dir(rtl) {
    border-left: 1px solid var(--strp-border, #e2e8f0);
    border-right: 4px solid #8444F9;
}

[dir="rtl"] .strp-retention-downgrade-option,
.strp-retention-downgrade-option:dir(rtl) {
    text-align: right;
}

[dir="rtl"] .strp-retention-pause-option,
.strp-retention-pause-option:dir(rtl) {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .strp-retention-actions,
.strp-retention-actions:dir(rtl) {
    flex-direction: row-reverse;
}

/* ---------------------------------------------------------------
   Responsive — Stack on screens < 480px
   --------------------------------------------------------------- */
@media (max-width: 480px) {
    .strp-retention-overlay {
        padding: 8px;
        align-items: flex-end;
    }

    .strp-retention-modal {
        padding: 24px 20px;
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--strp-radius-sm, 8px) var(--strp-radius-sm, 8px) 0 0;
    }

    .strp-retention-step h2 {
        font-size: 18px;
    }

    .strp-retention-actions {
        flex-direction: column;
        gap: 8px;
    }

    .strp-retention-actions .strp-retention-btn {
        width: 100%;
    }

    .strp-retention-pause-option {
        display: block;
        width: 100%;
        margin-right: 0;
        text-align: center;
    }

    .strp-retention-offer-card {
        padding: 16px;
    }

    .strp-retention-success-icon {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }
}
