/**
 * Find Service — Map-specific styles
 *
 * Marker pins, cluster icons, sidebar, and layout overrides.
 */

/* ──────────── Layout ──────────── */

body.incardoc-find-service-page {
    overflow: hidden;
    --find-service-car-repair-color: #ef4444;
    --find-service-car-rental-color: #22c55e;
    --find-service-car-wash-color: #3b82f6;
    --find-service-gas-station-color: #f59e0b;
    --find-service-charging-station-color: oklch(from var(--primary) calc(l + 0.12) calc(c * 0.9) 220);
    --find-service-parking-color: #8b5cf6;
    --find-service-tire-service-color: #475569;
}

body.incardoc-find-service-embed-page {
    --find-service-available-height: 100vh;
    --find-service-available-height: 100dvh;
}

.incardoc-find-service-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100vw;
    height: var(--find-service-available-height, var(--height-screen-minus-header));
    overflow: hidden;
}

body.incardoc-find-service-embed-page .incardoc-find-service-main {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.fs-wrapper {
    position: relative;
    z-index: 0;
    isolation: isolate;
    width: 100%;
    max-width: 100vw;
    height: 100%;
    overflow: hidden;
}

.fs-map {
    width: 100%;
    height: 100%;
}

/* ──────────── Marker Pin ──────────── */

.fs-marker {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--marker-color, #e74c3c);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    will-change: transform;
    transition: transform 0.15s ease;
}

.fs-marker:hover {
    transform: scale(1.15);
}

/* ──────────── Cluster Icon ──────────── */

.fs-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cluster-color, #e74c3c);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    will-change: transform;
    transition: transform 0.15s ease;
}

