/* --- Custom Google Maps Customer Locator --- */

/* Override any theme purple styling and WordPress block styles */
.wp-block-post-content .cgm-customer-locator,
.entry-content .cgm-customer-locator,
.post-content .cgm-customer-locator,
.wp-block-group .cgm-customer-locator,
.has-background .cgm-customer-locator {
    border: none !important;
    background: #fff !important;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07) !important;
    color: #333 !important;
}

/* Override all WordPress button and input styles specifically */
.cgm-customer-locator .wp-element-button,
.cgm-customer-locator .wp-block-button__link {
    background: #f5f5f5 !important;
    border: 1px solid #d1d5db !important;
    color: #333 !important;
}

/* Reset WordPress theme button and input styles */
.cgm-customer-locator *,
.cgm-customer-locator *::before,
.cgm-customer-locator *::after {
    box-sizing: border-box;
}

.cgm-customer-locator input,
.cgm-customer-locator button,
.cgm-customer-locator select {
    color: inherit !important;
    background: white !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    font-family: inherit !important;
}

.cgm-customer-locator {
    max-width: 900px;
    margin: 30px auto;
    background: #fff !important;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
    padding: 24px 20px 32px 20px;
    font-family: 'Segoe UI', Arial, sans-serif;
    border: none !important;
    outline: none !important;
}

.cgm-search-container {
    display: flex !important;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
    background: #f9f9f9 !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    padding: 15px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
}

.cgm-search-container input[type="text"],
.cgm-search-container gmp-place-autocomplete {
    flex: 1 1 220px;
    padding: 8px 12px;
    border: 1px solid #d1d5db !important;
    border-radius: 6px;
    font-size: 16px;
    background: white !important;
    transition: border-color 0.2s ease;
    color: #333 !important;
    box-shadow: none !important;
    outline: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 40px !important;
}

/* Ensure search input is always visible */
.cgm-search-container input[name="cgm_search_address"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

.cgm-search-container input[type="text"]:focus,
.cgm-search-container gmp-place-autocomplete:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px rgba(0, 115, 170, 0.2);
}

.cgm-search-container button.cgm-use-geolocation {
    background: #f5f5f5;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cgm-search-container button.cgm-use-geolocation:hover {
    background: #e0e7ef;
    transform: scale(1.05);
}

.cgm-search-container button.cgm-use-geolocation:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cgm-search-container button.cgm-use-geolocation:active {
    transform: scale(0.95);
}

