/* Leaflet Maps Styling */
.leaflet-container {
    height: 400px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.map-container {
    position: relative;
    margin: 1rem 0;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.map-controls .btn {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.map-controls .btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.map-controls .btn-primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.map-controls .btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.map-controls .btn-danger {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.map-controls .btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.coordinates-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.coordinates-display .form-group {
    margin-bottom: 0;
}

.coordinates-display label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
    display: block;
}

.coordinates-display input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.coordinates-display input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.map-info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.map-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1e293b;
}

.map-info p {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
}

/* Geocoder styling */
.leaflet-control-geocoder {
    width: 300px;
    max-width: 90vw;
}

.leaflet-control-geocoder-form {
    width: 100%;
}

.leaflet-control-geocoder-form input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.leaflet-control-geocoder-form input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.leaflet-control-geocoder-results {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
}

.leaflet-control-geocoder-results a {
    display: block;
    padding: 0.5rem;
    text-decoration: none;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}

.leaflet-control-geocoder-results a:hover {
    background: #f9fafb;
}

.leaflet-control-geocoder-results a:last-child {
    border-bottom: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .leaflet-container {
        height: 300px;
    }

    .coordinates-display {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .map-controls {
        justify-content: center;
    }

    .leaflet-control-geocoder {
        width: 250px;
    }
}

/* Loading state */
.map-loading {
    position: relative;
}

.map-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ── Fix: peta tidak menimpa navbar (sticky/fixed) ── */
.map-container {
    position: relative;
    isolation: isolate;    /* buat stacking context baru */
    z-index: 0;
}

.leaflet-pane         { z-index: 4 !important; }
.leaflet-tile-pane    { z-index: 2 !important; }
.leaflet-overlay-pane { z-index: 3 !important; }
.leaflet-shadow-pane  { z-index: 4 !important; }
.leaflet-marker-pane  { z-index: 5 !important; }
.leaflet-tooltip-pane { z-index: 6 !important; }
.leaflet-popup-pane   { z-index: 7 !important; }
.leaflet-top,
.leaflet-bottom       { z-index: 8 !important; }

/* Tinggi peta di halaman create/edit */
.map-container .leaflet-container {
    height: 380px;
}