/**
 * GeoBlock Redirect Pro - Popup Styling
 * Mobile-first, accessible design with CSS custom property support
 */

/* ==========================================================================
   CSS Custom Properties (defaults — overridden inline per template/customizer)
   ========================================================================== */
.geoblock-popup {
    --geoblock-primary: #4CAF50;
    --geoblock-bg: #ffffff;
    --geoblock-text: #333333;
    --geoblock-btn-bg: #4CAF50;
    --geoblock-btn-text: #ffffff;
    --geoblock-radius: 12px;
    --geoblock-overlay-opacity: 0.5;
    --geoblock-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Popup Container — z-index and !important ensure visibility above page builders (Divi, Elementor, etc.) */
.geoblock-popup {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999999 !important;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    font-family: var(--geoblock-font);
    isolation: isolate;
    pointer-events: none;
}

.geoblock-popup-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Overlay */
.geoblock-popup-overlay {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, var(--geoblock-overlay-opacity));
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Content Container */
.geoblock-popup-content {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: var(--geoblock-bg);
    border-radius: var(--geoblock-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    padding: 32px 24px;
    text-align: center;
    animation: slideUp 0.3s ease-out;
    color: var(--geoblock-text);
}

/* Background image support via CSS custom property */
.geoblock-popup-content::before {
    content: '';
    display: none;
}

.geoblock-popup[style*="--geoblock-bg-image"] .geoblock-popup-content::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--geoblock-bg-image);
    background-size: cover;
    background-position: center;
    border-radius: var(--geoblock-radius);
    z-index: 0;
    opacity: 0.15;
}

.geoblock-popup[style*="--geoblock-bg-image"] .geoblock-popup-content > * {
    position: relative;
    z-index: 1;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, -40%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* ==========================================================================
   Test Mode Badge
   ========================================================================== */
.geoblock-test-badge {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    background: #e53e3e;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 12px;
    border-radius: 4px;
    z-index: 10;
    line-height: 1.4;
    white-space: nowrap;
}

/* ==========================================================================
   Close Button
   ========================================================================== */
.geoblock-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
    z-index: 2;
}

.geoblock-popup-close:hover {
    color: var(--geoblock-text);
}

/* ==========================================================================
   Icon & Flag
   ========================================================================== */
.geoblock-popup-icon {
    color: var(--geoblock-primary);
    margin-bottom: 16px;
}

.geoblock-popup-icon svg.geoblock-popup-pin {
    width: 48px;
    height: 48px;
}

/* Flag emoji — hidden until JS populates it */
.geoblock-popup-flag {
    display: none;
    font-size: 48px;
    line-height: 1.2;
}

/* When flag is shown, it replaces the SVG icon */
.geoblock-popup-flag[style*="display: block"] ~ .geoblock-popup-pin {
    display: none;
}

/* ==========================================================================
   Title
   ========================================================================== */
.geoblock-popup-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--geoblock-text);
    margin: 0 0 12px;
    line-height: 1.3;
}

/* ==========================================================================
   Message
   ========================================================================== */
.geoblock-popup-message {
    font-size: 16px;
    color: var(--geoblock-text);
    opacity: 0.7;
    margin: 0 0 24px;
    line-height: 1.5;
}

/* ==========================================================================
   Action Buttons
   ========================================================================== */
.geoblock-popup-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-direction: column;
}

@media (min-width: 480px) {
    .geoblock-popup-actions {
        flex-direction: row;
    }
}

.geoblock-button {
    flex: 1;
    padding: 14px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    outline: none;
    font-family: var(--geoblock-font);
}

.geoblock-button:focus {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.geoblock-button-primary {
    background: var(--geoblock-btn-bg);
    color: var(--geoblock-btn-text);
    border-color: var(--geoblock-btn-bg);
}

.geoblock-button-primary:hover {
    filter: brightness(0.92);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.geoblock-button-secondary {
    background: transparent;
    color: var(--geoblock-text);
    border-color: #ddd;
}

.geoblock-button-secondary:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: #ccc;
}

/* ==========================================================================
   Footer Text
   ========================================================================== */
.geoblock-popup-footer {
    font-size: 12px;
    color: var(--geoblock-text);
    opacity: 0.5;
    margin: 0;
    line-height: 1.4;
}

/* ==========================================================================
   Mobile Optimizations
   ========================================================================== */
@media (max-width: 479px) {
    .geoblock-popup-content {
        width: 95%;
        padding: 24px 16px;
        border-radius: 8px;
    }

    .geoblock-popup-title {
        font-size: 20px;
    }

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

    .geoblock-button {
        padding: 12px 20px;
        font-size: 14px;
    }

    .geoblock-popup-footer {
        font-size: 11px;
    }
}

/* ==========================================================================
   Accessibility - Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .geoblock-popup {
        transition: none;
    }

    .geoblock-popup-content {
        animation: none;
    }

    .geoblock-button {
        transition: none;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .geoblock-popup {
        --geoblock-bg: #1e1e1e;
        --geoblock-text: #ffffff;
    }

    .geoblock-popup-close {
        color: #999;
    }

    .geoblock-popup-close:hover {
        color: #ffffff;
    }

    .geoblock-button-secondary {
        background: #2a2a2a;
        color: #cccccc;
        border-color: #444;
    }

    .geoblock-button-secondary:hover {
        background: #333;
        color: #ffffff;
        border-color: #555;
    }
}

/* ==========================================================================
   Print - Hide Popup
   ========================================================================== */
@media print {
    .geoblock-popup {
        display: none !important;
    }
}
