/**
 * Public-facing styles
 */

.iwm-map-container {
    width: 100%;
    position: relative;
    margin-bottom: 20px;
}

.iwm-filter-container {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.iwm-filters-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.iwm-categories-filter,
.iwm-subcategories-filter {
    flex: 1;
    min-width: 250px;
}

.iwm-dropdown-filter {
    position: relative;
    display: block;
    width: 100%;
}

.iwm-dropdown-button {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: space-between;
    transition: background-color 0.2s ease;
}

.iwm-dropdown-button:hover {
    background: #f5f5f5;
    border-color: #999;
}

.iwm-dropdown-button:focus {
    outline: none;
    border-color: #999;
}

.iwm-dropdown-button.active {
    background: #fff;
    border-color: #999;
    color: #333;
}

.iwm-dropdown-button.active .iwm-dropdown-arrow {
    color: #333;
}

.iwm-dropdown-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.iwm-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    z-index: 1000;
}

.iwm-dropdown-content.iwm-dropdown-open {
    max-height: 300px;
}

.iwm-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.iwm-dropdown-item:last-child {
    border-bottom: none;
}

.iwm-dropdown-item:hover {
    background: #f5f5f5;
}

.iwm-dropdown-item input[type="checkbox"] {
    margin: 0;
}

.iwm-checkbox-text {
    font-size: 14px;
    color: #333;
}

/* Subcategory filter styling */
.iwm-subcategory-group {
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.iwm-subcategory-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.iwm-subcategory-group-header {
    font-weight: 600;
    color: #0066cc;
    padding: 8px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.iwm-subcategory-filter-item {
    padding-left: 25px;
    position: relative;
    font-size: 13px;
}

.iwm-subcategory-filter-item .iwm-checkbox-text {
    font-size: 13px;
    color: #555;
}

.iwm-category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.iwm-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.iwm-filter-checkbox input[type="checkbox"] {
    margin: 0;
}

.iwm-filter-checkbox.active {
    background: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 5px 8px;
    color: #333;
}

.iwm-filter-checkbox.active input[type="checkbox"]:checked {
    accent-color: #333;
}

.iwm-map {
    width: 100%;
    height: 500px; /* Default, can be overridden by shortcode */
    z-index: 10;
}

/* Popup styling */
.iwm-popup {
    min-width: 200px;
    max-width: 300px;
    text-align: left;
}

.iwm-popup h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    text-align: left;
}

.iwm-popup h4 {
    margin: 15px 0 8px 0 !important;
    font-size: 14px !important;
    text-align: left !important;
    color: #333 !important;
    font-weight: bold !important;
}

.iwm-categories {
    margin-top: 10px;
}

.iwm-category-list {
    list-style: none;
    padding: 0 !important;
    margin: 0;
}

.iwm-category-item {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    padding: 6px 10px;
    margin: 4px 0;
    font-size: 13px;
    color: #0066cc;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.iwm-category-item:hover {
    background: #d1e7ff;
    border-color: #80bfff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,102,204,0.2);
}

/* Admin category tags styling */
.iwm-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.iwm-category-tag {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 12px;
    color: #0066cc;
    white-space: nowrap;
}

/* Category with subcategories styling */
.iwm-category-with-subs {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 4px;
    padding: 8px 10px;
    margin: 4px 0;
    font-size: 13px;
    color: #0066cc;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.iwm-category-with-subs:hover {
    background: #d1e7ff;
    border-color: #80bfff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,102,204,0.2);
}

.iwm-category-text {
    flex: 1;
}

.iwm-category-indicator {
    font-size: 10px;
    color: #0066cc;
    transition: transform 0.2s ease;
    font-weight: bold;
    margin-left: 8px;
}

/* Side popup styling */
.iwm-side-popup {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    max-width: 300px;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: absolute;
    z-index: 10002;
}

.iwm-side-popup-visible {
    opacity: 1;
    transform: scale(1);
}

.iwm-side-popup-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 12px 15px;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.iwm-side-popup-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #0066cc;
}

.iwm-side-popup-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.iwm-side-popup-close:hover {
    background: #e9ecef;
    color: #495057;
}

