/* PCM Form Map Picker — scoped z-index rules
 *
 * Targets only picker instances via [id^="pcm-map-"] to avoid the global
 * z-index reset that dotswan/filament-map-picker applies to all Leaflet panes.
 * This file is registered via FilamentAsset so it loads on every Filament page
 * without interfering with the fleet map's pane stack.
 */

[id^="pcm-map-"] .leaflet-tile-pane    { z-index: 200 !important; }
[id^="pcm-map-"] .leaflet-overlay-pane { z-index: 400 !important; }
[id^="pcm-map-"] .leaflet-shadow-pane  { z-index: 500 !important; }
[id^="pcm-map-"] .leaflet-marker-pane  { z-index: 600 !important; }
[id^="pcm-map-"] .leaflet-tooltip-pane { z-index: 650 !important; }
[id^="pcm-map-"] .leaflet-popup-pane   { z-index: 700 !important; }

[id^="pcm-map-"] .leaflet-top,
[id^="pcm-map-"] .leaflet-bottom       { z-index: 1000 !important; }

/* Marker icon — remove default Leaflet background/border injected by divIcon */
.pcm-map-marker-icon {
    background: transparent !important;
    border: none !important;
}

/* Coordinate readout displayed below the map */
.pcm-map-coords {
    font-size: 0.7rem;
    color: #9ca3af;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    margin-top: 0.25rem;
}

/* ── Location Search Control ──────────────────────────────────────────── */

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

/* Toggle button */
.pcm-search-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.pcm-search-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}

.pcm-search-toggle--active {
    background: #3b82f6 !important;
    color: #ffffff !important;
}

.pcm-search-toggle--active:hover {
    background: #2563eb !important;
}

/* Panel — position:fixed so it is never clipped by the map container's
   overflow:hidden. In native fullscreen the fullscreen element becomes the
   containing block for fixed descendants, so the panel stays inside the
   fullscreen area without any overflow toggling.
   JS sets top/left from getBoundingClientRect() of the toggle button. */
.pcm-search-panel {
    position: fixed;
    z-index: 9999;
    width: 280px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.14);
    overflow: hidden;

    opacity: 0;
    transform: translateX(-8px) scale(0.97);
    transform-origin: left center;
    pointer-events: none;

    transition: opacity 0.18s ease,
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pcm-search-panel--open {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

/* Input row */
.pcm-search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    height: 38px;
    border-bottom: 1px solid #f3f4f6;
}

.pcm-search-icon {
    flex-shrink: 0;
    color: #9ca3af;
    display: flex;
    align-items: center;
}

.pcm-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: #111827;
    line-height: 1.4;
    padding: 0;
}

.pcm-search-input::placeholder {
    color: #9ca3af;
}

.pcm-search-clear {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    color: #6b7280;
    width: 18px;
    height: 18px;
    padding: 0;
    transition: background 0.12s ease, color 0.12s ease;
}

.pcm-search-clear:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Loading spinner */
.pcm-search-spinner {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: pcm-spin 0.65s linear infinite;
}

/* Results list */
.pcm-search-results {
    max-height: 220px;
    overflow-y: auto;
}

.pcm-search-result-row {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 9px 12px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.1s ease;
}

.pcm-search-result-row:last-child {
    border-bottom: none;
}

.pcm-search-result-row:hover {
    background: #f9fafb;
}

.pcm-search-result-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
}

.pcm-search-result-type {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
    text-transform: capitalize;
}

.pcm-search-empty {
    padding: 16px 12px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
}

/* ── Dark mode ───────────────────────────────────────────────────────── */

.dark .pcm-search-toggle {
    color: #e5e7eb;
}

.dark .pcm-search-toggle:hover {
    background: #374151;
    color: #f3f4f6;
}

.dark .pcm-search-toggle--active {
    background: #3b82f6 !important;
    color: #ffffff !important;
}

.dark .pcm-search-panel {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.dark .pcm-search-input-wrap {
    border-bottom-color: #374151;
}

.dark .pcm-search-icon {
    color: #6b7280;
}

.dark .pcm-search-input {
    color: #f3f4f6;
}

.dark .pcm-search-input::placeholder {
    color: #6b7280;
}

.dark .pcm-search-clear {
    background: #374151;
    color: #9ca3af;
}

.dark .pcm-search-clear:hover {
    background: #4b5563;
    color: #e5e7eb;
}

.dark .pcm-search-spinner {
    border-color: #374151;
    border-top-color: #60a5fa;
}

.dark .pcm-search-result-row {
    border-bottom-color: #374151;
}

.dark .pcm-search-result-row:hover {
    background: #374151;
}

.dark .pcm-search-result-name {
    color: #f3f4f6;
}

.dark .pcm-search-result-type {
    color: #6b7280;
}

.dark .pcm-search-empty {
    color: #9ca3af;
}