/* 
 * Post & Boost: Premium Opt-in Popup
 * Required Variables (injected via JS):
 * --awp-popup-accent
 * --awp-popup-panel
 * --awp-popup-text
 * --awp-popup-from
 * --awp-popup-to
 * --awp-popup-blur
 * --awp-popup-image
 */

.awp-optin-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.26s ease, visibility 0.26s ease;
}

.awp-optin-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

body.awp-optin-open {
    overflow: hidden;
}

/* Modal backdrop for center position */
.awp-optin-overlay.awp-optin-pos-center {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 24px;
}

@supports (backdrop-filter: blur(1px)) {
    .awp-optin-overlay.awp-optin-pos-center {
        backdrop-filter: blur(var(--awp-popup-blur, 12px));
        -webkit-backdrop-filter: blur(var(--awp-popup-blur, 12px));
        background-color: rgba(0, 0, 0, 0.3);
    }
}

/* Non-blocking slide-ins for bottom positions */
.awp-optin-overlay.awp-optin-pos-bottom-left,
.awp-optin-overlay.awp-optin-pos-bottom-right {
    background-color: transparent;
    pointer-events: none;
    padding: 32px;
}

.awp-optin-overlay.awp-optin-pos-bottom-left .awp-optin-dialog,
.awp-optin-overlay.awp-optin-pos-bottom-right .awp-optin-dialog {
    pointer-events: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Position Alignments */
.awp-optin-pos-center {
    align-items: center;
    justify-content: center;
}

.awp-optin-pos-bottom-left {
    align-items: flex-end;
    justify-content: flex-start;
}

.awp-optin-pos-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
}

.awp-optin-overlay[hidden] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Dialog Core */
.awp-optin-dialog {
    position: relative;
    width: 100%;
    max-width: 440px;
    background-color: var(--awp-popup-panel, #111827);
    border-radius: 20px;
    overflow: hidden;
    font-family: var(--awp-fe-font, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    transform: translateY(15px) scale(0.95);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15), opacity 0.5s ease;
    opacity: 0;
    max-height: calc(100vh - 32px);
}

/* Entrance / Exit states */
.awp-optin-overlay.is-open .awp-optin-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.awp-optin-overlay.awp-optin-pos-bottom-left .awp-optin-dialog,
.awp-optin-overlay.awp-optin-pos-bottom-right .awp-optin-dialog {
    transform: translateY(40px);
}

.awp-optin-overlay.awp-optin-pos-bottom-left.is-open .awp-optin-dialog,
.awp-optin-overlay.awp-optin-pos-bottom-right.is-open .awp-optin-dialog {
    transform: translateY(0);
}

/* Close Button */
.awp-optin-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(128, 128, 128, 0.2);
    color: var(--awp-popup-text, #ffffff);
    border: none;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s, transform 0.2s;
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .awp-optin-close {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 15%, transparent);
    }
}

html[dir="rtl"] .awp-optin-close {
    right: auto;
    left: 16px;
}

.awp-optin-close:hover {
    background: rgba(128, 128, 128, 0.4);
    transform: scale(1.05);
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .awp-optin-close:hover {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 25%, transparent);
    }
}

.awp-optin-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--awp-popup-accent, #f5c451);
}

