/**
 * Styles for Entkreis Product Map frontend
 */

/* Map container */
.entkreis-product-map-container {
    position: relative;
    margin-top: 20px;  /* Space from header/previous elements */
    z-index: 1; /* Ensure map stays below header */
    clear: both; /* Prevent floating issues */
}

#entkreis-product-map {
    width: 100%;
    height: 500px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    z-index: 1;
}

/* Search and filter section */
.entkreis-product-map-filters {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f7f7f7;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

.filter-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 10px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.filter-btn {
    padding: 9px 20px;
    background-color: #0078A8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.filter-btn:hover {
    background-color: #005f85;
}

/* Search input group */
.entkreis-product-map-search {
    display: flex;
    flex-wrap: nowrap;
    gap: 15px;
    align-items: flex-end;
    width: 100%;
    box-sizing: border-box;
}

.search-input-wrapper {
    flex: 3;
    display: flex;
    flex-direction: column;
}

.radius-input-wrapper {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
}

.search-btn-wrapper {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 0;
    height: 40px;
}

.entkreis-product-map-search label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    white-space: nowrap;
}

#product-search-address,
#product-search-radius,
#product-search-button,
#product-reset-button {
    height: 40px;
    box-sizing: border-box;
    border-radius: 4px;
    font-size: 14px;
}

.radius-select {
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
}

#product-search-address,
#product-search-radius {
    width: 100%;
    padding: 0 10px;
    border: 1px solid #ddd;
}

#product-search-button,
#product-reset-button {
    padding: 0 15px;
    background-color: #0078A8;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    line-height: 40px;
}

#product-search-button:hover,
#product-reset-button:hover {
    background-color: #005f85;
}

#product-reset-button {
    background-color: #777;
}

#product-reset-button:hover {
    background-color: #555;
}

/* Results count */
#product-map-results {
    margin-bottom: 20px;
    padding: 10px 15px;
    background-color: #e7f5fa;
    border-left: 4px solid #0078A8;
    border-radius: 2px;
    font-weight: bold;
}

/* Product popups */
.product-popup {
    min-width: 250px;
    max-width: 300px;
    font-size: 16px;
}

.product-popup .product-image {
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 4px;
}

.product-popup .product-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #eee;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast; /* Improves image rendering in Chrome */
    image-rendering: crisp-edges; /* Modern browsers */
    transform: translateZ(0); /* Enables hardware acceleration */
}

.product-popup h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 18px;
    color: #333;
    font-weight: bold;
}

.product-popup p {
    margin: 5px 0;
    font-size: 15px;
    line-height: 1.5;
}

.product-popup .product-company {
    color: #005f85;
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dotted #ddd;
    font-size: 15px;
}

.product-popup .product-dates {
    color: #CC0000;
    margin: 10px 0;
    line-height: 1.5;
    font-size: 15px;
}

.product-popup .product-dates ul {
    margin: 5px 0 5px 20px;
    padding: 0;
}

.product-popup .product-dates li {
    margin: 2px 0;
    padding: 0;
    list-style-type: disc;
    font-size: 15px;
}

.product-popup .product-price {
    color: #0078A8;
    font-weight: bold;
    font-size: 15px;
}

.product-popup .product-address {
    color: #666;
    font-size: 15px;
}

.product-popup .product-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 15px;
    background-color: #0078A8;
    color: white !important;
    text-decoration: none;
    border-radius: 3px;
    font-size: 15px;
    transition: background-color 0.2s;
    font-weight: bold;
    border: none;
    text-align: center;
}

.product-popup .product-link:hover {
    background-color: #005f85;
    text-decoration: none;
    color: white !important;
}

/* Search marker */
.search-marker-icon {
    background: none;
}

.search-marker {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #0078A8;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

/* Product list */
#product-map-list {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

.product-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
    background-color: #fff;
}

.product-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.product-item-image {
    height: 180px;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
}

.product-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    image-rendering: -webkit-optimize-contrast; /* Improves image rendering in Chrome */
    image-rendering: crisp-edges; /* Modern browsers */
    transform: translateZ(0); /* Enables hardware acceleration */
    transition: transform 0.3s ease;
}

.product-item-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
    color: #888;
    font-style: italic;
}

.product-item:hover .product-item-image img {
    transform: scale(1.05) translateZ(0); /* Subtle zoom effect on hover */
}

.product-item-info {
    padding: 15px;
}

.product-item-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
}

.product-item-info p {
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.4;
}

.product-item-info .product-price {
    font-weight: bold;
    color: #0078A8;
    font-size: 16px;
}

.product-item-info .product-distance {
    color: #0078A8;
    font-weight: bold;
}

.product-item-info .product-link {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 12px;
    background-color: #26a847;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 14px;
    transition: background-color 0.2s;
}

.product-item-info .product-link:hover {
    background-color: #1e8a3a;
    text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .entkreis-product-map-search {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .search-input-wrapper {
        flex: 100%;
        margin-bottom: 10px;
    }
    
    .radius-input-wrapper,
    .search-btn-wrapper {
        flex: 1 1 auto;
    }
}

@media (max-width: 600px) {
    #entkreis-product-map {
        height: 400px;
    }
    
    .entkreis-product-map-search {
        flex-direction: column;
        gap: 10px;
    }
    
    .search-input-wrapper,
    .radius-input-wrapper,
    .search-btn-wrapper {
        flex: 100%;
        width: 100%;
    }
    
    .search-btn-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    #product-map-list {
        grid-template-columns: 1fr;
    }
}

/* Marker cluster customization */
.marker-cluster {
    background-color: rgba(0, 120, 168, 0.6);
}

.marker-cluster div {
    background-color: rgba(0, 120, 168, 0.8);
    color: white;
    font-weight: bold;
}

/* Leaflet control styles */
.leaflet-control-geocoder {
    border: none !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-geocoder input {
    border: none !important;
    border-radius: 4px !important;
    padding: 8px 10px !important;
}

.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
    border: none !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2) !important;
}

/* Loading indicator */
.loading-map {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: 18px;
    color: #666;
    padding: 40px;
    text-align: center;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.loading-map:before {
    content: "";
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    border: 3px solid #ddd;
    border-top: 3px solid #0078A8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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