/**
 * Adaptiverse Popup Manager - Frontend Styles
 *
 * @package Adaptiverse_Popup_Manager
 */

/* ═══════════════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════════════ */

:root {
    /* Brand */
    --apm-brand: #4568dc;
    --apm-brand-hover: #3a5bc5;
    --apm-accent: #b06ab3;
    --apm-gradient: linear-gradient(135deg, #4568dc 0%, #b06ab3 100%);

    /* Promotional (dark) */
    --apm-promo-bg: #1e2433;
    --apm-promo-bg-light: #2a3244;
    --apm-promo-text: #ffffff;
    --apm-promo-text-dim: #b8c4d9;
    --apm-promo-text-muted: #8a99b3;
    --apm-promo-border: #3d4759;

    /* Lead-gen (light/warm) */
    --apm-lg-bg: #faf9f7;
    --apm-lg-intro-bg: #f0eeeb;
    --apm-lg-text: #2d3748;
    --apm-lg-text-dim: #5a6577;
    --apm-lg-text-muted: #8d95a3;
    --apm-lg-form-bg: #ffffff;
    --apm-lg-border: #e2ddd6;
    --apm-lg-input-border: #d4cfc7;
    --apm-lg-input-focus: #4568dc;

    /* Shared */
    --apm-radius: 20px;
    --apm-radius-sm: 12px;
    --apm-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --apm-font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}


/* ═══════════════════════════════════════════════
   SHARED INFRASTRUCTURE
   ═══════════════════════════════════════════════ */

.apm-body-no-scroll { overflow: hidden; }

/* Overlay */
.apm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 28, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--apm-transition), visibility var(--apm-transition);
}
.apm-overlay.apm-overlay--visible { opacity: 1; visibility: visible; }
.apm-overlay.apm-overlay--hiding { opacity: 0; }