.cgm-filters {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cgm-filters select {
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 15px;
}

.cgm-results-count {
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Loading indicator */
.cgm-loading-bar {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    position: relative;
    overflow: hidden;
}

.cgm-loading-progress {
    height: 4px;
    background: linear-gradient(90deg, #007bff, #0056b3, #007bff);
    background-size: 200% 100%;
    border-radius: 2px;
    margin-bottom: 10px;
    animation: cgm-loading-animation 2s ease-in-out infinite;
}

.cgm-loading-text {
    font-size: 14px;
    color: #6c757d;
    text-align: center;
    font-weight: 500;
}

@keyframes cgm-loading-animation {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Loading states */
.cgm-loading-bar.searching .cgm-loading-text::after {
    content: '...';
    animation: cgm-dots 1.5s infinite;
}

.cgm-loading-bar.geocoding .cgm-loading-progress {
    background: linear-gradient(90deg, #28a745, #20c997, #28a745);
    background-size: 200% 100%;
}

.cgm-loading-bar.fallback .cgm-loading-progress {
    background: linear-gradient(90deg, #ffc107, #fd7e14, #ffc107);
    background-size: 200% 100%;
}

@keyframes cgm-dots {

    0%,
    20% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    80%,
    100% {
        opacity: 0;
    }
}

.cgm-map-container {
    margin-bottom: 18px;
}

#cgm-map {
    flex: 2 1 60%;
    min-width: 300px;
    max-width: 100%;
    min-height: 350px;
    height: 40vh;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 18px;
}

@media (max-width: 600px) {
    #cgm-map {
        min-height: 250px;
        height: 35vh;
    }

    .cgm-customer-locator {
        padding: 10px 2vw 18px 2vw;
    }
}

.cgm-customer-list {
    flex: 1 1 320px;
    min-width: 250px;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 0 0 0 0;
    gap: 0;
}

.cgm-customer-item {
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    padding: 16px 18px;
    transition: box-shadow 0.2s, border 0.2s;
    cursor: pointer;
}

.cgm-customer-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    border-color: #b6d4fe;
}

.cgm-customer-item h3 {
    margin: 0 0 6px 0;
    font-size: 18px;
    color: #1a202c;
    font-weight: 600;
}

.cgm-customer-item p {
    margin: 2px 0 0 0;
    font-size: 15px;
    color: #374151;
}

.cgm-display-tags {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.cgm-display-tag,
.cgm-display-badge {
    display: inline-block;
    background: #e0e7ef;
    color: #1a202c;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 13px;
    margin-right: 4px;
    margin-bottom: 2px;
}

.cgm-customer-item h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.cgm-customer-item p {
    margin: 4px 0;
    line-height: 1.4;
    font-size: 14px;
}

.cgm-customer-item p strong {
    color: #555;
    font-weight: 600;
    margin-right: 4px;
}

.cgm-customer-item:last-child {
    margin-bottom: 0;
}

/* Progress bar styling (admin) */
.progress-bar {
    background: #f0f0f0;
    border-radius: 3px;
    height: 20px;
    margin: 10px 0;
    width: 100%;
}

.progress {
    background: #0073aa;
    border-radius: 3px;
    height: 100%;
    width: 0%;
    transition: width 0.3s;
}

.cgm-customer-locator-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.cgm-map-list-container {
    display: flex;
    gap: 24px;
}

.cgm-info-window {
    padding: 10px;
}

.cgm-info-window h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.cgm-info-window p {
    margin: 5px 0;
    color: #666;
    font-size: 0.9em;
}

@media (max-width: 900px) {
    .cgm-map-list-container {
        flex-direction: column;
    }

    #cgm-map,
    .cgm-customer-list {
        min-width: 100%;
        max-width: 100%;
    }

    .cgm-customer-list {
        max-height: 250px;
    }
}

.cgm-display-badge {
    display: inline-block;
    background: #fff !important;
    color: #111 !important;
    border: 1px solid #007bff;
    border-radius: 12px;
    padding: 2px 10px;
    margin: 0 4px 4px 0;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.03em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cgm-map-white-controls .gm-control,
.cgm-map-white-controls .gm-control-active,
.cgm-map-white-controls .gm-fullscreen-control,
.cgm-map-white-controls .gm-svpc,
.cgm-map-white-controls .gm-style-mtc,
.cgm-map-white-controls .gm-bundled-control,
.cgm-map-white-controls .gm-bundled-control-on-bottom,
.cgm-map-white-controls .gm-control>div,
.cgm-map-white-controls .gm-control>button,
.cgm-map-white-controls .gm-control>span,
.cgm-map-white-controls .gm-control * {
    background: #fff !important;
    color: #111 !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
}

.cgm-map-white-controls .gm-control-active:hover,
.cgm-map-white-controls .gm-control:hover {
    background: #fff !important;
    color: #111 !important;
}

.cgm-map-white-controls .gm-control span,
.cgm-map-white-controls .gm-control button,
.cgm-map-white-controls .gm-fullscreen-control,
.cgm-map-white-controls .gm-svpc,
.cgm-map-white-controls .gm-style-mtc button,
.cgm-map-white-controls .gm-control * {
    color: #111 !important;
    fill: #fff !important;
    filter: invert(1) brightness(100) grayscale(1) !important;
    text-shadow: none !important;
}

.cgm-map-white-controls .gm-style-mtc button {
    color: #111 !important;
    background: #fff !important;
    border: none !important;
}

.cgm-map-white-controls .gm-style-mtc button[aria-pressed="true"] {
    background: #e0e0e0 !important;
}

.cgm-map-white-controls .gm-control>div>div>svg,
.cgm-map-white-controls .gm-control>button>svg,
.cgm-map-white-controls .gm-control>span>svg,
.cgm-map-white-controls .gm-control * svg {
    filter: invert(1) brightness(100) grayscale(1) !important;
}

/* Elementor fix - scoped to CGM only */
.cgm-customer-locator .elementor-kit-5 button,
.elementor-kit-5 .cgm-customer-locator button {
    background: #fff !important;
}

/* Select2 styling - scoped to CGM container only */
.cgm-customer-locator .cgm-display-type-select,
.cgm-customer-locator .select2-container {
    width: 160px !important;
    min-width: 100px !important;
    max-width: 180px !important;
}

/* Select2 dropdown - only when related to CGM (compatible approach) */
.cgm-customer-locator+.select2-dropdown,
.select2-dropdown[data-cgm="true"],
.select2-dropdown.cgm-select2-dropdown {
    width: 160px !important;
    min-width: 100px !important;
    max-width: 180px !important;
}

.cgm-customer-locator .select2-container--default .select2-selection--multiple .select2-selection__choice,
.select2-dropdown[data-cgm="true"] .select2-selection__choice,
.select2-dropdown.cgm-select2-dropdown .select2-selection__choice {
    background: #e0e7ef !important;
    color: #1a202c !important;
    border-radius: 6px !important;
    border: 1px solid #d1d5db !important;
    font-size: 14px !important;
    padding: 2px 8px !important;
    margin: 2px 4px 2px 0 !important;
    min-height: 22px !important;
    display: flex !important;
    align-items: center !important;
    height: 26px !important;
}

.cgm-customer-locator .select2-container--default .select2-selection--multiple .select2-selection__choice__remove,
.select2-dropdown[data-cgm="true"] .select2-selection__choice__remove,
.select2-dropdown.cgm-select2-dropdown .select2-selection__choice__remove {
    color: #888 !important;
    font-size: 16px !important;
    margin-right: 2px !important;
    margin-left: 0 !important;
    line-height: 1 !important;
    padding: 0 !important;