/**
 * Murls Smart Popups — Frontend Stylesheet
 *
 * All rules are scoped to .murls- prefixed classes to avoid conflicts
 * with any theme or plugin. Popups are hidden by default; the JavaScript
 * layer adds .murls-visible when the popup should be displayed.
 *
 * Layout combinations supported:
 *   - Image only
 *   - Message only
 *   - Badge + message
 *   - Badge + message + button
 *   - Image + message + button (image never breaks layout)
 *   - Any combination of the above
 *
 * @package Murls_Smart_Popups
 * @since   1.3.0
 */

/* ── Overlay ─────────────────────────────────────────────────────────────── */

.murls-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.murls-popup-overlay.murls-visible {
    display: flex;
    animation: murls-fade-in 0.22s ease both;
}

/* ── Popup Box ───────────────────────────────────────────────────────────── */

.murls-popup-box {
    background: #ffffff;
    border-radius: 16px;
    max-width: 460px;
    width: 100%;
    position: relative;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.22),
        0 4px 16px rgba(0, 0, 0, 0.08);
    animation: murls-slide-up 0.28s cubic-bezier(0.34, 1.4, 0.64, 1) both;
    overflow: hidden;
}

/* ── Type accent stripe ──────────────────────────────────────────────────── */

.murls-popup-type-announcement  { border-top: 3px solid #6c47ff; }
.murls-popup-type-email_capture { border-top: 3px solid #6b46c1; }
.murls-popup-type-exit_intent   { border-top: 3px solid #e53e3e; }

/* ── Close Button ────────────────────────────────────────────────────────── */

.murls-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.07);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}

.murls-popup-close:hover,
.murls-popup-close:focus-visible {
    background: rgba(0, 0, 0, 0.14);
    color: #111827;
    outline: none;
}

/* ── Image area ──────────────────────────────────────────────────────────── */

.murls-popup-image {
    width: 100%;
    line-height: 0;
    overflow: hidden;
    max-height: 260px;
}

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

/* Image-only popup: let the image fill naturally */
.murls-popup-image.murls-popup-image-only {
    max-height: none;
    border-radius: 0 0 16px 16px;
}

/* ── Body (badge + heading + message + button) ───────────────────────────── */

.murls-popup-body {
    padding: 24px 28px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

/* ── Badge ───────────────────────────────────────────────────────────────── */

.murls-popup-badge {
    display: inline-flex;
    align-items: center;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 100px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.4;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Heading ─────────────────────────────────────────────────────────────── */

.murls-popup-heading {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
    color: #111827;
    letter-spacing: -0.02em;
    word-break: break-word;
}

/* ── Message ─────────────────────────────────────────────────────────────── */

.murls-popup-message {
    margin: 0;
    font-size: 15px;
    line-height: 1.65;
    color: #4b5563;
    word-break: break-word;
}

/* ── CTA Button ──────────────────────────────────────────────────────────── */

.murls-popup-btn {
    display: block;
    width: 100%;
    padding: 13px 20px;
    background: #6c47ff;
    color: #ffffff;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    line-height: 1.4;
    transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
    box-shadow: 0 4px 14px rgba(108, 71, 255, 0.3);
    word-break: break-word;
}

.murls-popup-btn:hover,
.murls-popup-btn:focus-visible {
    background: #5835e8;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(108, 71, 255, 0.4);
    outline: none;
    color: #ffffff;
    text-decoration: none;
}

.murls-popup-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(108, 71, 255, 0.3);
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes murls-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes murls-slide-up {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media ( max-width: 520px ) {

    .murls-popup-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .murls-popup-box {
        border-radius: 16px 16px 12px 12px;
        max-width: 100%;
    }

    .murls-popup-image {
        max-height: 200px;
    }

    .murls-popup-body {
        padding: 20px 20px 24px;
        gap: 12px;
    }

    .murls-popup-heading {
        font-size: 17px;
    }

    .murls-popup-message {
        font-size: 14px;
    }

    .murls-popup-btn {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* ── Position classes ────────────────────────────────────────────────────── */

/* Default (center) is already set by align-items/justify-content: center */

.murls-popup-overlay.murls-pos-top-left      { align-items: flex-start; justify-content: flex-start; padding: 20px; }
.murls-popup-overlay.murls-pos-top-center    { align-items: flex-start; justify-content: center;     padding: 20px; }
.murls-popup-overlay.murls-pos-top-right     { align-items: flex-start; justify-content: flex-end;   padding: 20px; }
.murls-popup-overlay.murls-pos-middle-left   { align-items: center;     justify-content: flex-start; padding: 20px; }
.murls-popup-overlay.murls-pos-center        { align-items: center;     justify-content: center;     padding: 16px; }
.murls-popup-overlay.murls-pos-middle-right  { align-items: center;     justify-content: flex-end;   padding: 20px; }
.murls-popup-overlay.murls-pos-bottom-left   { align-items: flex-end;   justify-content: flex-start; padding: 20px; }
.murls-popup-overlay.murls-pos-bottom-center { align-items: flex-end;   justify-content: center;     padding: 20px; }
.murls-popup-overlay.murls-pos-bottom-right  { align-items: flex-end;   justify-content: flex-end;   padding: 20px; }

/* Corner and edge popups: slightly smaller max-width for a widget feel */
.murls-popup-overlay.murls-pos-top-left    .murls-popup-box,
.murls-popup-overlay.murls-pos-top-right   .murls-popup-box,
.murls-popup-overlay.murls-pos-bottom-left .murls-popup-box,
.murls-popup-overlay.murls-pos-bottom-right .murls-popup-box {
    max-width: 380px;
}

/* Bottom positions: slide up from bottom */
.murls-popup-overlay.murls-pos-bottom-left   .murls-popup-box,
.murls-popup-overlay.murls-pos-bottom-center .murls-popup-box,
.murls-popup-overlay.murls-pos-bottom-right  .murls-popup-box {
    animation: murls-slide-up 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
    border-radius: 16px;
}

/* Top positions: slide down from top */
.murls-popup-overlay.murls-pos-top-left   .murls-popup-box,
.murls-popup-overlay.murls-pos-top-center .murls-popup-box,
.murls-popup-overlay.murls-pos-top-right  .murls-popup-box {
    animation: murls-slide-down 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@keyframes murls-slide-down {
    from { opacity: 0; transform: translateY(-24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

/* ── Device visibility ───────────────────────────────────────────────────── */

/*
 * The JavaScript layer already skips popups that do not match the current
 * device, so these rules are a cache-safe backstop: if markup is served from a
 * cached page before scripts run, the popup still cannot flash on the wrong
 * device. Breakpoint must stay in sync with MOBILE_BREAKPOINT in popup.js.
 */

@media ( max-width: 520px ) {
    .murls-popup-overlay.murls-device-desktop { display: none !important; }
}

@media ( min-width: 521px ) {
    .murls-popup-overlay.murls-device-mobile { display: none !important; }
}

/* ── Themes ──────────────────────────────────────────────────────────────── */

/*
 * "default" intentionally has no rules — it is the original design and stays
 * pixel-identical. Each theme below only overrides colour, weight, and radius,
 * never layout, so every popup keeps the same structure and spacing.
 */

/* Minimal — flat, quiet, no shadow */

.murls-popup-box.murls-popup-theme-minimal {
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    border-top: 1px solid #e5e7eb;
}

.murls-popup-box.murls-popup-theme-minimal .murls-popup-badge {
    background: #f3f4f6;
    color: #4b5563;
    font-weight: 600;
}

.murls-popup-box.murls-popup-theme-minimal .murls-popup-heading {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.murls-popup-box.murls-popup-theme-minimal .murls-popup-btn {
    background: #111827;
    border-radius: 6px;
    box-shadow: none;
    font-weight: 600;
}

.murls-popup-box.murls-popup-theme-minimal .murls-popup-btn:hover,
.murls-popup-box.murls-popup-theme-minimal .murls-popup-btn:focus-visible {
    background: #374151;
    box-shadow: none;
}

/* Bold — high contrast, heavy type */

.murls-popup-box.murls-popup-theme-bold {
    border-top: 6px solid #6c47ff;
    border-radius: 20px;
}

.murls-popup-box.murls-popup-theme-bold .murls-popup-badge {
    background: #6c47ff;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.murls-popup-box.murls-popup-theme-bold .murls-popup-heading {
    font-size: 25px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.murls-popup-box.murls-popup-theme-bold .murls-popup-btn {
    font-size: 16px;
    font-weight: 800;
    padding: 15px 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Seasonal — warm festive gradient */

.murls-popup-box.murls-popup-theme-seasonal {
    border-top: 3px solid #f59e0b;
    background: linear-gradient(165deg, #fffbeb 0%, #ffffff 55%);
}

.murls-popup-box.murls-popup-theme-seasonal .murls-popup-badge {
    background: #fef3c7;
    color: #92400e;
}

.murls-popup-box.murls-popup-theme-seasonal .murls-popup-heading {
    color: #7c2d12;
}

.murls-popup-box.murls-popup-theme-seasonal .murls-popup-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.3);
}

.murls-popup-box.murls-popup-theme-seasonal .murls-popup-btn:hover,
.murls-popup-box.murls-popup-theme-seasonal .murls-popup-btn:focus-visible {
    background: linear-gradient(135deg, #d97706 0%, #b91c1c 100%);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

/* Dark — light text on near-black */

.murls-popup-box.murls-popup-theme-dark {
    background: #17181c;
    border-top: 3px solid #8b5cf6;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-close {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d5db;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-close:hover,
.murls-popup-box.murls-popup-theme-dark .murls-popup-close:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #c4b5fd;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-heading {
    color: #f9fafb;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-message {
    color: #9ca3af;
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-btn {
    background: #8b5cf6;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.murls-popup-box.murls-popup-theme-dark .murls-popup-btn:hover,
.murls-popup-box.murls-popup-theme-dark .murls-popup-btn:focus-visible {
    background: #7c3aed;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

/* Branded — saturated brand-colour panel */

.murls-popup-box.murls-popup-theme-branded {
    background: linear-gradient(160deg, #6c47ff 0%, #4c1d95 100%);
    border-top: none;
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-close {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-close:hover,
.murls-popup-box.murls-popup-theme-branded .murls-popup-close:focus-visible {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-heading {
    color: #ffffff;
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-message {
    color: rgba(255, 255, 255, 0.85);
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-btn {
    background: #ffffff;
    color: #4c1d95;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.murls-popup-box.murls-popup-theme-branded .murls-popup-btn:hover,
.murls-popup-box.murls-popup-theme-branded .murls-popup-btn:focus-visible {
    background: #f5f3ff;
    color: #4c1d95;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}
