/**
 * WordPress Popup Creator - Frontend Stylesheet
 * Fully responsive, modern modal styling with 4 layout modes.
 */

/* Modal Root Wrapper */
.wpc-popup-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.wpc-popup-wrap *,
.wpc-popup-wrap *::before,
.wpc-popup-wrap *::after {
    box-sizing: border-box;
}

/* Screen reader utility */
.wpc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Backdrop Overlay */
.wpc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--wpc-overlay-color, rgba(15, 23, 42, 0.65));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.wpc-popup-wrap.wpc-show .wpc-overlay {
    opacity: 1;
}

/* Modal Dialog Card */
.wpc-dialog {
    position: relative;
    z-index: 999999;
    width: 92%;
    max-width: 740px;
    max-height: 90vh;
    background: var(--wpc-bg-color, #ffffff);
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.wpc-popup-wrap.wpc-show .wpc-dialog {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Close Button */
.wpc-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 20;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(241, 245, 249, 0.85);
    color: #475569;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.wpc-close-btn:hover,
.wpc-close-btn:focus {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.08);
    outline: none;
}

/* Body Layout Wrapper */
.wpc-body-wrapper {
    display: flex;
    width: 100%;
    min-height: 360px;
    position: relative;
}

/* Media Column & Image */
.wpc-media-col {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
}

.wpc-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Content Column */
.wpc-content-col {
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 5;
}

/* Title & Typography */
.wpc-title {
    margin: 0 0 10px 0;
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--wpc-title-color, #0f172a);
}

.wpc-description {
    margin: 0 0 20px 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--wpc-desc-color, #475569);
}

/* Form & Inputs */
.wpc-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.wpc-field-group {
    display: flex;
    flex-direction: column;
}

.wpc-input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font-size: 15px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background-color: #ffffff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wpc-input:focus {
    border-color: var(--wpc-btn-bg-color, #2563eb);
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.15);
}

.wpc-input.wpc-error-input {
    border-color: #ef4444;
    box-shadow: 0 0 0 3.5px rgba(239, 68, 68, 0.15);
}

/* Intl-Tel-Input Overrides & Dropdown Stacking */
.wpc-form .iti {
    width: 100%;
    position: relative;
    display: block;
}

/* Beautiful dedicated country code section */
.wpc-form .iti__country-container {
    position: absolute;
    top: 1.5px;
    bottom: 1.5px;
    left: 1.5px;
    z-index: 2;
    border-radius: 6.5px 0 0 6.5px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    width: auto !important;
    max-width: 95px !important;
    pointer-events: none; /* Allows clicks to pass through to input */
}

/* Reset button styling so the WordPress theme cannot turn it into a red button or add borders */
.wpc-form .iti__selected-country {
    pointer-events: auto !important; /* Only the button intercepts clicks */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 6.5px 0 0 6.5px !important;
    padding: 0 8px 0 10px !important;
    margin: 0 !important;
    color: #1e293b !important;
    cursor: pointer !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    transition: background-color 0.2s ease;
}

.wpc-form .iti__selected-country:hover,
.wpc-form .iti__selected-country:focus {
    background-color: #f1f5f9 !important;
    outline: none !important;
}

/* Clear, guaranteed-visible dropdown arrow triangle */
.wpc-form .iti__arrow {
    display: inline-block !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 3.5px solid transparent !important;
    border-right: 3.5px solid transparent !important;
    border-top: 4.5px solid #64748b !important;
    margin-left: 6px !important;
    margin-right: 2px !important;
    vertical-align: middle !important;
    transition: transform 0.2s ease;
}

.wpc-form .iti__arrow--up {
    border-top: none !important;
    border-bottom: 4.5px solid #64748b !important;
}

.wpc-form .iti__selected-dial-code {
    margin-left: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #334155 !important;
    line-height: 1 !important;
}

/* Force adequate left padding and ensure phone input is 100% clickable and typeable */
.wpc-form .iti input.wpc-phone-input {
    position: relative !important;
    z-index: 1 !important;
    cursor: text !important;
    pointer-events: auto !important;
    padding-left: 100px !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, padding-left 0.15s ease;
}

/* Crucial: Pull the dropdown and fullscreen mobile popup in front of the modal (#wpc-popup-modal is 999999) */
.iti--container,
.iti--fullscreen-popup.iti--container {
    z-index: 99999999 !important;
}

.iti__dropdown-content {
    z-index: 99999999 !important;
    box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.2), 0 4px 12px -2px rgba(0, 0, 0, 0.1) !important;
    border-radius: 10px !important;
    border: 1px solid #cbd5e1 !important;
    background: #ffffff !important;
    overflow: hidden !important;
}

.iti__search-input {
    padding: 12px 14px !important;
    font-size: 14px !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    outline: none !important;
    box-sizing: border-box !important;
    width: 100% !important;
    background: #f8fafc !important;
    color: #0f172a !important;
}

.iti__search-input:focus {
    background: #ffffff !important;
}

.iti__country-list {
    max-height: 220px !important;
    list-style: none !important;
    padding: 4px 0 !important;
    margin: 0 !important;
}