/* Visual Background (Image + Gradient) */
.awp-optin-visual {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: var(--awp-popup-panel, #111827);
    background-image: var(--awp-popup-image, none);
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

.awp-optin-visual::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, var(--awp-popup-from, #020617), var(--awp-popup-to, #312e81));
    opacity: 0.88;
}

/* Content Area */
.awp-optin-content {
    position: relative;
    z-index: 1;
    padding: 44px 36px 36px;
    color: var(--awp-popup-text, #ffffff);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.awp-optin-kicker {
    display: inline-block;
    background: rgba(128, 128, 128, 0.15);
    border: 1px solid rgba(128, 128, 128, 0.3);
    color: var(--awp-popup-accent, #f5c451);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 5px 14px;
    border-radius: 30px;
    margin-bottom: 18px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .awp-optin-kicker {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 10%, transparent);
        border-color: color-mix(in srgb, var(--awp-popup-text, #ffffff) 20%, transparent);
    }
}

#awp-optin-title {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.25;
    margin: 0 0 12px;
    color: var(--awp-popup-text, #ffffff);
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.awp-optin-subtitle {
    font-size: 15px;
    line-height: 1.5;
    margin: 0 0 28px;
    opacity: 0.85;
    text-wrap: balance;
}

/* Form */
#awp-optin-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}

html[dir="rtl"] #awp-optin-form {
    text-align: right;
}

.awp-optin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.awp-optin-field span {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.95;
    margin-left: 2px;
}

html[dir="rtl"] .awp-optin-field span {
    margin-left: 0;
    margin-right: 2px;
}

.awp-optin-field input {
    box-sizing: border-box;
    width: 100%;
    height: 50px;
    padding: 0 16px;
    background: rgba(128, 128, 128, 0.15);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 10px;
    color: var(--awp-popup-text, #ffffff);
    font-size: 15px;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .awp-optin-field input {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 8%, transparent);
        border-color: color-mix(in srgb, var(--awp-popup-text, #ffffff) 20%, transparent);
    }
    
    .awp-optin-field input:hover {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 12%, transparent);
        border-color: color-mix(in srgb, var(--awp-popup-text, #ffffff) 30%, transparent);
    }
    
    .awp-optin-field input:focus {
        background: color-mix(in srgb, var(--awp-popup-text, #ffffff) 10%, transparent);
    }
    
    .awp-optin-field input::placeholder {
        color: color-mix(in srgb, var(--awp-popup-text, #ffffff) 50%, transparent);
    }
}

.awp-optin-field input:focus {
    outline: none;
    border-color: var(--awp-popup-accent, #f5c451);
    box-shadow: 0 0 0 3px rgba(245, 196, 81, 0.2);
}

@supports (box-shadow: 0 0 0 3px color-mix(in srgb, red 10%, transparent)) {
    .awp-optin-field input:focus {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--awp-popup-accent, #f5c451) 25%, transparent);
    }
}

.awp-optin-field input:-webkit-autofill,
.awp-optin-field input:-webkit-autofill:hover,
.awp-optin-field input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--awp-popup-text, #ffffff);
    -webkit-box-shadow: 0 0 0px 1000px rgba(128, 128, 128, 0.3) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.awp-optin-hp {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.awp-optin-consent {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.45;
    opacity: 0.8;
}

.awp-optin-submit {
    margin-top: 14px;
    width: 100%;
    height: 52px;
    background: var(--awp-popup-accent, #f5c451);
    color: var(--awp-popup-panel, #111827);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.awp-optin-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.awp-optin-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.awp-optin-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5), 0 0 0 6px var(--awp-popup-accent, #f5c451);
}

.awp-optin-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.awp-optin-status {
    margin: 10px 0 0;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    min-height: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.awp-optin-status:not(:empty) {
    opacity: 1;
}

.awp-optin-status.awp-error,
.awp-optin-status.is-error {
    color: #ff6b6b;
}

.awp-optin-status.awp-success,
.awp-optin-status.is-success {
    color: #51cf66;
}

/* Error states for fields */
.awp-optin-field input.awp-error {
    border-color: #ff6b6b !important;
    background: rgba(255, 107, 107, 0.05) !important;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .awp-optin-overlay.awp-optin-pos-bottom-left,
    .awp-optin-overlay.awp-optin-pos-bottom-right {
        padding: 12px;
        align-items: flex-end;
        justify-content: center;
    }

    .awp-optin-overlay.awp-optin-pos-bottom-left .awp-optin-dialog,
    .awp-optin-overlay.awp-optin-pos-bottom-right .awp-optin-dialog {
        width: 100%;
        max-width: 100%;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
    
    .awp-optin-overlay.awp-optin-pos-center {
        padding: 16px;
    }

    .awp-optin-content {
        padding: 40px 24px 28px;
    }
    
    #awp-optin-title {
        font-size: 24px;
    }
}

/* ==========================================================================
   INLINE SESSION OFFER CARD
   ========================================================================== */

.awp-session-offer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin: 24px 0;
    background: rgba(128, 128, 128, 0.05);
    border: 2px solid var(--awp-popup-accent, #f5c451);
    border-radius: 12px;
    color: inherit;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    font-family: var(--awp-fe-font, system-ui, -apple-system, sans-serif);
    animation: awp-offer-entrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .awp-session-offer {
        background: color-mix(in srgb, var(--awp-popup-accent, #f5c451) 8%, transparent);
    }
}

.awp-session-offer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--awp-popup-accent, #f5c451);
    color: #ffffff; /* Highly legible on most accents */
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.awp-session-offer span:not(.awp-session-offer-icon) {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
}

.awp-session-offer-label {
    font-size: 16px;
    font-weight: 800;
    color: inherit;
}

.awp-session-offer-detail {
    font-size: 14px;
    opacity: 0.7;
}

@keyframes awp-offer-entrance {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .awp-optin-overlay,
    .awp-optin-dialog,
    .awp-optin-submit {
        transition: none !important;
        transform: none !important;
    }
    .awp-session-offer {
        animation: none !important;
    }
    .awp-optin-overlay:not(.is-open) .awp-optin-dialog {
        transform: none !important;
        opacity: 0;
    }
}