/**
 * Consent Mode Manager - Modern consent popup styles
 * Version: 2.0.7
 */

/* CSS Variables - Dark mode by default (following user design preferences) */
.ecmm-consent-popup {
    --ecmm-popup-bg-color: rgba(30, 30, 30, 0.5);
    /* 50% opacity background per user preference */
    --ecmm-popup-bdrs: 15px;
    /* border radius - shortened to avoid WP core CSS attribute selectors */
    --ecmm-popup-text-color: #ffffff;
    /* White text for dark mode */
    --ecmm-popup-link-color: #4da6ff;
    /* Blue links */
    --ecmm-popup-button-bg-color: #4da6ff;
    /* Blue buttons */
    --ecmm-popup-button-text-color: #ffffff;
    /* White button text */
    --ecmm-popup-btn-bdrs: 8px;
    /* Button border radius */
    --ecmm-popup-button-hover-color: #2a80d2;
    /* Button hover color */
    --ecmm-popup-toggle-active-color: #4da6ff;
    /* Toggle active color */
    --ecmm-transition-duration: 0.3s;
    /* 0.3s transitions per user preference */
    --ecmm-backdrop-blur: 5px;
    /* Blur amount for background */
}

/* =============== BLUR EFFECT FOR BACKGROUND =============== */

/* Apply blur effect to background when popup is visible */
.ecmm-blurred-background {
    filter: blur(var(--ecmm-backdrop-blur));
    transition: filter var(--ecmm-transition-duration) ease;
}

body.ecmm-popup-active .ecmm-blurred-background {
    filter: blur(var(--ecmm-backdrop-blur));
}

/* =============== BASE POPUP STYLES =============== */

/* Main popup container - base styles for all modes */
.ecmm-consent-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    width: 600px;
    /* Consistent width */
    max-width: 95%;
    margin: 0 auto;
    border-radius: 15px 15px 0 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--ecmm-popup-text-color);
    text-align: left;
    overflow: hidden;
    background-color: transparent;
    transform: translateY(100%);
    /* Initially hidden off-screen below */
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    /* Smooth spring-like easing */
    /* Defensive: prevent WP core or theme CSS from adding borders */
    border: none !important;
    border-style: none !important;
    border-width: 0 !important;
    outline: none !important;
}

/* =============== POPUP STATES =============== */

/* Active popup (shown) */
.ecmm-consent-popup.ecmm-active {
    transform: translateY(0);
}

/* Main container that holds all content */
.ecmm-consent-popup-container {
    width: 100%;
    background-color: transparent !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}

/* Fixed top section (shown in all modes) - this has the blur background effect */
.ecmm-consent-popup-fixed-section {
    width: 100%;
    background-color: var(--ecmm-popup-bg-color) !important;
    backdrop-filter: blur(10px) !important;
    /* Blur effect per user preference */
    -webkit-backdrop-filter: blur(10px) !important;
    border-radius: 15px 15px 0 0;
    /* Border radius per user preference */
}

/* Content section with flex layout for description and toggle */
.ecmm-consent-popup-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px;
    gap: 10px;
}

/* Description text */
.ecmm-consent-popup-description {
    flex: 1;
    margin: 0;
    padding: 0 15px 0 0;
    font-size: 14px;
    line-height: 1.4;
}

.ecmm-consent-popup-description p {
    margin: 0;
    padding: 0 15px 0 0;
}

/* Privacy policy link */
.ecmm-consent-popup-privacy-link {
    color: var(--ecmm-popup-link-color) !important;
    text-decoration: underline;
    transition: color var(--ecmm-transition-duration) ease;
}

.ecmm-consent-popup-privacy-link:hover,
.ecmm-consent-popup-privacy-link:focus {
    color: #ffffff !important;
    text-decoration: underline;
}

/* Header is now hidden in all modes via a global rule */

/* =============== TOGGLE SWITCH =============== */

/* Toggle switch container */
.ecmm-toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    margin: 0;
    flex-shrink: 0;
}

/* Hide the actual checkbox */
.ecmm-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Toggle slider (background) */
.ecmm-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444444;
    border-radius: 22px;
    transition: background-color var(--ecmm-transition-duration) ease;
}

/* Toggle slider knob */
.ecmm-toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--ecmm-transition-duration) ease;
}

/* Toggle active state */
.ecmm-toggle-switch input:checked+.ecmm-toggle-slider {
    background-color: var(--ecmm-popup-toggle-active-color);
}