.iti__country {
    padding: 9px 14px !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease;
}

.iti__country:hover,
.iti__country.iti__highlight {
    background-color: #f1f5f9 !important;
}

/* Action Button */
.wpc-btn {
    width: 100%;
    height: 48px;
    margin-top: 4px;
    background: var(--wpc-btn-bg-color, #2563eb);
    color: var(--wpc-btn-text-color, #ffffff);
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: filter 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wpc-btn:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wpc-btn:active {
    transform: translateY(0);
}

.wpc-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Spinner */
.wpc-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: wpc-spin 0.8s linear infinite;
}

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

/* Status Notifications */
.wpc-status-box {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
    animation: wpc-fade-in 0.25s ease;
}

.wpc-status-box.wpc-success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.wpc-status-box.wpc-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

@keyframes wpc-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
 * 4 DISTINCT LAYOUT CONFIGURATIONS
 * ------------------------------------------------------------- */

/* Layout 1: Split Left (Image Left, Form Right) */
.wpc-layout-split_left .wpc-media-col {
    flex: 0 0 45%;
    max-width: 45%;
}
.wpc-layout-split_left .wpc-content-col {
    flex: 0 0 55%;
    max-width: 55%;
}

/* Layout 2: Split Right (Form Left, Image Right) */
.wpc-layout-split_right .wpc-content-col {
    flex: 0 0 55%;
    max-width: 55%;
}
.wpc-layout-split_right .wpc-media-col {
    flex: 0 0 45%;
    max-width: 45%;
}

/* Layout 3: Banner Top (Full Width Banner on Top, Content Below) */
.wpc-layout-banner_top .wpc-dialog {
    max-width: 540px;
}
.wpc-layout-banner_top .wpc-body-wrapper {
    flex-direction: column;
    min-height: auto;
}
.wpc-layout-banner_top .wpc-media-col {
    width: 100%;
    height: 200px;
}
.wpc-layout-banner_top .wpc-content-col {
    padding: 28px 32px;
}

/* Layout 4: Hero Background (Image as full background with contrast scrim) */
.wpc-layout-hero_bg .wpc-dialog {
    max-width: 520px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.wpc-layout-hero_bg .wpc-hero-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.90) 0%, rgba(30, 41, 59, 0.85) 100%);
    z-index: 1;
}
.wpc-layout-hero_bg .wpc-close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}
.wpc-layout-hero_bg .wpc-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #ffffff;
}
.wpc-layout-hero_bg .wpc-title {
    color: #ffffff;
}
.wpc-layout-hero_bg .wpc-description {
    color: #cbd5e1;
}
.wpc-layout-hero_bg .wpc-input {
    background-color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.4);
    color: #0f172a;
}
.wpc-layout-hero_bg .wpc-input:focus {
    background-color: #ffffff;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3.5px rgba(96, 165, 250, 0.3);
}
.wpc-layout-hero_bg .wpc-content-col {
    width: 100%;
    padding: 44px 36px 36px 36px;
}

/* -------------------------------------------------------------
 * RESPONSIVE MOBILE STYLES (< 680px)
 * ------------------------------------------------------------- */
@media (max-width: 680px) {
    .wpc-dialog {
        width: 92%;
        max-width: 440px;
        border-radius: 20px;
    }

    .wpc-body-wrapper {
        flex-direction: column !important;
        min-height: auto;
    }

    /* Split layouts stack vertically on small screens */
    .wpc-layout-split_left .wpc-media-col,
    .wpc-layout-split_right .wpc-media-col {
        flex: none;
        width: 100%;
        max-width: 100%;
        height: auto;
        order: -1; /* Ensure image is always on top on mobile */
    }

    .wpc-image {
        height: auto;
        max-height: 60vh; /* Prevents absolutely massive posters from being too ridiculous */
        object-fit: contain; /* Ensures the whole image is visible if it hits the max-height */
        object-position: center top; 
    }

    .wpc-layout-split_left .wpc-content-col,
    .wpc-layout-split_right .wpc-content-col {
        flex: none;
        width: 100%;
        max-width: 100%;
        padding: 28px 20px 24px 20px;
        text-align: center;
    }

    .wpc-layout-banner_top .wpc-media-col {
        flex: none;
        height: auto;
    }

    .wpc-layout-banner_top .wpc-content-col,
    .wpc-layout-hero_bg .wpc-content-col {
        flex: none;
        padding: 28px 20px 24px 20px;
        text-align: center;
    }

    .wpc-title {
        font-size: 1.45rem;
        margin-bottom: 12px;
        padding-right: 24px; /* Give room for close button */
        padding-left: 24px; /* Keep centered */
    }

    .wpc-description {
        font-size: 0.92rem;
        margin-bottom: 20px;
    }

    .wpc-input {
        height: 48px;
        font-size: 16px; /* Prevents auto-zoom in mobile Safari */
        text-align: center;
    }

    .wpc-btn {
        height: 50px;
        font-size: 16px;
        margin-top: 8px;
    }

    .wpc-close-btn {
        top: 12px;
        right: 12px;
        width: 34px;
        height: 34px;
        font-size: 22px;
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

