/* ARDEM Wiki Map - Enhanced Styles with Zones and Local Markers */

/* Custom Marker Icons - FIXED: Always visible markers with proper hierarchy */
.custom-marker-icon {
    background: transparent !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* UPDATED: Marker hierarchy with z-index */
.custom-marker-icon.location-marker {
    z-index: 2000000 !important; /* Highest priority for location markers */
}

.custom-marker-icon.local-marker {
    z-index: 3000000 !important; /* Local markers above everything */
}

.custom-marker-icon.regular-marker {
    z-index: 1000000 !important; /* Regular markers lowest */
}

.custom-marker-icon.always-visible,
.marker-always-visible {
    visibility: visible !important;
    display: block !important;
    opacity: 1 !important;
    position: absolute !important;
}

.custom-marker-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* NEW: Local marker specific styling */
.local-marker-wrapper {
    position: relative;
}

.local-marker-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF6B6B;
    color: white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    font-size: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Remove any CSS that might hide markers */
.leaflet-marker-icon {
    /* Ensure markers are visible */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.temp-marker-icon {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Marker Labels - UPDATED with improved hierarchy */
.marker-label {
    background: rgba(15, 17, 24, 0.9) !important;
    border: 1px solid rgba(254, 206, 39, 0.5) !important;
    border-radius: 6px !important;
    color: #FECE27 !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    padding: 4px 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 3000 !important; /* Base z-index for labels */
}

/* Location labels always on top */
.marker-label.location-label {
    background: rgba(254, 206, 39, 0.95) !important;
    border: 1px solid rgba(254, 206, 39, 0.8) !important;
    color: #101828 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    z-index: 4000 !important; /* Location labels highest priority */
    box-shadow: 0 6px 16px rgba(254, 206, 39, 0.4) !important;
}

/* NEW: Local marker labels */
.marker-label.local-label {
    background: rgba(255, 107, 107, 0.95) !important;
    border: 1px solid rgba(255, 107, 107, 0.8) !important;
    color: white !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    z-index: 5000 !important; /* Local labels highest */
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.4) !important;
}

.marker-label::before {
    border-top-color: rgba(15, 17, 24, 0.9) !important;
    z-index: inherit !important;
}

.marker-label.location-label::before {
    border-top-color: rgba(254, 206, 39, 0.95) !important;
}

.marker-label.local-label::before {
    border-top-color: rgba(255, 107, 107, 0.95) !important;
}

/* === ZONE STYLES === */

/* Zone Labels */
.zone-label-container {
    background: transparent !important;
    border: none !important;
    pointer-events: none !important;
    /* Label wird durch JavaScript-Logic gesteuert, nicht durch CSS */
}

.zone-label {
    background: rgba(15, 17, 24, 0.95) !important;
    border: 2px solid rgba(254, 206, 39, 0.8) !important;
    border-radius: 8px !important;
    color: #FECE27 !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    padding: 6px 12px !important;
    text-align: center !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(15px) !important;
    white-space: nowrap !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8) !important;
    z-index: 1500 !important;
    max-width: none !important;
    overflow: visible !important;
    text-overflow: unset !important;
    line-height: 1.2 !important;
}



/* Zone Popup Styles */
.leaflet-popup.zone-popup .leaflet-popup-content-wrapper {
    background: rgba(20, 22, 30, 0.98) !important;
    border: 2px solid rgba(254, 206, 39, 0.5) !important;
    border-radius: 15px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(20px) !important;
}

.zone-popup h4 {
    font-size: 18px !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
}

/* Zone drawing temporary markers */
.leaflet-interactive.zone-temp-marker {
    z-index: 1200 !important;
}

.zone-temp-line {
    z-index: 1150 !important;
}

/* Zone polygons - ensure they're below markers */
.leaflet-overlay-pane svg g path {
    z-index: auto !important; /* Let Leaflet handle zone z-indexes */
}

/* Zone drawing mode cursor */
.zone-drawing-mode {
    cursor: crosshair !important;
}

/* UPDATED: Custom Popup Styles with improved z-index hierarchy */
.leaflet-popup.custom-popup .leaflet-popup-content-wrapper {
    background: rgba(15, 17, 24, 0.95) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(15px) !important;
    padding: 12px !important;
    z-index: 6000 !important; /* CRITICAL: Highest z-index for popups */
}

/* SUPER HIGH PRIORITY POPUPS - for clicked markers/zones */
.leaflet-popup.high-priority-popup {
    z-index: 10000 !important; /* Absolutely highest for active popups */
}

.leaflet-popup.high-priority-popup .leaflet-popup-content-wrapper {
    z-index: 10000 !important;
}

.leaflet-popup.high-priority-popup .leaflet-popup-tip {
    z-index: 10000 !important;
}

/* NEW: Local marker popup styling */
.leaflet-popup.local-popup .leaflet-popup-content-wrapper {
    background: rgba(20, 15, 15, 0.95) !important;
    border: 1px solid rgba(255, 107, 107, 0.5) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(255, 107, 107, 0.3) !important;
}

.leaflet-popup.custom-popup .leaflet-popup-content {
    color: white !important;
    margin: 0 !important;
    font-family: inherit !important;
    line-height: 1.5 !important;
    min-width: 280px !important;
    max-width: 320px !important;
}

.leaflet-popup.custom-popup .leaflet-popup-tip {
    background: rgba(15, 17, 24, 0.95) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-top: none !important;
    border-right: none !important;
    z-index: inherit !important;
}

.leaflet-popup.local-popup .leaflet-popup-tip {
    background: rgba(20, 15, 15, 0.95) !important;
    border: 1px solid rgba(255, 107, 107, 0.5) !important;
    border-top: none !important;
    border-right: none !important;
}

.leaflet-popup.custom-popup .leaflet-popup-close-button {
    color: #FECE27 !important;
    font-size: 18px !important;
    font-weight: bold !important;
    right: 8px !important;
    top: 8px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: rgba(254, 206, 39, 0.1) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    transition: all 0.3s ease !important;
    z-index: 10010 !important;
}

.leaflet-popup.custom-popup .leaflet-popup-close-button:hover {
    background: rgba(254, 206, 39, 0.2) !important;
    border-color: rgba(254, 206, 39, 0.5) !important;
    transform: scale(1.1) !important;
}

/* NEW: Local marker popup badges */
.local-badge {
    background: #FF6B6B;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.local-badge-small {
    background: #FF6B6B;
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 8px;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 4px;
}

/* Marker Popup Internal Styling */
.marker-popup h4 {
    font-size: 16px !important;
    line-height: 1.2 !important;
    margin-bottom: 8px !important;
}

.marker-popup h5 {
    font-size: 14px !important;
    line-height: 1.3 !important;
    margin-bottom: 4px !important;
}

.marker-popup .text-xs {
    font-size: 11px !important;
}

.marker-popup .max-h-20 {
    max-height: 80px !important;
}

.marker-popup .max-h-16 {
    max-height: 64px !important;
}

/* NEW: Local marker popup styling */
.local-marker-popup {
    border-left: 4px solid #FF6B6B !important;
}

.local-result {
    border-left: 3px solid #FF6B6B !important;
    background: rgba(255, 107, 107, 0.05) !important;
}

/* Search Panel Header - FIXED layout */
.search-header-content {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
}

.search-header-content .search-toggle-btn {
    order: 1;
    flex-shrink: 0;
}

.search-header-content .search-icon {
    order: 2;
    flex-shrink: 0;
    font-size: 16px;
}

.search-header-content .search-title {
    order: 3;
    flex-grow: 1;
    margin: 0;
    font-size: 18px;
}

/* Form Select Styling - FIXED for dark theme */
.form-select {
    background: rgba(30, 30, 35, 0.95) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 6px !important;
    padding: 10px 40px 10px 12px !important;
    color: #ffffff !important;
    font-size: 14px !important;
    width: 100% !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23FECE27' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 12px center !important;
    background-repeat: no-repeat !important;
    background-size: 16px 16px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

.form-select:focus {
    outline: none !important;
    border-color: #FECE27 !important;
    background: rgba(25, 25, 30, 0.98) !important;
    box-shadow: 0 0 0 3px rgba(254, 206, 39, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    color: #ffffff !important;
}

.form-select:hover {
    border-color: rgba(254, 206, 39, 0.5) !important;
    background: rgba(25, 25, 30, 0.95) !important;
}

/* Dropdown Options Styling - CRITICAL FIX */
.form-select option {
    background: #1e1e23 !important;
    color: #ffffff !important;
    padding: 10px !important;
    border: none !important;
    font-size: 14px !important;
}

.form-select option:hover,
.form-select option:focus {
    background: rgba(254, 206, 39, 0.2) !important;
    color: #FECE27 !important;
}

.form-select option:checked,
.form-select option:selected {
    background: rgba(254, 206, 39, 0.3) !important;
    color: #FECE27 !important;
    font-weight: 600 !important;
}

/* Zone Form Specific Styling */
.zone-drawing-help {
    background: rgba(254, 206, 39, 0.1) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    margin-bottom: 16px !important;
    color: #FECE27 !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

.color-input-group {
    display: flex !important;
    gap: 12px !important;
    align-items: center !important;
}

.color-input {
    width: 60px !important;
    height: 40px !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    background: none !important;
    padding: 0 !important;
}

.color-input:hover {
    border-color: rgba(254, 206, 39, 0.5) !important;
    transform: scale(1.05) !important;
}

.range-input {
    width: 100% !important;
    margin-top: 8px !important;
    appearance: none !important;
    height: 6px !important;
    border-radius: 3px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    outline: none !important;
}

.range-input::-webkit-slider-thumb {
    appearance: none !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    background: #FECE27 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

.range-input::-moz-range-thumb {
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    background: #FECE27 !important;
    cursor: pointer !important;
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    .form-select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23FECE27' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
        padding-right: 35px !important;
    }
}

/* WebKit specific fixes */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    .form-select {
        background-position: right 10px center !important;
    }
}

/* Additional form input styling for consistency */
.form-input, .form-textarea {
    background: rgba(30, 30, 35, 0.95) !important;
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 6px !important;
    padding: 10px 12px !important;
    color: #ffffff !important;
    font-size: 14px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

.form-input:focus, .form-textarea:focus {
    outline: none !important;
    border-color: #FECE27 !important;
    background: rgba(25, 25, 30, 0.98) !important;
    box-shadow: 0 0 0 3px rgba(254, 206, 39, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

.form-input::placeholder, .form-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Readonly inputs */
.form-input:read-only {
    background: rgba(255, 255, 255, 0.05) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    cursor: not-allowed !important;
}

/* Map Controls - UPDATED Z-INDEX */
.leaflet-control-zoom {
    border: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 8px !important;
    background: rgba(15, 17, 24, 0.9) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    z-index: 1200 !important; /* Above map but below panels */
}

.leaflet-control-zoom a {
    background: transparent !important;
    border: none !important;
    color: #FECE27 !important;
    font-weight: bold !important;
    font-size: 18px !important;
    transition: all 0.3s ease !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(254, 206, 39, 0.2) !important;
    color: white !important;
    transform: scale(1.1) !important;
}

.leaflet-control-zoom a:first-child {
    border-bottom: 1px solid rgba(254, 206, 39, 0.3) !important;
    border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 8px 8px !important;
}

/* Mobile Responsive Adjustments - Fixed */
@media (max-width: 768px) {
    .map-control-panel {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        left: 20px !important;
        right: auto !important;
    }
    
    .filter-panel {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        left: 20px !important;
        max-height: 50vh !important;
        transform: translateX(-85%) !important;
    }
    
    .filter-panel.collapsed {
        transform: translateX(-92%) !important;
    }
    
    .search-panel {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        right: 20px !important;
        left: auto !important;
        top: 20px !important;
        transform: translateX(85%) !important;
    }
    
    .search-panel.collapsed {
        transform: translateX(92%) !important;
    }
    
    .add-marker-panel, .add-zone-panel {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        left: 20px !important;
        bottom: 20px !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
    }
    
    .info-panel {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        right: 20px !important;
        bottom: 20px !important;
        max-height: 50vh !important;
    }
    
    /* Panel toggle buttons - Fixed positioning */
    .panel-toggle-header {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 1002 !important;
        min-width: 40px !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .filter-panel .panel-toggle-header {
        right: -45px !important;
    }
    
    .search-panel .search-header-content .search-toggle-btn {
        position: static !important;
        transform: none !important;
        right: auto !important;
        left: auto !important;
    }
    
    /* Search panel mobile adjustments */
    .search-panel .panel-header {
        position: relative !important;
    }
    
    /* Make buttons larger for touch */
    .btn {
        padding: 12px 18px !important;
        font-size: 16px !important;
        min-height: 44px !important;
    }
    
    .panel-toggle-header {
        padding: 12px !important;
        font-size: 16px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Adjust popup for mobile */
    .leaflet-popup.custom-popup .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 60px) !important;
        min-width: 260px !important;
    }
    
    .marker-popup, .zone-popup {
        min-width: auto !important;
        max-width: 100% !important;
    }
    
    /* Touch-friendly checkboxes */
    .subcategory-item input[type="checkbox"] {
        width: 20px !important;
        height: 20px !important;
        margin-right: 12px !important;
        min-width: 20px !important;
        min-height: 20px !important;
    }
    
    .subcategory-item label {
        display: flex !important;
        align-items: center !important;
        padding: 8px 0 !important;
        min-height: 44px !important;
        cursor: pointer !important;
    }
    
    /* Larger form inputs for mobile */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 14px 12px !important;
        min-height: 44px !important;
    }
    
    .form-select {
        padding-right: 44px !important;
    }
    
    /* Color inputs for mobile */
    .color-input {
        width: 80px !important;
        height: 50px !important;
    }
    
    /* Range inputs for mobile */
    .range-input {
        height: 10px !important;
    }
    
    .range-input::-webkit-slider-thumb {
        width: 24px !important;
        height: 24px !important;
    }
    
    .range-input::-moz-range-thumb {
        width: 24px !important;
        height: 24px !important;
    }
    
    /* Category headers clickable area */
    .category-header {
        padding: 12px 8px !important;
        min-height: 44px !important;
        cursor: pointer !important;
    }
    
    /* Zone labels mobile scaling */
    .zone-label {
        font-size: 12px !important;
        padding: 4px 8px !important;
        max-width: none !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* Local marker badge mobile */
    .local-marker-badge {
        width: 14px !important;
        height: 14px !important;
        font-size: 9px !important;
    }
}

/* Panel positioning fixes for desktop */
@media (min-width: 769px) {
    .filter-panel {
        transform: translateX(0) !important;
    }
    
    .filter-panel.collapsed {
        transform: translateX(-92%) !important;
    }
    
    .search-panel {
        transform: translateX(0) !important;
    }
    
    .search-panel.collapsed {
        transform: translateX(92%) !important;
    }
    
    .panel-toggle-header {
        position: static !important;
        transform: none !important;
    }
    
    /* Desktop search header positioning - FIXED */
    .search-panel .search-header-content .search-toggle-btn {
        position: static !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
    }
    
    .search-panel .search-header-content {
        position: relative !important;
        padding-right: 0 !important;
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .custom-marker-icon i {
        text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    }
    
    .custom-marker-icon img {
        filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.8)) !important;
    }
    
    .leaflet-control-zoom {
        border-width: 0.5px;
    }
    
    .zone-label {
        text-shadow: 1px 1px 3px rgba(0,0,0,0.9) !important;
    }
    
    .local-marker-badge {
        text-shadow: 1px 1px 2px rgba(0,0,0,0.8) !important;
    }
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    .map-control-panel {
        background: rgba(10, 12, 18, 0.95);
    }
    
    .leaflet-popup.custom-popup .leaflet-popup-content-wrapper {
        background: rgba(10, 12, 18, 0.98) !important;
    }
    
    .form-select {
        background: rgba(20, 20, 25, 0.98) !important;
    }
    
    .zone-label {
        background: rgba(8, 10, 15, 0.95) !important;
    }
    
    .local-marker-badge {
        background: #FF4444 !important;
    }
}

/* Loading animations */
@keyframes marker-appear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-marker-icon.new-marker {
    animation: marker-appear 0.6s ease-out;
}

/* Pulse animation for verified markers */
@keyframes verified-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.verified-marker {
    animation: verified-pulse 2s infinite;
}

/* Zone animation for new zones */
@keyframes zone-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.new-zone {
    animation: zone-appear 0.8s ease-out;
}

/* NEW: Local marker animations */
@keyframes local-marker-appear {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(0deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(360deg);
    }
}

.local-marker.new-local-marker {
    animation: local-marker-appear 0.8s ease-out;
}

/* Category color coding */
.category-locations { color: #FECE27; }
.category-objects { color: #4169E1; }
.category-loot { color: #FFD700; }
.category-farm { color: #228B22; }
.category-spawns { color: #00FF00; }
.category-vehicle-spawns { color: #FF6347; }
.category-enemies { color: #FF0000; }
.category-animals { color: #228B22; }

/* Zone type color coding */
.zone-radioactive { 
    border-color: #00FF00 !important;
    background-color: rgba(0, 255, 0, 0.1) !important;
}

.zone-military { 
    border-color: #FF0000 !important;
    background-color: rgba(255, 0, 0, 0.1) !important;
}

.zone-industrial { 
    border-color: #808080 !important;
    background-color: rgba(128, 128, 128, 0.1) !important;
}

.zone-safe { 
    border-color: #00BFFF !important;
    background-color: rgba(0, 191, 255, 0.1) !important;
}

.zone-dangerous { 
    border-color: #FF4500 !important;
    background-color: rgba(255, 69, 0, 0.1) !important;
}

/* Smooth transitions for all interactive elements */
.map-control-panel * {
    transition: all 0.3s ease;
}

/* Focus styles for accessibility */
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.color-input:focus,
.range-input:focus {
    box-shadow: 0 0 0 3px rgba(254, 206, 39, 0.3);
}

button:focus,
.btn:focus {
    outline: 2px solid #FECE27;
    outline-offset: 2px;
}

/* Custom scrollbar for webkit browsers */
.map-control-panel::-webkit-scrollbar {
    width: 8px;
}

.map-control-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.map-control-panel::-webkit-scrollbar-thumb {
    background: rgba(254, 206, 39, 0.5);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-control-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(254, 206, 39, 0.7);
}

/* Print styles */
@media print {
    .map-control-panel,
    .leaflet-control-zoom,
    #map-controls {
        display: none !important;
    }
    
    #map {
        position: relative !important;
        width: 100% !important;
        height: 500px !important;
    }
    
    .zone-label {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
    }
    
    .local-marker-badge {
        background: black !important;
        color: white !important;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
        border: 4px solid #FECE27;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .map-control-panel {
        background: black !important;
        border: 2px solid white !important;
    }
    
    .btn-primary {
        background: yellow !important;
        color: black !important;
        border: 2px solid black !important;
    }
    
    .text-yellow-400 {
        color: yellow !important;
    }
    
    .form-select, .form-input, .form-textarea, .color-input {
        background: black !important;
        color: white !important;
        border: 2px solid white !important;
    }
    
    .zone-label {
        background: yellow !important;
        color: black !important;
        border: 2px solid black !important;
    }
    
    .local-marker-badge {
        background: red !important;
        color: white !important;
        border: 2px solid white !important;
    }
}

/* Additional utility classes */
.map-hidden {
    display: none !important;
}

.map-visible {
    display: block !important;
}

.map-fade-in {
    animation: fadeIn 0.5s ease-in;
}

.map-fade-out {
    animation: fadeOut 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Truncate long text in popups */
.marker-popup .truncate, .zone-popup .truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* Scrollable areas in popups */
.marker-popup .overflow-y-auto, .zone-popup .overflow-y-auto {
    overflow-y: auto !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(254, 206, 39, 0.5) transparent !important;
}

.marker-popup .overflow-y-auto::-webkit-scrollbar,
.zone-popup .overflow-y-auto::-webkit-scrollbar {
    width: 4px !important;
}

.marker-popup .overflow-y-auto::-webkit-scrollbar-track,
.zone-popup .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent !important;
}

.marker-popup .overflow-y-auto::-webkit-scrollbar-thumb,
.zone-popup .overflow-y-auto::-webkit-scrollbar-thumb {
    background: rgba(254, 206, 39, 0.5) !important;
    border-radius: 2px !important;
}

.marker-popup .overflow-y-auto::-webkit-scrollbar-thumb:hover,
.zone-popup .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: rgba(254, 206, 39, 0.7) !important;
}

/* Improved touch targets */
@media (pointer: coarse) {
    .btn,
    .category-header,
    .subcategory-item label,
    .search-result-item,
    .panel-toggle-header,
    .color-input,
    .toggle-switch {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    .range-input {
        min-height: 44px !important;
    }
}

/* Enhanced panel transitions */
.map-control-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Fix for panel content visibility during transitions */
.map-control-panel.collapsed .panel-content {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease !important;
}

.map-control-panel:not(.collapsed) .panel-content {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: opacity 0.3s ease 0.1s !important;
}

/* Edit Mode Styling */
.edit-mode-active {
    border: 2px dashed #FECE27 !important;
    background: rgba(254, 206, 39, 0.1) !important;
}

.draggable-marker {
    cursor: move !important;
}

/* Zone Drawing Mode Styling */
.zone-drawing-active {
    cursor: crosshair !important;
}

.zone-point-marker {
    border: 2px solid #FECE27 !important;
    background: rgba(254, 206, 39, 0.8) !important;
}

/* Custom icons in category lists */
.subcategory-item img {
    width: 16px !important;
    height: 16px !important;
    margin-right: 8px !important;
    vertical-align: middle !important;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5)) !important;
}

/* === CRITICAL Z-INDEX HIERARCHY - COMPLETELY REWRITTEN === */

/* Map container - base level */
#map-container {
    z-index: 1000 !important;
}

/* Map itself - let Leaflet handle all its internal z-indexes */
#map {
    z-index: auto !important;
}

/* DO NOT override any Leaflet panes - they have their own z-index management */
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
.leaflet-tooltip-pane {
    z-index: auto !important;
}

/* ABSOLUTE HIGHEST PRIORITY: Popup pane gets ultimate priority */
.leaflet-popup-pane {
    z-index: 999999999 !important; /* Absolutely highest for popups */
}

.leaflet-popup {
    z-index: 999999999 !important; /* Ultimate priority */
}

/* SUPER HIGH PRIORITY POPUPS - for clicked markers/zones */
.leaflet-popup.super-high-priority-popup {
    z-index: 999999999 !important; /* Absolutely highest for active popups */
}

.leaflet-popup.super-high-priority-popup .leaflet-popup-content-wrapper {
    z-index: 999999999 !important;
}

.leaflet-popup.super-high-priority-popup .leaflet-popup-tip {
    z-index: 999999999 !important;
}

/* HIGH PRIORITY POPUPS - fallback */
.leaflet-popup.high-priority-popup {
    z-index: 888888888 !important;
}

.leaflet-popup.high-priority-popup .leaflet-popup-content-wrapper {
    z-index: 888888888 !important;
}

.leaflet-popup.high-priority-popup .leaflet-popup-tip {
    z-index: 888888888 !important;
}

/* Ensure popup content is visible */
.leaflet-popup-content-wrapper {
    z-index: inherit !important;
}

.leaflet-popup-tip {
    z-index: inherit !important;
}

/* Map control panels - above the map but below popups */
.map-control-panel {
    z-index: 1001 !important;
}

/* Map controls */
#map-controls {
    z-index: 1002 !important;
}

/* Loading overlay - above panels but below popups */
.loading-overlay {
    z-index: 1003 !important;
}

/* Notifications - above loading */
.fixed.top-24 {
    z-index: 1004 !important;
}

/* NAVBAR - highest priority but separate from map */
nav {
    z-index: 9999 !important;
}

.dropdown-menu {
    z-index: 10000 !important;
}

/* Mobile menu */
#mobile-menu {
    z-index: 9998 !important;
}

/* Ensure all dropdown elements are properly layered */
.relative.group .dropdown-menu {
    z-index: 10000 !important;
}

.group:hover .dropdown-menu {
    z-index: 10000 !important;
}

/* Additional navbar dropdown fixes */
nav .relative.group {
    z-index: 10000 !important;
}

nav .absolute {
    z-index: 10001 !important;
}

/* Force dropdown visibility above everything */
nav .group-hover\:opacity-100 {
    z-index: 10002 !important;
}

nav .group-hover\:visible {
    z-index: 10002 !important;
}

/* Ensure navbar dropdowns work on map page */
body nav,
body nav * {
    position: relative !important;
}

body nav .dropdown-menu {
    position: absolute !important;
    z-index: 10000 !important;
}

/* Make sure map container doesn't interfere */
#map-container {
    position: fixed !important;
    z-index: 1000 !important;
}

/* Additional specificity for navbar dropdowns */
.container nav .relative.group .dropdown-menu,
nav .relative.group .dropdown-menu,
.group .dropdown-menu {
    z-index: 10000 !important;
    position: absolute !important;
}

/* Ensure proper stacking context */
nav {
    position: relative !important;
    z-index: 9999 !important;
}

nav > * {
    z-index: inherit !important;
}

/* Final override for any stubborn dropdowns */
nav [class*="dropdown"],
nav [class*="group"]:hover [class*="absolute"],
nav .group:hover .absolute {
    z-index: 10000 !important;
}

/* Media query for mobile navbar z-index */
@media (max-width: 768px) {
    #mobile-menu {
        z-index: 9998 !important;
    }
    
    nav {
        z-index: 9999 !important;
    }
    .zone-label {
        font-size: 12px !important;
        padding: 4px 8px !important;
        max-width: 120px !important;
    }
}