/* Modal base */
.apm-modal {
    position: relative;
    max-width: 880px;
    width: 100%;
    border-radius: var(--apm-radius);
    overflow: hidden;
    font-family: var(--apm-font);
    transform: scale(0.95) translateY(12px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}
.apm-overlay--visible .apm-modal { transform: scale(1) translateY(0); opacity: 1; }
.apm-overlay--hiding .apm-modal { transform: scale(0.95) translateY(12px); opacity: 0; }

/* Preview */
.apm-modal--preview { outline: 2px dashed var(--apm-brand); outline-offset: -2px; }
.apm-modal__preview-notice {
    background: var(--apm-gradient);
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
}


/* ═══════════════════════════════════════════════
   PROMOTIONAL MODAL (dark theme — unchanged)
   ═══════════════════════════════════════════════ */

.apm-modal:not(.apm-modal--lead-gen) {
    background: var(--apm-promo-bg);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.apm-modal:not(.apm-modal--lead-gen) .apm-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--apm-promo-bg-light);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: var(--apm-promo-text-muted);
    transition: background var(--apm-transition), color var(--apm-transition);
    z-index: 1;
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__close:hover {
    background: var(--apm-promo-border);
    color: var(--apm-promo-text);
}

.apm-modal:not(.apm-modal--lead-gen) .apm-modal__content {
    display: flex;
    gap: 32px;
    padding: 48px;
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__image { flex-shrink: 0; width: 200px; }
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__image img {
    width: 100%; height: auto; border-radius: var(--apm-radius-sm); display: block;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__text { flex: 1; min-width: 0; }
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__headline {
    margin: 0 0 20px; font-size: 32px; font-weight: 700; line-height: 1.2; color: var(--apm-promo-text);
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__message {
    margin: 0 0 28px; font-size: 18px; line-height: 1.7; color: var(--apm-promo-text-dim);
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__message p { margin: 0 0 14px; }
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__message p:last-child { margin-bottom: 0; }
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__message strong { color: var(--apm-promo-text); font-weight: 600; }
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__cta {
    display: inline-block; padding: 18px 40px; background: var(--apm-gradient);
    color: #ffffff !important; font-size: 18px; font-weight: 600;
    text-decoration: none !important; border-radius: 10px;
    transition: transform var(--apm-transition), box-shadow var(--apm-transition);
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__cta:hover {
    transform: translateY(-3px); box-shadow: 0 8px 24px rgba(69, 104, 220, 0.4);
}
.apm-modal:not(.apm-modal--lead-gen) .apm-modal__signature {
    margin: 24px 0 0; font-size: 18px; color: var(--apm-promo-text-muted); font-style: italic;
}


/* ═══════════════════════════════════════════════
   LEAD-GEN MODAL — warm, editorial, parent-facing
   ═══════════════════════════════════════════════ */

.apm-modal--lead-gen {
    background: var(--apm-lg-bg);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 12px 40px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* ── Close button ── */
.apm-modal--lead-gen .apm-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--apm-lg-border);
    background: var(--apm-lg-bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: var(--apm-lg-text-muted);
    transition: all var(--apm-transition);
    z-index: 2;
}
.apm-modal--lead-gen .apm-modal__close:hover {
    background: #ffffff;
    color: var(--apm-lg-text);
    border-color: var(--apm-lg-text-muted);
}
.apm-modal--lead-gen .apm-modal__close:focus {
    outline: 2px solid var(--apm-brand);
    outline-offset: 2px;
}

/* ── Two-column layout ── */
.apm-modal--lead-gen .apm-modal__content--lead-gen {
    display: flex;
    flex-direction: row;
    padding: 0;
    gap: 0;
    min-height: 420px;
}

/* ── Left: intro column ── */
.apm-modal--lead-gen .apm-modal__intro {
    flex: 0 0 42%;
    background: var(--apm-lg-intro-bg);
    padding: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--apm-lg-border);
}

/* Image fills the top of the intro column */
.apm-modal--lead-gen .apm-modal__image {
    width: 100%;
    margin: 0;
    flex-shrink: 0;
}
.apm-modal--lead-gen .apm-modal__image img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    border-radius: 0;
    box-shadow: none;
}

/* Text content below image */
.apm-modal--lead-gen .apm-modal__intro-text {
    padding: 28px 32px 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.apm-modal--lead-gen .apm-modal__headline {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: #4a5568;
    margin: 0 0 10px;
}

.apm-modal--lead-gen .apm-modal__message {
    font-size: 14px;
    line-height: 1.6;
    color: var(--apm-lg-text-dim);
    margin: 0;
}
.apm-modal--lead-gen .apm-modal__message p { margin: 0 0 8px; }
.apm-modal--lead-gen .apm-modal__message p:last-child { margin-bottom: 0; }
.apm-modal--lead-gen .apm-modal__message strong { color: var(--apm-lg-text); }

.apm-modal--lead-gen .apm-modal__signature {
    margin-top: 20px;
    font-size: 13px;
    font-style: normal;
    color: var(--apm-lg-text-muted);
    letter-spacing: 0.01em;
}

/* ── Right: form column ── */
.apm-modal--lead-gen .apm-modal__form {
    flex: 1;
    padding: 44px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    max-height: 85vh;
}

/* Strip the lead-gen plugin's container chrome */
.apm-modal--lead-gen .apm-modal__form .alg-generator-wrap {
    padding: 0;
    margin: 0;
    max-width: none;
}
.apm-modal--lead-gen .apm-modal__form .alg-form-container {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
}

/* Form heading — warm, conversational, leads the eye */
.apm-modal--lead-gen .apm-modal__form .alg-form-heading {
    font-family: var(--apm-font) !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: #3a4a6b !important;
    -webkit-text-fill-color: #3a4a6b !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    text-align: left !important;
    margin: 0 0 4px !important;
    padding: 0 !important;
}

/* Soft reassurance below heading */
.apm-modal--lead-gen .apm-modal__form .alg-form-heading::after {
    content: 'Takes about 30 seconds. No signup needed.';
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #7a85a0;
    margin-top: 6px;
    margin-bottom: 20px;
}

/* Form card — gentle container, inviting not clinical */
.apm-modal--lead-gen .apm-modal__form .alg-form {
    background: #ffffff;
    border: 1px solid var(--apm-lg-border);
    border-radius: var(--apm-radius-sm);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.apm-modal--lead-gen .apm-modal__form .alg-form-group {
    margin-bottom: 20px;
}
.apm-modal--lead-gen .apm-modal__form .alg-form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #4a5872;
    margin-bottom: 6px;
}
.apm-modal--lead-gen .apm-modal__form textarea,
.apm-modal--lead-gen .apm-modal__form select,
.apm-modal--lead-gen .apm-modal__form input[type="text"],
.apm-modal--lead-gen .apm-modal__form input[type="email"] {
    border: 1.5px solid var(--apm-lg-input-border) !important;
    border-radius: 10px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
    font-family: var(--apm-font) !important;
    background: var(--apm-lg-form-bg) !important;
    color: var(--apm-lg-text) !important;
    transition: border-color var(--apm-transition), box-shadow var(--apm-transition);
    outline: none !important;
    box-shadow: none !important;
}
.apm-modal--lead-gen .apm-modal__form textarea:focus,
.apm-modal--lead-gen .apm-modal__form select:focus,
.apm-modal--lead-gen .apm-modal__form input[type="text"]:focus,
.apm-modal--lead-gen .apm-modal__form input[type="email"]:focus {
    border-color: var(--apm-lg-input-focus) !important;
    box-shadow: 0 0 0 3px rgba(69, 104, 220, 0.12) !important;
}
.apm-modal--lead-gen .apm-modal__form textarea {
    min-height: 100px;
    resize: vertical;
}

/* Generate button */
.apm-modal--lead-gen .apm-modal__form .alg-generate-button {
    background: var(--apm-brand) !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 14px 24px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    font-family: var(--apm-font) !important;
    color: #ffffff !important;
    cursor: pointer;
    transition: background var(--apm-transition), transform var(--apm-transition), box-shadow var(--apm-transition);
    letter-spacing: 0.01em;
}
.apm-modal--lead-gen .apm-modal__form .alg-generate-button:hover {
    background: var(--apm-brand-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(69, 104, 220, 0.25);
}

/* Hide advanced tools in popup */
.apm-modal--lead-gen .apm-modal__form .alg-advanced-accordion {
    display: none;
}

/* Popup's namespaced progress modal — z-index set inline by lead-gen-init.js */

/* Mirror the lead-gen suggestion styles for namespaced IDs */
#apm-alg-suggestions {
    position: absolute;
    top: 12px;
    left: 14px;
    right: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    pointer-events: auto;
}
#apm-alg-suggestions .alg-suggestion-pill {
    display: inline-block;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--apm-font);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
#apm-alg-suggestions .alg-suggestion-pill:hover {
    background: rgba(69, 104, 220, 0.08);
    border-color: #4568dc;
    box-shadow: 0 2px 6px rgba(69, 104, 220, 0.15);
}

/* Rotating pill — single suggestion with close X */
.apm-rotating-pill {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.apm-rotating-pill.apm-pill-visible {
    opacity: 1;
    transform: translateY(0);
}
.apm-pill-text {
    cursor: pointer;
}
.apm-pill-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    color: #a0aec0;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}
.apm-pill-close:hover {
    color: #4a5568;
    background: rgba(0, 0, 0, 0.06);
}

/* Also apply popup styles to namespaced IDs */
.apm-modal--lead-gen .apm-modal__form #apm-alg-form-container {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
}
.apm-modal--lead-gen .apm-modal__form #apm-alg-generator {
    padding: 0;
    margin: 0;
    max-width: none;
}

/* Hide email gate styling reset */
.apm-modal--lead-gen .apm-modal__form .alg-email-gate h3 {
    color: var(--apm-lg-text);
}


/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */

@media (max-width: 767px) {
    .apm-overlay {
        padding: 0;
        align-items: flex-end;
    }

    /* Promotional: bottom sheet */
    .apm-modal:not(.apm-modal--lead-gen) {
        max-width: none;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: var(--apm-radius) var(--apm-radius) 0 0;
    }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__content {
        flex-direction: column;
        padding: 32px 24px;
        gap: 20px;
    }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__image {
        width: 120px;
        align-self: center;
    }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__text { text-align: center; }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__headline { font-size: 24px; }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__message { font-size: 16px; }
    .apm-modal:not(.apm-modal--lead-gen) .apm-modal__cta {
        display: block; text-align: center; padding: 16px 32px; font-size: 16px;
    }

    /* Lead-gen: full-screen takeover */
    .apm-modal--lead-gen {
        max-width: none;
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
        overflow-y: auto;
    }
    .apm-modal--lead-gen .apm-modal__content--lead-gen {
        flex-direction: column;
        min-height: auto;
    }
    .apm-modal--lead-gen .apm-modal__intro {
        flex: none;
        padding: 0;
        text-align: center;
        border-right: none;
        border-bottom: 1px solid var(--apm-lg-border);
    }
    .apm-modal--lead-gen .apm-modal__image img {
        height: 160px;
    }
    .apm-modal--lead-gen .apm-modal__intro-text {
        padding: 20px 24px;
    }
    .apm-modal--lead-gen .apm-modal__headline { font-size: 20px; }
    .apm-modal--lead-gen .apm-modal__form {
        flex: none;
        padding: 28px 24px 32px;
        max-height: none;
    }
    .apm-modal--lead-gen .apm-modal__form .alg-form-heading {
        text-align: center !important;
    }

    .apm-modal__close {
        top: 12px;
        right: 12px;
    }
}

/* Hide on mobile if disabled */
@media (max-width: 767px) {
    .apm-overlay.apm-overlay--hide-mobile {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .apm-overlay,
    .apm-modal,
    .apm-modal__close,
    .apm-modal__cta,
    .alg-generate-button {
        transition: none !important;
    }
    .apm-overlay--visible .apm-modal { transform: none; }
}

/* Print */
@media print {
    .apm-overlay { display: none !important; }
}