.ecmm-toggle-switch input:checked+.ecmm-toggle-slider:before {
    transform: translateX(18px);
}

/* =============== CONSENT OPTIONS SECTION =============== */

/* Expandable section for options */
.ecmm-consent-popup-expandable-section {
    width: 100%;
    background-color: transparent !important;
    display: none;
    /* Hidden by default, controlled via jQuery slideDown/slideUp for smooth animation */
    overflow: hidden;
}

/* Consent options container */
.ecmm-consent-options {
    padding: 15px;
    background-color: var(--ecmm-popup-bg-color) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hide options in minimized mode */
.ecmm-consent-popup-minimized .ecmm-consent-popup-expandable-section {
    display: none !important;
}

/* Show options in expanded and fullscreen modes */
.ecmm-consent-popup-expanded .ecmm-consent-popup-expandable-section,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-expandable-section {
    display: block !important;
}

/* Individual option item */
.ecmm-consent-option-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ecmm-consent-option-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Option header with title and toggle */
.ecmm-consent-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* Option title */
.ecmm-consent-option-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

/* Option description */
.ecmm-consent-option-description {
    font-size: 13px;
    margin: 0;
    opacity: 0.8;
}

/* =============== FOOTER AND BUTTONS =============== */

/* Footer container */
.ecmm-consent-popup-footer {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background-color: var(--ecmm-popup-bg-color) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Minimized mode footer needs no top border and less padding */
.ecmm-consent-popup-minimized .ecmm-consent-popup-footer {
    padding: 15px;

    background-color: var(--ecmm-popup-bg-color) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Buttons container */
.ecmm-consent-popup-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Base button styles */
.ecmm-consent-popup-button {
    display: inline-block !important;
    padding: 10px 15px !important;
    border-radius: var(--ecmm-popup-btn-bdrs) !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-align: center !important;
    white-space: nowrap !important;
    background-color: #2a2a2a !important;
    color: var(--ecmm-popup-text-color) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    min-width: 140px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    transition: background-color var(--ecmm-transition-duration) ease !important;
}

/* Accept button (primary) */
.ecmm-consent-popup-button-accept {
    background-color: var(--ecmm-popup-button-bg-color) !important;
    color: var(--ecmm-popup-button-text-color) !important;
}

/* Button hover states */
.ecmm-consent-popup-button:hover {
    opacity: 0.9 !important;
}

.ecmm-consent-popup-button-accept:hover {
    background-color: var(--ecmm-popup-button-hover-color) !important;
}

/* Hide only save button in minimized mode - keep deny button visible */
.ecmm-consent-popup-minimized .ecmm-consent-popup-button-save {
    display: none !important;
}

/* Show all buttons in expanded and fullscreen modes */
.ecmm-consent-popup-expanded .ecmm-consent-popup-button-deny,
.ecmm-consent-popup-expanded .ecmm-consent-popup-button-save,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-button-deny,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-button-save {
    display: inline-block !important;
}

/* =============== DISPLAY MODES =============== */

/* 1. MINIMIZED MODE */
.ecmm-consent-popup-minimized {
    /* No additional height in minimized mode */
    height: auto;
    max-height: 300px;
}

/* 2. EXPANDED MODE */
.ecmm-consent-popup-expanded {
    /* Same height as minimized, expanded only shows more content below */
    height: auto;
}

/* Separate fullscreen overlay element */
.ecmm-consent-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    /* Just below the popup */
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: background-color var(--ecmm-transition-duration) ease, backdrop-filter 0.3s ease;
    /* Always visible when popup is visible */
    display: none;
    pointer-events: auto;
}

/* Extra: blur class for background elements when overlay is active */
.ecmm-backdrop-blur {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    background-color: rgba(30, 30, 30, 0.5) !important;
    /* 50% opacity */
    transition: backdrop-filter 0.3s ease, background-color 0.3s ease;
}

/* Pulsating animation for overlay */
.ecmm-consent-overlay.pulsating {
    animation: ecmmPulsateOverlay 2s infinite;
}

/* Ensure popup doesn't change size in overlay mode */
.ecmm-consent-popup-overlay {
    /* Keep the same width and position */
    width: 600px;
    max-width: 95%;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    border-radius: 15px 15px 0 0;
}

/* Show overlay when popup is visible */
body:has(.ecmm-consent-popup-visible) .ecmm-consent-overlay {
    display: block;
    pointer-events: auto;
}

/* Accessibility: ensure overlay disables interaction with background */
body.ecmm-has-consent-popup>*:not(.ecmm-consent-popup):not(.ecmm-consent-overlay) {
    pointer-events: none !important;
}

/* Fallback for browsers without :has support */
.ecmm-consent-popup-visible~.ecmm-consent-overlay {
    display: block;
}

/* Only add pulsating effect when in overlay mode */
body:has(.ecmm-consent-popup-overlay) .ecmm-consent-overlay.pulsating {
    animation: ecmmPulsateOverlay 2s infinite;
}

/* 3. OVERLAY MODE - separate from popup */

/* Active popup (shown) */
.ecmm-consent-popup.ecmm-active {
    transform: translateY(0);
}

/* Fix any potential alignment issues in all modes */
.ecmm-consent-popup-minimized .ecmm-consent-popup-content,
.ecmm-consent-popup-expanded .ecmm-consent-popup-content,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-content {
    /* Ensure consistent padding and alignment in all modes */
    padding: 15px 15px 0 15px;
    align-items: center;
}

/* Ensure buttons have consistent appearance */
.ecmm-consent-popup-minimized .ecmm-consent-popup-button,
.ecmm-consent-popup-expanded .ecmm-consent-popup-button,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-button {
    /* Same button size and appearance in all modes */
    padding: 10px 15px !important;
    margin: 0 !important;
}

/* Ensure consistent padding in footer across modes */
.ecmm-consent-popup-expanded .ecmm-consent-popup-footer,
.ecmm-consent-popup-fullscreen .ecmm-consent-popup-footer {
    padding: 15px;

    background-color: var(--ecmm-popup-bg-color) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* Animation for showing the popup */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ecmm-consent-popup.ecmm-active {
    animation: fadeIn 0.3s ease forwards;
}

/* =============== RESPONSIVE STYLES =============== */

/* Adjust for smaller screens */
@media (max-width: 640px) {
    .ecmm-consent-popup {
        width: 100%;
        max-width: 100%;
        border-radius: 15px 15px 0 0;
    }

    .ecmm-consent-popup-content {
        padding: 15px;
    }

    .ecmm-consent-popup-description {
        font-size: 13px;
    }

    .ecmm-consent-popup-button {
        min-width: 120px !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
}

/* Stack buttons on very small screens */
@media (max-width: 480px) {
    .ecmm-consent-popup-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .ecmm-consent-popup-button {
        width: 100%;
    }
}

/* =============== UTILITY CLASSES =============== */

/* Hidden state */
.ecmm-hidden {
    display: none !important;
}

/* Backdrop blur effect - consistent with user preferences */
.ecmm-backdrop-blur {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    background-color: rgba(30, 30, 30, 0.5) !important;
    /* 50% opacity */
}

/* Primary button color */
.ecmm-primary-color {
    background-color: var(--ecmm-popup-button-bg-color) !important;
    color: var(--ecmm-popup-button-text-color) !important;
}

/* Animation utilities */
.ecmm-fade-in {
    opacity: 0;
    transition: opacity var(--ecmm-transition-duration) ease;
}

.ecmm-fade-in.ecmm-active {
    opacity: 1;
}

/* Add background overlay when popup is visible */
.ecmm-overlay::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9990;
}

/* Show popup */
.ecmm-consent-popup.ecmm-consent-popup-visible {
    transform: translateY(0);
}

/* Customize consent span */
#customize-consent {
    text-decoration: underline;
    cursor: pointer;
    color: var(--ecmm-popup-link-color);
    transition: all var(--ecmm-transition-duration) ease;
}

#customize-consent:hover {
    color: var(--ecmm-popup-button-hover-color);
}

/* Popup header - hidden in all modes */
.ecmm-consent-popup-header {
    display: none !important;
}

/* Popup title */
.ecmm-consent-popup-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

/* Popup content */
.ecmm-consent-popup-content {
    padding: 20px 25px;
    max-height: 60vh;
    overflow-y: auto;
    transition: all var(--ecmm-transition-duration) ease;

}

/* Centered content for fullscreen mode */
.ecmm-consent-popup-content.centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

/* Information message container - consistent across all modes */
.ecmm-consent-popup-info {
    flex: 1;
    margin-bottom: 0;
}

/* Popup description */
.ecmm-consent-popup-description {
    margin-top: 0;
    margin-bottom: 15px;
    line-height: 1.5;
}



/* Consent option item */
.ecmm-consent-option-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ecmm-consent-option-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Consent option header */
.ecmm-consent-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* Consent option title */
.ecmm-consent-option-title {
    margin: 0;
    font-size: 14px !important;
    font-weight: 600;
}

/* Consent option description */
.ecmm-consent-option-description {
    margin: 0;
    font-size: 12px !important;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
}

/* Toggle switch for consent options - different color than main toggle */
.ecmm-consent-option-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.ecmm-consent-option-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ecmm-consent-option-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: var(--ecmm-transition-duration) ease;
    border-radius: 20px;
}

