/* Elementor Editor Overrides - HIGHEST SPECIFICITY */
body.elementor-editor-active .elementor-element.woowall-protected,
body.elementor-editor-active .elementor-section.woowall-protected,
body.elementor-editor-active .elementor-container.woowall-protected,
body.elementor-editor-active .e-con.woowall-protected,
body.elementor-editor-active .woowall-wrapper.woowall-protected,
.elementor-editor-active .elementor-element.woowall-protected,
.elementor-editor-active .elementor-section.woowall-protected,
.elementor-editor-active .elementor-container.woowall-protected,
.elementor-editor-active .e-con.woowall-protected,
.woowall-editor-mode .woowall-wrapper.woowall-protected,
.woowall-editor-mode .elementor-element.woowall-protected,
.woowall-editor-mode .elementor-section.woowall-protected,
.woowall-editor-mode .elementor-container.woowall-protected,
.woowall-editor-mode .e-con.woowall-protected {
    pointer-events: auto !important;
    user-select: auto !important;
    max-height: none !important;
    overflow: visible !important;
    filter: none !important;
    opacity: 1 !important;
}

body.elementor-editor-active .elementor-element.woowall-protected::after,
body.elementor-editor-active .elementor-section.woowall-protected::after,
body.elementor-editor-active .elementor-container.woowall-protected::after,
body.elementor-editor-active .e-con.woowall-protected::after,
body.elementor-editor-active .woowall-wrapper.woowall-protected::after,
.elementor-editor-active .elementor-element.woowall-protected::after,
.elementor-editor-active .elementor-section.woowall-protected::after,
.elementor-editor-active .elementor-container.woowall-protected::after,
.elementor-editor-active .e-con.woowall-protected::after,
.woowall-editor-mode .woowall-wrapper.woowall-protected::after,
.woowall-editor-mode .elementor-element.woowall-protected::after,
.woowall-editor-mode .elementor-section.woowall-protected::after,
.woowall-editor-mode .elementor-container.woowall-protected::after,
.woowall-editor-mode .e-con.woowall-protected::after {
    display: none !important;
    content: none !important;
}

body.elementor-editor-active .elementor-element.woowall-protected::before,
body.elementor-editor-active .elementor-section.woowall-protected::before,
body.elementor-editor-active .elementor-container.woowall-protected::before,
body.elementor-editor-active .e-con.woowall-protected::before,
body.elementor-editor-active .woowall-wrapper.woowall-protected::before,
.elementor-editor-active .elementor-element.woowall-protected::before,
.elementor-editor-active .elementor-section.woowall-protected::before,
.elementor-editor-active .elementor-container.woowall-protected::before,
.elementor-editor-active .e-con.woowall-protected::before,
.woowall-editor-mode .woowall-wrapper.woowall-protected::before,
.woowall-editor-mode .elementor-element.woowall-protected::before,
.woowall-editor-mode .elementor-section.woowall-protected::before,
.woowall-editor-mode .elementor-container.woowall-protected::before,
.woowall-editor-mode .e-con.woowall-protected::before {
    display: none !important;
    content: none !important;
}

body.elementor-editor-active .woowall-controls[data-for],
.elementor-editor-active .woowall-controls[data-for],
.woowall-editor-mode .woowall-controls[data-for] {
    display: none !important;
}

body.elementor-editor-active .woowall-wrapper.woowall-protected .woowall-content-preview,
body.elementor-editor-active .elementor-element.woowall-protected > .e-con-inner,
body.elementor-editor-active .elementor-section.woowall-protected > .e-con-inner,
body.elementor-editor-active .elementor-container.woowall-protected > .e-con-inner,
body.elementor-editor-active .e-con.woowall-protected > .e-con-inner,
.elementor-editor-active .woowall-wrapper.woowall-protected .woowall-content-preview,
.elementor-editor-active .elementor-element.woowall-protected > .e-con-inner,
.elementor-editor-active .elementor-section.woowall-protected > .e-con-inner,
.elementor-editor-active .elementor-container.woowall-protected > .e-con-inner,
.elementor-editor-active .e-con.woowall-protected > .e-con-inner {
    filter: none !important;
    opacity: 1 !important;
}

