/* Map Styles */

.map-container {
    position: relative;
    height: calc(100vh - 60px);
    width: 100%;
    z-index: 0; /* Create stacking context so map z-indices don't escape */
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.map-btn {
    background: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-btn:hover {
    background: #f1f5f9;
    transform: scale(1.05);
}

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

/* Filter Panel */
.filter-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 280px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.filter-panel.collapsed {
    padding: 0;
    max-width: none;
}

.filter-panel.collapsed .filter-content {
    display: none;
}

.filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    text-align: left;
}

.filter-toggle svg {
    width: 18px;
    height: 18px;
}

.filter-section {
    margin-bottom: 1rem;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    letter-spacing: 0.05em;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: white;
    transition: all 0.2s;
}

.filter-chip:hover {
    border-color: #cbd5e1;
}

.filter-chip.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.filter-chip .chip-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Search Box */
.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

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

.search-box svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #94a3b8;
}

/* POI Popup */
.poi-popup {
    min-width: 200px;
}

.poi-popup h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1e293b;
}

.poi-popup .poi-category {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.poi-popup .poi-description {
    font-size: 0.875rem;
    color: #475569;
    margin: 0.5rem 0;
}

.poi-popup .poi-meta {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.poi-popup .poi-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.poi-popup .btn-sm {
    flex: 1;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.poi-popup .btn-primary {
    background: #3b82f6;
    color: white;
}

.poi-popup .btn-primary:hover {
    background: #2563eb;
}

.poi-popup .btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.poi-popup .btn-secondary:hover {
    background: #e2e8f0;
}

.camping-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #dcfce7;
    color: #166534;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
}

.checkin-popup-img {
    margin: -0.75rem -0.75rem 0.75rem -0.75rem;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.checkin-popup-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.checkin-popup-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.checkin-popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.checkin-popup-action,
.leaflet-popup-content .checkin-popup-action,
a.checkin-popup-action,
button.checkin-popup-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    color: #475569;
    background: #f1f5f9;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.2s;
    white-space: nowrap;
    line-height: 1;
}

.checkin-popup-action:hover,
a.checkin-popup-action:hover {
    background: #e2e8f0;
    color: #1e293b;
    text-decoration: none;
}

.checkin-popup-action svg {
    color: #94a3b8;
    flex-shrink: 0;
}

.checkin-popup-action.liked {
    color: #ef4444;
}

.checkin-popup-action.liked svg {
    color: #ef4444;
}

.map-scroll-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
    white-space: nowrap;
}

.map-scroll-msg.visible {
    opacity: 1;
}

/* Custom Markers */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    border: 2px solid white;
}

.van-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f59e0b;
    border: 3px solid white;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: van-pulse 2s ease-in-out infinite;
}

@keyframes van-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3); }
}

.custom-marker.visited {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.custom-marker.camping-card {
    border-color: #facc15;
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.custom-marker.camping-card.visited {
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.5), 0 0 0 6px rgba(34, 197, 94, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.custom-marker.not-on-card {
    border-style: dashed;
}

/* Cluster markers */
.marker-cluster {
    background: rgba(59, 130, 246, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster div {
    background: rgba(59, 130, 246, 0.8);
    border-radius: 50%;
    color: white;
    font-weight: bold;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster-small {
    width: 30px;
    height: 30px;
}

.marker-cluster-small div {
    width: 22px;
    height: 22px;
}

.marker-cluster-medium {
    width: 40px;
    height: 40px;
}

.marker-cluster-medium div {
    width: 30px;
    height: 30px;
}

.marker-cluster-large {
    width: 50px;
    height: 50px;
}

.marker-cluster-large div {
    width: 38px;
    height: 38px;
}

/* Legend */
.map-legend {
    position: absolute;
    bottom: 2rem;
    left: 1rem;
    z-index: 1000;
    background: white;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    font-size: 0.75rem;
}

.legend-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #1e293b;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.legend-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.legend-icon svg {
    width: 12px;
    height: 12px;
}

/* Loading overlay */
.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.map-loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile adjustments */
@media (max-width: 640px) {
    .filter-panel {
        max-width: calc(100% - 2rem);
    }

    .map-legend {
        display: none;
    }

    .map-controls {
        top: auto;
        bottom: 1rem;
    }
}

/* POI Side Panel */
.poi-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    background: white;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.poi-panel.open {
    transform: translateX(0);
}

.poi-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.poi-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
}

.poi-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #64748b;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poi-panel-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.poi-panel-body {
    overflow-y: auto;
    padding: 1.25rem;
    flex: 1;
}

.poi-panel-search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.poi-panel-search input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

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

.poi-panel-search button {
    white-space: nowrap;
}

.panel-search-results {
    display: none;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.panel-search-results.visible {
    display: block;
}

.panel-search-result {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

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

.panel-search-result:hover {
    background: #f1f5f9;
}

.panel-search-result .result-icon {
    color: #3b82f6;
    flex-shrink: 0;
    margin-top: 2px;
}

.poi-panel-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1001;
}

.poi-panel-overlay.visible {
    display: block;
}

.poi-panel .form-group {
    margin-bottom: 1rem;
}

.poi-panel .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
    display: block;
}

.poi-panel .form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

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

.poi-panel textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

.poi-panel select.form-control {
    appearance: auto;
}

.poi-panel .coord-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.poi-panel .coord-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.poi-panel .coord-row .btn {
    flex-shrink: 0;
    margin-bottom: 0;
}

.poi-panel .panel-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
}

.poi-panel .panel-actions .btn {
    flex: 1;
}

#poi-form-message {
    margin-bottom: 1rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    display: none;
}

#poi-form-message.success {
    display: block;
    background: #dcfce7;
    color: #166534;
}

#poi-form-message.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
}

@media (max-width: 640px) {
    .poi-panel {
        width: 100%;
    }

    .poi-panel-overlay.visible {
        display: block;
    }
}

/* Leaflet overrides */
.leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    overflow: hidden;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
}

.leaflet-popup-content .poi-popup {
    padding: 0.75rem;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    border-radius: 0.375rem !important;
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid #e2e8f0 !important;
}
