/* 
 * MapPress Extension Custom Filter Styles - Proxy UI Version
 */

/* 1. Hide the Original MapPress Filter UI entirely on load to prevent FOUC */
.mapp-filter-values .mapp-control-checkboxes {
    display: none !important;
}

/* Fallback: if our script fails for some reason or JS is disabled, maybe show them? 
   But since we require JS, it's safer to always hide them. */
.mappress-hidden-native-filter {
    display: none !important;
}

/* 2. Proxy Container & Reset */
.mappress-extension-filter-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 0 20px 0 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.mappress-extension-filter-list ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.mappress-extension-filter-list li {
    margin: 0 !important;
    padding: 0 !important;
    position: relative;
    border: none !important;
    background: transparent !important;
}

/* 3. General Label Styling */
.mappress-extension-filter-list .proxy-label {
    display: flex !important;
    align-items: center;
    padding: 10px 14px;
    margin: 4px 0;
    cursor: pointer;
    background-color: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px; /* Modern Pill/Rounded look */
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
    color: #334155;
    position: relative;
}

.mappress-extension-filter-list .proxy-label:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.mappress-extension-filter-list .proxy-text {
    flex-grow: 1;
}

/* 4. Native Icon styling */
.mappress-extension-filter-list img.mappress-ext-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    object-fit: contain;
    border-radius: 50%; /* Make icons circular if they aren't */
}

/* 5. Custom Status Circles (Checkboxes) */
/* We add a circle indicator to every label */
.mappress-extension-filter-list .proxy-label::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-right: 12px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background-color: #fff;
    transition: all 0.2s ease;
    box-sizing: border-box;
    position: relative;
}

/* State: Checked (Fully Selected) */
.mappress-extension-filter-list li.proxy-checked > .proxy-label {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.mappress-extension-filter-list li.proxy-checked > .proxy-label::before {
    border-color: #2563eb;
    background-color: #2563eb;
    /* Checkmark icon using CSS background */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

/* State: Partial Selection (Main category has some, but not all subcategories selected) */
.mappress-extension-filter-list li.main-category.proxy-has-selected-sub > .proxy-label {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    border-style: dashed; /* Dashed border to indicate partial state */
}

.mappress-extension-filter-list li.main-category.proxy-has-selected-sub > .proxy-label::before {
    border-color: #64748b;
    background-color: #fff;
    /* Minus/Dash icon using CSS background */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");
    background-size: 10px;
    background-position: center;
    background-repeat: no-repeat;
}

/* 6. Sub-categories Container */
.mappress-extension-filter-list .sub-menu {
    margin-left: 20px !important;
    padding-left: 15px !important;
    border-left: 2px solid #e2e8f0;
    margin-top: 4px;
    margin-bottom: 8px;
    display: none; /* Controlled by JS inline style usually, but fallback */
}

/* 7. Sub-category Item Adjustments */
.mappress-extension-filter-list li.sub-category > .proxy-label {
    padding: 8px 12px;
    background-color: transparent;
    border-color: transparent;
    border-radius: 6px;
    font-size: 0.9em;
    color: #475569;
}

.mappress-extension-filter-list li.sub-category > .proxy-label:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

.mappress-extension-filter-list li.sub-category.proxy-checked > .proxy-label {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* 8. Accordion Toggle Button */
.mappress-extension-filter-list .toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-left: 8px;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.05);
    transition: transform 0.3s ease, background-color 0.2s;
}

.mappress-extension-filter-list .toggle:hover {
    background-color: rgba(0,0,0,0.1);
}

.mappress-extension-filter-list .toggle::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg);
    margin-top: -4px;
    transition: transform 0.3s ease;
}

.mappress-extension-filter-list li.proxy-open > .proxy-label .toggle::after {
    transform: rotate(225deg); /* Flip arrow up */
    margin-top: 4px;
}


/* ========================================= */
/* Popup / Modal Styling                     */
/* ========================================= */

.mappress-ext-hidden {
    display: none !important;
}

/* Overlay background */
#mappress-ext-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999998; /* Below popup, above MapPress */
    backdrop-filter: blur(3px);
}

/* The Popup Box */
#mappress-ext-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header containing the Close Button */
.mappress-ext-popup-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 16px;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

#mappress-ext-popup-close {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#mappress-ext-popup-close:hover {
    background: #dc2626;
}

/* Content Area */
.mappress-ext-popup-content {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    color: #334155;
}

/* Make images inside responsive */
.mappress-ext-popup-content img {
    max-width: 100%;
    height: auto;
}

/* Preloader / Spinner Container */
.mappress-ext-preloader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* If standard WP spinner is unavailable, we fallback to CSS spinner */
.mappress-ext-preloader .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: mapp-ext-spin 1s linear infinite;
    display: block;
    float: none;
    margin: 0;
    opacity: 1;
    visibility: visible;
}

@keyframes mapp-ext-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Override MapPress Native Info Window Close Button purely visually (Optional enhancement) */
.mapp-iw-close {
    opacity: 0.7;
    transition: opacity 0.2s;
    /* Move the native close button to the top left as requested by user */
    left: 10px !important;
    right: auto !important;
}
.mapp-iw-close:hover {
    opacity: 1;
}

/* Custom injected close button for the Mashup popup (.mapp-ib-wrapper) */
.mapp-ib-wrapper {
    position: relative; /* ensure button anchors here */
}
.mappress-ext-ib-close {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: background 0.2s ease;
}
.mappress-ext-ib-close:hover {
    background: rgba(0,0,0,0.8);
}