/* Protected Container Styles - Modern approach with universal blur */
.woowall-wrapper.woowall-protected,
.elementor-element.woowall-protected,
.elementor-section.woowall-protected,
.elementor-container.woowall-protected,
.e-con.woowall-protected {
    position: relative !important;
    pointer-events: none !important;
    user-select: none !important;
    max-height: 200px !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    z-index: 10 !important;
}

.woowall-wrapper.woowall-protected::after,
.elementor-element.woowall-protected::after,
.elementor-section.woowall-protected::after,
.elementor-container.woowall-protected::after,
.e-con.woowall-protected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), rgba(255,255,255,0.6));
    pointer-events: none;
    z-index: 5;
}

/* Controls Wrapper */
.woowall-controls {
    position: relative;
    text-align: center;
    margin: 2em 0;
    z-index: 10;
}

.woowall-wrapper {
    position: relative;
}

/* Controls positioned within protected containers as full overlay */
.woowall-controls[data-for] {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 20 !important;
    text-align: center;
    pointer-events: none;
    filter: none !important;
    padding: 1em;
    background: transparent !important;
}

/* Allow button to be clickable while overlay blocks other interactions */
.woowall-controls[data-for] .woowall-unlock-button {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 21 !important;
    padding: 1em 2em !important;
    border-radius: 6px !important;
    border: none !important;
    font-weight: bold !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    cursor: pointer !important;
    text-decoration: none !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    filter: none !important;
}

/* Apply default colors only to buttons without custom colors */
.woowall-wrapper .woowall-controls[data-for] .woowall-unlock-button:not(.woowall-custom-colors) {
    background: #0073aa !important;
    color: white !important;
}

.woowall-controls[data-for] .woowall-modal-overlay {
    pointer-events: auto !important;
    z-index: 2147483647 !important; /* Same as other modals */
}

/* Ensure protected containers are positioned and have proper spacing */
.woowall-wrapper.woowall-protected,
.elementor-element.woowall-protected,
.elementor-section.woowall-protected, 
.elementor-container.woowall-protected,
.e-con.woowall-protected {
    position: relative !important;
    margin-bottom: 2em; /* Add space between protected instances */
}

/* Ensure unlock button stands out in multiple instance scenarios */
.woowall-controls[data-for] .woowall-unlock-button {
    box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
    border: 2px solid rgba(255,255,255,0.1) !important;
}

/* Remove any spacing conflicts - spacing is handled above */
.woowall-protected-content {
    position: relative;
    z-index: 10;
}
.woowall-controls .woowall-unlock-button {
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* Only apply default colors when no inline style is present */
.woowall-controls .woowall-unlock-button:not([style*="background"]) {
    background: #0073aa;
}

.woowall-controls .woowall-unlock-button:not([style*="color"]) {
    color: #fff;
}

/* Unlock Button */
.woowall-unlock-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875em 1.5em;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 0.5em;
}

/* Only apply default colors when no inline style is present */
.woowall-unlock-button:not([style*="color"]) {
    color: #fff;
}