.ecmm-consent-option-toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--ecmm-transition-duration) ease;
    border-radius: 50%;
}

.ecmm-consent-option-toggle input:checked+.ecmm-consent-option-toggle-slider {
    background-color: #6ac27a;
    /* Different color than main toggle */
}

.ecmm-consent-option-toggle input:focus+.ecmm-consent-option-toggle-slider {
    box-shadow: 0 0 1px var(--ecmm-popup-toggle-active-color);
}

.ecmm-consent-option-toggle input:checked+.ecmm-consent-option-toggle-slider:before {
    transform: translateX(16px);
}

.ecmm-consent-option-toggle input:disabled+.ecmm-consent-option-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Popup footer */
.ecmm-consent-popup-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    /* Align buttons to the right */
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background-color: transparent !important;


}

/* Centered footer for fullscreen mode */
.ecmm-consent-popup-footer.centered {
    justify-content: center;
    border-top: none;
}

/* Privacy policy link - integrated within description */
.ecmm-consent-popup-privacy-link {
    color: var(--ecmm-popup-link-color) !important;
    text-decoration: underline !important;
    transition: color 0.3s ease !important;
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
}

.ecmm-consent-popup-privacy-link:hover,
.ecmm-consent-popup-privacy-link:focus {
    color: #ffffff !important;
    text-decoration: underline !important;
}