.iwm-side-popup-content {
    padding: 15px;
}

.iwm-side-subcategory-list {
    list-style: none;
    padding: 0 !important;
    padding-left: 0 !important;
    margin: 0;
}

.iwm-side-subcategory-item {
    background: #f0f8ff;
    border: 1px solid #cce6ff;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 6px 0;
    font-size: 13px;
    color: #004d99;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.iwm-side-subcategory-item:hover {
    background: #e6f2ff;
    border-color: #99ccff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,77,153,0.2);
}


/* Make sure popup container allows overflow for side popup */
.leaflet-popup-content {
    position: relative;
    overflow: visible !important;
}

/* Make the leaflet popup content wider and align text left */
.leaflet-popup-content {
    min-width: 200px;
    text-align: left;
}

/* Ensure no padding or margin is affecting alignment */
.leaflet-popup-content * {
    text-align: left !important;
}

/* Override theme styles that affect the popup list */
.entry-content .leaflet-popup-content ul.iwm-category-list,
.entry-content .iwm-popup ul.iwm-category-list,
.iwm-popup ul.iwm-category-list {
    padding: 0 !important;
    margin: 0 !important;
}

/* Tooltip styling */
.iwm-category-item {
    position: relative;
}

.iwm-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    width: 200px;
    max-width: 200px;
    word-wrap: break-word;
    white-space: normal;
    z-index: 10000;
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    left: 100%;
    top: 50%;
    transform: translate(10px, -50%);
}

.iwm-tooltip::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
    border-left: none;
}

.iwm-tooltip-visible {
    opacity: 1;
    transform: translate(15px, -50%);
}

/* Tooltip positioned to the left (when right side doesn't fit) */
.iwm-tooltip.tooltip-left {
    left: auto;
    right: 100%;
    transform: translate(-10px, -50%);
}

.iwm-tooltip.tooltip-left::before {
    left: auto;
    right: -6px;
    border-right: none;
    border-left: 6px solid #333;
    border-top-color: transparent;
    border-bottom-color: transparent;
}

.iwm-tooltip.tooltip-left.iwm-tooltip-visible {
    transform: translate(-15px, -50%);
}

/* Responsive styles */
@media screen and (max-width: 1024px) {
    /* Disable tooltips on mobile and tablet */
    .iwm-tooltip {
        display: none !important;
    }
}

@media screen and (max-width: 767px) {
    .iwm-map {
        height: 400px; /* Smaller on mobile devices */
    }
    
    .iwm-popup {
        max-width: 250px;
    }
    
    .iwm-filters-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .iwm-categories-filter,
    .iwm-subcategories-filter {
        min-width: auto;
    }
    
    .iwm-dropdown-button {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .iwm-dropdown-item {
        padding: 10px 12px;
    }
    
    .iwm-filter-container {
        padding: 10px;
    }
    
    .iwm-tooltip {
        width: 180px;
        max-width: 180px;
        font-size: 11px;
        padding: 6px 10px;
        white-space: normal;
    }
    
    /* Force left positioning on mobile for better visibility */
    .iwm-tooltip {
        left: auto !important;
        right: 100% !important;
        transform: translate(-10px, -50%) !important;
    }
    
    .iwm-tooltip-visible {
        transform: translate(-15px, -50%) !important;
    }
    
    .iwm-category-item,
    .iwm-category-with-subs {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    /* Mobile side popup styling - remove the forced centering */
    .iwm-side-popup {
        min-width: 180px;
        max-width: 250px;
        max-height: 70vh;
        overflow-y: auto;
        /* Remove the forced positioning that was breaking mobile */
    }
    
    .iwm-side-popup-header {
        padding: 10px 12px;
    }
    
    .iwm-side-popup-header h4 {
        font-size: 13px;
    }
    
    .iwm-side-popup-content {
        padding: 12px;
    }
    
    .iwm-side-subcategory-item {
        font-size: 12px;
        padding: 6px 10px;
        margin: 4px 0;
    }
    
    /* On mobile, always position to the right or center if no space - REMOVED */
    
    .iwm-side-popup-visible {
        transform: scale(1);
    }
}