.woowall-unlock-button:not([style*="background"]) {
    background: var(--woowall-brand-primary, #0073aa);
}

.woowall-unlock-button:hover:not([style*="background"]) {
    background: var(--woowall-brand-secondary, #005c8a);
    transform: translateY(-1px);
}

/* Custom colored buttons still get hover transform effect */
.woowall-unlock-button[style*="background"]:hover {
    transform: translateY(-1px);
    filter: brightness(0.9);
}

.woowall-unlock-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--woowall-brand-primary, #0073aa);
}

.woowall-unlock-button:active {
    transform: translateY(1px);
}

/* Modal Base Styles */
.woowall-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2147483647; /* Maximum z-index to be above everything */
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

/* Active modal styling - ensure proper stacking and visibility */
.woowall-modal-overlay[data-active="1"] {
    opacity: 1;
    z-index: 2147483647; /* Maximum z-index */
}

/* Hide all buttons when any modal is active */
body.woowall-modal-open .woowall-unlock-button {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* But keep the button in the active modal visible */
.woowall-modal-overlay[data-active="1"] .woowall-unlock-button {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.woowall-modal {
    background: #fff;
    padding: 2em 2.5em;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 100%;
    transform: translateY(20px);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2147483647; /* Ensure modal content is above everything */
}

.woowall-modal-overlay[data-active="1"] .woowall-modal {
    transform: translateY(0);
}

/* Form Styles */
.woowall-access-form {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.woowall-form-fields {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.woowall-modal h2 {
    margin: 0 0 1em;
    font-size: 1.4em;
    line-height: 1.3;
    color: #222;
}

/* Payment info styling */
.woowall-payment-info {
    background: #f8f9fa;
    border: 2px solid #007cba;
    border-radius: 8px;
    padding: 1em;
    margin: 1em 0;
    text-align: center;
    font-size: 1.1em;
    color: #333;
}

.woowall-payment-info strong {
    color: inherit;
}

/* Brand styling for payment info */
.woowall-modal.woowall-style-brand .woowall-payment-info {
    background: rgba(255,255,255,0.15) !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    color: inherit !important;
}

.woowall-modal.woowall-style-brand .woowall-payment-info strong {
    color: inherit !important;
}

.woowall-access-form label {
    display: block;
    margin: 0;
    text-align: left;
}

.woowall-access-form label span {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 700;
    color: #333;
}

.woowall-access-form input[type="email"],
.woowall-access-form input[type="text"],
.woowall-access-form input[type="tel"] {
    width: 100%;
    padding: 0.75em 1em;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.2s ease;
}

.woowall-access-form input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}

.woowall-access-form input.woowall-invalid {
    border-color: #dc3232;
    background-color: #fff8f8;
}

.woowall-access-form input.woowall-invalid:focus {
    box-shadow: 0 0 0 2px rgba(220,50,50,0.2);
}

/* GDPR Checkbox */
.gdpr-label {
    display: flex !important;
    align-items: flex-start;
    gap: 0.75em;
    font-size: 0.9em;
    color: #666;
    margin-top: 0.5em;
    cursor: pointer;
}

.gdpr-label input[type="checkbox"] {
    margin-top: 0.25em;
}

/* Submit Button */
.woowall-submit-button {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 1em 1.5em;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    position: relative;
    overflow: hidden;
}

.woowall-submit-button:hover {
    background: #005c8a;
    transform: translateY(-1px);
}

.woowall-submit-button:focus {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa;
}

.woowall-submit-button:active {
    transform: translateY(1px);
}

.woowall-submit-button[disabled] {
    background: #999;
    cursor: not-allowed;
    opacity: 0.8;
    transform: none;
}

/* Loading Spinner */
.woowall-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: woowall-spin 0.8s linear infinite;
}

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

/* Message Styles */
.woowall-error-message,
.woowall-success-message {
    padding: 0.75em 1em;
    border-radius: 4px;
    margin-bottom: 1em;
    font-size: 0.9em;
    animation: woowall-message-slide-down 0.3s ease;
}

.woowall-error-message {
    background: #fee;
    color: #c00;
    border: 1px solid rgba(204,0,0,0.2);
}

.woowall-success-message {
    background: #e8f6e8;
    color: #287728;
    border: 1px solid rgba(40,119,40,0.2);
}

@keyframes woowall-message-slide-down {
    from { 
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Style Variants */
.woowall-style-minimal {
    background: #f9f9f9 !important;
    border: 1px solid #e0e0e0 !important;
    box-shadow: none !important;
}

.woowall-style-minimal .woowall-submit-button {
    background: #333 !important;
}

.woowall-style-minimal .woowall-submit-button:hover {
    background: #000 !important;
}

/* Brand styling for modal (scoped) - only apply when inline styles are not present */
.woowall-modal.woowall-style-brand {
    /* allow the modal-specific stylesheet to define the main gradient/background */
    background: inherit;
    color: inherit;
}

.woowall-modal.woowall-style-brand h2,
.woowall-modal.woowall-style-brand label span {
    color: #333333;
}

.woowall-modal.woowall-style-brand h2 {
    text-align: center;
}

.woowall-modal.woowall-style-brand input {
    background: #ffffff;
    border: 1px solid #dddddd;
    color: #333333;
}

.woowall-modal.woowall-style-brand input::placeholder {
    color: #999999;
}

.woowall-modal.woowall-style-brand input:focus {
    border-color: #445f00;
    box-shadow: 0 0 0 2px rgba(68, 95, 0, 0.1);
}

/* Only apply brand button styles when no inline style is present */
.woowall-modal.woowall-style-brand .woowall-submit-button:not([style*="background"]) {
    background: #445f00;
    border: none;
}

.woowall-modal.woowall-style-brand .woowall-submit-button:not([style*="color"]) {
    color: #9fe000;
}

.woowall-modal.woowall-style-brand .woowall-submit-button:hover:not([style*="background"]) {
    background: #334000;
}

.woowall-modal.woowall-style-brand .woowall-submit-button:hover:not([style*="color"]) {
    color: #9fe000;
}

/* Logo styling */
.woowall-modal-logo {
    margin-bottom: 1.5em;
    text-align: center;
}

.woowall-modal-logo img {
    max-width: 180px !important;
    max-height: 80px;
    height: auto;
}

/* Prevent scrolling when modal is open */
body.woowall-modal-open {
    overflow: hidden;
    padding-right: var(--woowall-scrollbar-width, 0px);
}

/* Mobile Styles */
@media (max-width: 480px) {
    .woowall-modal {
        padding: 1.5em;
    }

    .woowall-modal h2 {
        font-size: 1.2em;
    }

    .woowall-access-form {
        gap: 1em;
    }

    .woowall-submit-button {
        padding: 0.875em 1.25em;
    }
}

/* Animations */
@keyframes woowall-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes woowall-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.woowall-fade-in {
    animation: woowall-fade-in 0.3s ease forwards;
}

.woowall-slide-up {
    animation: woowall-slide-up 0.3s ease forwards;
}

/* Form Validation Styles */
.woowall-access-form input:invalid {
    border-color: #dc3232;
}

.woowall-access-form input:invalid:focus {
    box-shadow: 0 0 0 2px rgba(220,50,50,0.2);
}

.woowall-access-form input:valid {
    border-color: #46b450;
}

.woowall-access-form input:valid:focus {
    box-shadow: 0 0 0 2px rgba(70,180,80,0.2);
}

/* Loading State */
.woowall-submit-button[disabled] {
    position: relative;
}

.woowall-submit-button[disabled]::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.1);
    animation: woowall-loading-pulse 1s ease infinite;
}

@keyframes woowall-loading-pulse {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* Unlocked State */
.woowall-wrapper.woowall-unlocked {
    filter: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    user-select: auto !important;
    max-height: none !important;
    overflow: visible !important;
    transition: all 0.3s ease !important;
}

.woowall-wrapper.woowall-unlocked::after {
    display: none !important;
}

.woowall-wrapper.woowall-unlocked-animate {
    animation: woowall-fade-in 0.7s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes woowall-fade-in {
    from { opacity: 0.3; filter: blur(5px); }
    to { opacity: 1; filter: none; }
}


/* Apply blur to content inside protected containers, but exclude controls */
.woowall-wrapper.woowall-protected .woowall-content-preview,
.woowall-wrapper.woowall-protected .wp-block-woowall-content-protection,
.elementor-element.woowall-protected > .e-con-inner,
.elementor-section.woowall-protected > .e-con-inner,
.elementor-container.woowall-protected > .e-con-inner,
.e-con.woowall-protected > .e-con-inner {
    filter: blur(3px) !important;
    opacity: 0.6 !important;
    transition: all 0.3s ease !important;
}

/* Remove preview effects when content preview is disabled - show clean button only */
.woowall-wrapper.woowall-no-preview .woowall-content-preview,
.woowall-wrapper.woowall-no-preview .wp-block-woowall-content-protection,
.woowall-no-preview.elementor-element > .e-con-inner,
.woowall-no-preview.elementor-section > .e-con-inner,
.woowall-no-preview.elementor-container > .e-con-inner,
.woowall-no-preview.e-con > .e-con-inner {
    opacity: 0 !important;
    filter: none !important;
    pointer-events: none !important;
}

/* Unlocked State */
.woowall-unlocked,
.woowall-unlocked-animate {
    filter: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    user-select: auto !important;
    max-height: none !important;
    overflow: visible !important;
    transition: all 0.3s ease !important;
    z-index: auto !important;
}
.woowall-unlocked::after,
.woowall-unlocked-animate::after {
    display: none !important;
}

/* Gutenberg Block Modal Fix - Ensure modals from Gutenberg blocks display correctly */
div[id*="woowall-gutenberg-"][id$="-modal"].woowall-modal-overlay {
    position: fixed !important;
    z-index: 2147483647 !important;
}