/* Buttons container */
.ecmm-consent-popup-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Button container in minimized mode - identical to expanded mode */
.ecmm-consent-popup-minimized .ecmm-consent-popup-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Buttons - with !important to override theme styles */
.ecmm-consent-popup-button {
    display: inline-block !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background-color 0.3s ease !important;
    /* Only transition background color */
    font-size: 14px !important;
    font-weight: 600 !important;
    text-align: center !important;
    white-space: nowrap !important;
    margin: 0 !important;
    /* Remove bottom margin */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    background-color: #2a2a2a !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    min-width: 140px !important;
}

/* No custom styling for minimized mode buttons - use the same as expanded mode */

/* Normal button style */
.ecmm-consent-popup-button-deny,
.ecmm-consent-popup-button-save {
    background-color: #2a2a2a !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Highlighted button style - for recommended action */
.ecmm-consent-popup-button-accept {
    background-color: #4da6ff !important;
    color: #ffffff !important;
    border: 1px solid rgba(42, 128, 210, 0.5) !important;
    box-shadow: 0 2px 8px rgba(77, 166, 255, 0.3) !important;
}

.ecmm-consent-popup-button-deny:hover,
.ecmm-consent-popup-button-save:hover,
.ecmm-consent-popup-button-deny:focus,
.ecmm-consent-popup-button-save:focus {
    background-color: #3a3a3a !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
}

.ecmm-consent-popup-button-accept:hover,
.ecmm-consent-popup-button-accept:focus {
    background-color: #2a80d2 !important;
    border-color: rgba(42, 128, 210, 0.7) !important;
    transition: all var(--ecmm-transition-duration) ease !important;
}

.ecmm-consent-popup-button-deny {
    background-color: transparent;
    color: var(--ecmm-popup-text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Responsive styles */
@media screen and (max-width: 768px) {
    .ecmm-consent-popup {
        max-width: 100%;
    }

    .ecmm-consent-popup-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .ecmm-consent-popup-buttons {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: space-between;
    }

    .ecmm-consent-popup-button {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Pulsating animation for overlay */
@keyframes ecmmPulsateOverlay {
    0% {
        background-color: rgba(0, 0, 0, 0.7);
    }

    50% {
        background-color: rgba(0, 0, 0, 0.9);
    }

    100% {
        background-color: rgba(0, 0, 0, 0.7);
    }
}