.fs-cluster span {
    color: white;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.fs-cluster:hover {
    transform: scale(1.1);
}

/* Override default MarkerCluster styling */
.marker-cluster {
    background: none !important;
}

.marker-cluster div {
    background: none !important;
}

/* ──────────── Popup ──────────── */

.fs-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 4px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

.fs-popup .leaflet-popup-content {
    margin: 10px 12px;
}

.fs-popup-detail {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--muted-foreground, #666);
    font-size: 12px;
    margin-top: 2px;
}

.fs-popup-label {
    font-size: 11px;
    flex-shrink: 0;
}

.fs-popup-link {
    color: var(--primary, #e76f51);
    text-decoration: none;
    word-break: break-all;
}

.fs-popup-link:hover {
    text-decoration: underline;
}

.fs-popup-desc {
    display: block;
    margin-top: 4px;
    color: var(--muted-foreground, #666);
    font-size: 12px;
    line-height: 1.4;
}

.fs-popup-street,
.fs-popup-hours {
    color: var(--muted-foreground, #666);
    font-size: 12px;
}

/* ──────────── Sidebar ──────────── */

.fs-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 100%;
    width: 360px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--card, #fff);
    border-right: 1px solid var(--border, #e0e0e0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);
}

.fs-ready .fs-sidebar {
    transition: transform 0.3s ease;
}

.fs-sidebar[data-hidden="true"] {
    transform: translateX(-100%);
    pointer-events: none;
}

.fs-sidebar-toggle {
    position: absolute;
    top: 50%;
    left: 8px;
    z-index: 1001;
    transform: translateY(-50%);
    background: var(--card, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 999px;
    width: 42px;
    height: 42px;
    padding: 0;
    cursor: pointer;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground, #333);
}

.fs-sidebar-toggle[data-open="true"] {
    left: 368px;
}

.fs-ready .fs-sidebar-toggle {
    transition: left 0.3s ease;
}

.fs-toggle-close {
    display: none;
}

.fs-ready .fs-sidebar-toggle svg {
    transition: transform 0.3s ease;
}

.fs-sidebar-toggle[data-open="false"] svg {
    transform: rotate(180deg);
}

.fs-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    flex-shrink: 0;
}

.fs-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ──────────── Search Input ──────────── */

.fs-search-wrap {
    position: relative;
}

.fs-search-input {
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid var(--input, #d0d5dd);
    border-radius: var(--radius, 0.55rem);
    font-size: 14px;
    background: var(--background, #fff);
    color: var(--foreground, #333);
    outline: none;
    transition: border-color 0.2s;
}

.fs-search-input:focus {
    border-color: var(--ring, #e76f51);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring, #e76f51) 20%, transparent);
}

.fs-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground, #888);
    pointer-events: none;
}

.fs-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground, #888);
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
}

.fs-search-clear:hover {
    color: var(--foreground, #333);
    background: var(--muted, #f0f0f0);
}

.fs-reference-pin {
    width: 24px;
    height: 24px;
    position: relative;
    border: 2px solid var(--primary, #e76f51);
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary, #e76f51) 12%, var(--background, #fff));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary, #e76f51) 16%, transparent);
}

.fs-reference-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary, #e76f51);
    transform: translate(-50%, -50%);
}

.fs-map-control {
    margin-top: 8px;
    border: none;
    background: transparent;
}

.fs-map-control-button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--background, #fff);
    color: var(--foreground, #333);
    cursor: pointer;
}

.fs-map-control-button:hover:not(:disabled) {
    background: var(--muted, #f0f0f0);
}

.fs-map-control-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.fs-map-control-button.is-loading svg {
    animation: fs-spin 0.8s linear infinite;
}

/* ──────────── Autocomplete ──────────── */

.fs-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    margin-top: 4px;
    background: var(--card, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: var(--radius, 0.55rem);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 220px;
    overflow-y: auto;
}

.fs-autocomplete-item {
    padding: 10px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #e0e0e0);
    color: var(--foreground, #333);
    transition: background 0.15s;
}

.fs-autocomplete-item:last-child {
    border-bottom: none;
}

.fs-autocomplete-item:hover {
    background: var(--muted, #f0f0f0);
}

/* ──────────── Filter Chips ──────────── */

.fs-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fs-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1.5px solid var(--border, #e0e0e0);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--foreground, #333);
    transition: all 0.2s;
    white-space: nowrap;
}

.fs-filter-chip:hover {
    border-color: var(--chip-color, #888);
    background: color-mix(in srgb, var(--chip-color, #888) 8%, transparent);
}

.fs-filter-chip svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--chip-color, #888);
}

.fs-filter-chip[data-active="true"] {
    background: color-mix(in srgb, var(--chip-color, #888) 12%, transparent);
    border-color: var(--chip-color, #888);
    color: color-mix(in srgb, var(--chip-color, #888) 80%, #000);
    box-shadow: 0 0 0 1px var(--chip-color, #888);
}

.fs-filter-chip[data-active="true"]:hover {
    background: color-mix(in srgb, var(--chip-color, #888) 20%, transparent);
}

/* ──────────── Results List ──────────── */

.fs-results-group {
    margin-bottom: 16px;
}

.fs-results-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--foreground, #333);
    width: 100%;
    background: none;
    border: none;
    padding: 6px 4px;
    border-radius: var(--radius, 0.55rem);
    cursor: pointer;
    transition: background 0.15s;
}

.fs-results-group-header:hover {
    background: var(--muted, #f0f0f0);
}

.fs-results-group-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fs-results-group-count {
    color: var(--muted-foreground, #888);
    font-weight: 400;
    margin-left: auto;
}

.fs-collapse-icon {
    flex-shrink: 0;
    color: var(--muted-foreground, #888);
    transition: transform 0.2s;
}

.fs-collapse-icon.fs-collapsed {
    transform: rotate(-90deg);
}

.fs-result-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius, 0.55rem);
    cursor: pointer;
    transition: background 0.15s;
}

.fs-result-item:hover {
    background: var(--muted, #f0f0f0);
}

.fs-result-item.fs-result-selected {
    background: color-mix(in srgb, var(--primary, #e76f51) 8%, transparent);
    outline: 1.5px solid color-mix(in srgb, var(--primary, #e76f51) 30%, transparent);
}

.fs-result-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.fs-result-info {
    flex: 1;
    min-width: 0;
}

.fs-result-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--foreground, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fs-result-meta {
    font-size: 12px;
    color: var(--muted-foreground, #888);
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.fs-result-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.fs-result-detail {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12px;
    color: var(--muted-foreground, #666);
    line-height: 1.4;
}

.fs-detail-icon {
    font-size: 11px;
    flex-shrink: 0;
}

.fs-detail-link {
    color: var(--primary, #e76f51);
    text-decoration: none;
    word-break: break-all;
}

.fs-detail-link:hover {
    text-decoration: underline;
}

.fs-result-desc {
    color: var(--muted-foreground, #888);
    font-style: italic;
}

/* ──────────── Refresh Button ──────────── */

.fs-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: var(--radius, 0.55rem);
    background: var(--background, #fff);
    color: var(--foreground, #333);
    cursor: pointer;
    transition: all 0.2s;
}

.fs-refresh-btn:hover {
    background: var(--muted, #f0f0f0);
}

.fs-refresh-btn svg {
    width: 14px;
    height: 14px;
}

/* ──────────── Loading / Status ──────────── */

.fs-loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    font-size: 13px;
    color: var(--muted-foreground, #888);
}

.fs-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border, #e0e0e0);
    border-top-color: var(--primary, #e76f51);
    border-radius: 50%;
    animation: fs-spin 0.6s linear infinite;
}

@keyframes fs-spin {
    to { transform: rotate(360deg); }
}

.fs-empty-state {
    text-align: center;
    padding: 24px 16px;
    color: var(--muted-foreground, #888);
    font-size: 13px;
}

.fs-error-msg {
    font-size: 12px;
    color: var(--destructive, #e74c3c);
    margin-top: 4px;
}

/* ──────────── Fullscreen support ──────────── */

.leaflet-pseudo-fullscreen,
.fs-wrapper:fullscreen {
    z-index: 2000;
}

.leaflet-pseudo-fullscreen .fs-sidebar,
.fs-wrapper:fullscreen .fs-sidebar {
    z-index: 10001;
}

.fs-wrapper:fullscreen .fs-sidebar-toggle,
.leaflet-pseudo-fullscreen .fs-sidebar-toggle {
    z-index: 10002;
}

/* ──────────── Responsive ──────────── */

@media (max-width: 640px) {
    .fs-sidebar {
        width: 100%;
    }

    .fs-search-wrap {
        position: relative;
        margin-left: 40px;
    }

    .fs-ready .fs-sidebar-toggle {
        transition: none;
    }

    .fs-sidebar-toggle {
        top: 16px;
        left: 8px;
        transform: none;
    }

    .fs-sidebar-toggle[data-open="true"] {
        left: 8px;
        top: 16px;
        bottom: auto;
        transform: none;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    }

    .fs-sidebar-toggle[data-open="true"] .fs-toggle-chevron {
        display: none;
    }

    .fs-sidebar-toggle[data-open="true"] .fs-toggle-close {
        display: block;
    }

    .fs-map-control {
        margin-top: 56px;
    }
}

/* ──────────── Fix icon position during zoom ──────────── */

.leaflet-zoom-anim .leaflet-zoom-animated {
    will-change: transform;
}

/*  IMPORTANT! Don't  hide attribution, or you may violate the terms of use for the map tiles! */
.leaflet-control-attribution {
    font-size: 10px !important;
}
