/* Huoltopistehaku Block Frontend Styles */



.huoltopistehaku-block {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    font-family: inherit;
    position: relative;
}

.map-popup {
    position: relative;
}
.map-popup:hover .popup-title, .map-popup:hover .popup-location{
    color: #8C7D1A}
.map-popup a {
    position: absolute;
    inset:0;
}

.map-popup:focus-visible {
    outline: -webkit-focus-ring-color auto 0px;
}


/* Combined Header and Filters Container */
.huoltopiste-filters-container {
    position: relative;
    width: 100vw;
    margin-bottom: 30px;
    min-height: 150px;
    display: flex;
    align-items: center;
}

.filter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.filters-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.huoltopiste-header {
    text-align: center;
    margin-bottom: 30px;
}

.huoltopiste-title {
    margin: 0 0 10px 0;
    font-weight: 600;
}

.huoltopiste-subtitle {
    margin: 0;
}

.huoltopiste-filters-horizontal {
    width: 100%;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
    justify-content: center;
    max-width: 100%;
    overflow: visible;
    flex-direction: row;
}

.filter-item {
    flex: 1;
  
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
}
.filter-item:has(.location-btn,.clear-all-btn) {
        width: auto !important;
        min-width: unset;
    max-width: unset;
    flex-grow: 0;
    }

.filter-item label {
    display: none;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.filter-input-wrapper::after {
    content: '▼';
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
    pointer-events: none;
    z-index: 2;
}

/* Hide arrow when filter has searchable select */
.filter-input-wrapper:has(.select-container)::after,
.filter-input-wrapper.has-searchable::after {
    display: none;
}

.filter-select {
    flex: 1;
    width: 100%;
padding: .5em 1em;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

input.select-search, .filter-select, .select-dropdown, .select-search {
    font-size: var(--wp--preset--font-size--x-small) !important;

}

.filter-select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
    background: white;
}

.clear-filter-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #dc3545;
    border: none;
    font-size: 12px;
    color: white;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    z-index: 3;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.clear-filter-btn:hover {
    background: #c82333;
    transform: translateY(-50%) scale(1.1);
}

.clear-filter-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.location-btn, .clear-all-btn {
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    margin-top: auto;
    box-sizing: border-box;
    min-height: 42px; /* Match filter select height */
    min-width: 42px; /* Make square for icon */
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-btn {
    background: rgba(255, 255, 255, 0.9);
    color:black;
    border-color: var(--wp--preset--color--primary);
}
.location-btn span{
        display:none;
        padding-left: 5px;
    }

.location-btn:hover {
    background: white;
    border-color: var(--wp--preset--color--primary);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
    opacity: 0.9;
}

.location-btn:disabled {
    background: rgba(255, 255, 255, 0.5);
    color: #999;
    border-color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

.location-btn[data-active="true"] {
    background: #10f27d !important;
    color: black !important;
    border-color: #10f27d !important;
}

.location-btn[data-active="true"]:hover {
    background: #218838 !important;
    border-color: #1e7e34 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.location-btn svg {
    width: 20px;
    height: 20px;
}

.clear-all-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.3);
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

.clear-all-btn:hover {
    background: white;
    color: #dc3545;
    border-color: #dc3545;
}

/* Main Content Area */
.huoltopiste-content {
    display: flex;
    gap: 20px;
    min-height: 600px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.huoltopiste-sidebar {
    flex: 0 0 350px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    padding: 20px;
}

.results-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.results-count {
    font-weight: 500;
    font-size: 14px;
    color: var(--wp--preset--color--main-accent);
}

.results-list {
    max-height: 500px;
    overflow-y: auto;
}

.result-item {
    background: #2f2f2f;
    border: 1px solid #363632;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.result-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--wp--preset--color--primary);
}

.result-item.active {
    border-color: var(--wp--preset--color--primary);
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.2);
}

.result-title {
    font-weight: 600;
    margin: 0 0 5px 0;
    font-size: 13px;
    font-family: inherit;
}
.result-title a{
color: var(--wp--preset--color--primary);
text-decoration: none;
}
.result-title a:hover{
text-decoration: underline;
}

.result-location {
    font-size: 14px;
    color: var(--wp--preset--color--main-accent);
    margin: 0 0 8px 0;
}

.result-distance {
    font-size: 12px;
    color: #10f27d;
    font-weight: 500;
}

.result-services {
    margin-top: 8px;
    display: none;
}

.service-tag {
    display: inline-block;
    background: #f0f8ff;
    color: #007cba;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 4px;
    margin-bottom: 2px;
}

.huoltopiste-map-container {
    flex: 1;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.huoltopiste-map {
    width: 100%;
    height: 100%;
    min-height: 600px;
}

/* Custom select styling for searchable dropdowns */
.select-container {
    position: relative;
    width: 100%;
}

.select-container::after {
    content: '▼';
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
    pointer-events: none;
    z-index: 2;
}

.select-search {
    width: 100%;
    padding: 10px 50px 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    cursor: pointer;
    text-align: left;
}

.select-search:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
    background: white;
}

.select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.select-option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.select-option:hover {
    background: #f5f5f5;
}

.select-option.selected {
    background: #007cba;
    color: white;
}

.select-option:last-child {
    border-bottom: none;
}

/* Responsive design */
@media (max-width: 1024px) {
    .filter-row {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .filter-item {
        min-width: 100%;
        max-width: 100%;
        width: 100%;
        margin-bottom: 10px;
    }
     
    
    
    .filter-input-wrapper {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
        min-width: 0;
    }
    
    .location-btn, .clear-all-btn {
        min-width: 60px;
        min-height: 50px;
        margin-top: 10px;
    }
    
    .huoltopiste-content {
        flex-direction: column;
    }
    
    .huoltopiste-sidebar {
        flex: none;
    }
    
    .huoltopiste-map {
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .filters-content {
        padding: 20px 15px;
    }
    
    .filter-row {
        gap: 15px;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    .filter-item {
        min-width: 100%;
        max-width: 100%;
        width: 100%;
        margin-bottom: 15px;
    }
    
    .filter-input-wrapper {
        width: 100%;
    }
    
    .filter-select {
        width: 100%;
        padding: 12px 50px 12px 15px;
        font-size: 16px; /* Prevent zoom on iOS */
        height: 44px;
    }
    
    .location-btn, .clear-all-btn {
        height: 44px;
        font-size: 16px;
        margin-top: 10px;
    }
    .clear-all-btn {
        width: 100%;
        height: 44px;
        font-size: 16px;
        margin-top: 10px;
    }
    .location-btn {
        width: 200px;
    }
    .location-btn span{
        display:inline-block;
    }
    
    .clear-filter-btn {
        right: 30px;
        width: 22px;
        height: 22px;
    }
    
    .filter-input-wrapper::after,.select-container::after {
        right: 12px !important;
    }
    
    .huoltopiste-content {
        padding: 0;
        gap:0;
    }

     div:has(.huoltopiste-content)
         {
        padding: 0;
    }
    .huoltopiste-sidebar, .huoltopiste-map-container  {
    border-radius: 0;
}
.huoltopiste-filters-container {
margin-bottom: 0;
border-bottom: 1px solid var(--wp--preset--color--primary);
}
   .huoltopiste-sidebar{
border-bottom: 1px solid var(--wp--preset--color--primary);
}
}

/* Mapbox popup customization */
.mapboxgl-popup-content {
    padding: 15px 22px 10px 10px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.popup-title {
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
    font-family: var(--wp--preset--font-family--inter);
    font-size: 12px;
}

.popup-location {
    font-size: 14px;
    color: #666;
    margin: 0 0 8px 0;
}

.popup-services {
    margin-top: 8px;
}

.popup-service-tag {
    display: inline-block;
    background: #f0f8ff;
    color: #007cba;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 4px;
    margin-bottom: 2px;
}

/* Custom Mapbox Marker */
.marker {
  background-image: url('bgmarker.png');
    background-size: cover;
    width: 21px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
}

/* Production Ready Enhancements */
.huoltopiste-notification {
    position: relative;
    padding: 12px 40px 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
}

.huoltopiste-notification--info {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    color: #1565c0;
}

.huoltopiste-notification--error {
    background-color: #ffebee;
    border-left: 4px solid #f44336;
    color: #c62828;
}

.huoltopiste-notification--success {
    background-color: #e8f5e8;
    border-left: 4px solid #4caf50;
    color: #2e7d32;
}

.huoltopiste-notification__close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.huoltopiste-notification__close:hover {
    opacity: 1;
}

.loading-spinner {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.loading-spinner::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 2px solid var(--wp--preset--color--primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Accessibility improvements */
.filter-select:focus,
.select-search:focus,
.location-btn:focus,
.clear-all-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Performance: Hardware acceleration for animations */
.result-item,
.marker,
.select-dropdown {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Better mobile touch targets */
@media (max-width: 768px) {
    .filter-select,
    .select-search,
    .location-btn,
    .clear-all-btn,
    .select-search
   {
        min-height: 44px;
        min-width: 44px;
    }

       
    .clear-filter-btn {
        min-height: 24px;
        min-width: 24px;
    }
    
    .result-item {
        padding: 20px;
        margin-bottom: 15px;
    }
}
