/* BitBeam Maps — OpenStreetMap property intelligence */

.bitbeam-map-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.bb-map-canvas {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ─── Interaction mode overlay (Google Maps style) ────────────── */
/* When inactive: wheel scrolls page, show "click to interact"    */
/* When active: wheel zooms map, overlay hidden                   */
/* Ctrl/Cmd+wheel always zooms regardless of mode                 */

.bb-map-inactive {
    cursor: pointer;
}

.bb-map-inactive::after {
    content: "Klik om te interageren · Ctrl+scroll om te zoomen";
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.3s;
}

.bb-map-inactive.leaflet-grab {
    cursor: pointer;
}

.bb-map-active::after {
    display: none;
}

.bb-map-active {
    cursor: grab;
}

.bb-map-active.leaflet-drag-target {
    cursor: grabbing;
}

/* ─── Empty / Error states ────────────────────────────────────── */

.bb-map-empty,
.bb-map-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #666;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 999;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.bb-map-error {
    color: #DC2626;
}

.bb-map-empty.hidden,
.bb-map-error.hidden {
    display: none;
}

/* ─── Loading overlay ─────────────────────────────────────────── */

.bb-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.bb-map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.bb-map-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: bb-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.bb-map-loading p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* ─── Filter sidebar ──────────────────────────────────────────── */

.bb-map-filters {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 500;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    width: 260px;
    max-height: calc(100% - 20px);
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.bb-map-filters.collapsed {
    transform: translateX(-270px);
}

.bb-map-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.bb-map-filters-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.bb-map-filters-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.bb-map-filters-toggle:hover {
    background: #f0f0f0;
}

.bb-map-filters-body {
    padding: 12px 16px;
}

.bb-filter-group {
    margin-bottom: 14px;
}

.bb-filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bb-filter-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.bb-filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.bb-filter-checkbox {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.bb-filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.bb-filter-apply {
    width: 100%;
    padding: 10px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.bb-filter-apply:hover {
    background: #5558e3;
}

.bb-filter-apply:active {
    background: #4f46e5;
}

/* ─── Stats bar ───────────────────────────────────────────────── */

.bb-map-stats {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 500;
    background: white;
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    color: #555;
}

.bb-map-stat-count {
    font-weight: 700;
    color: #6366f1;
}

.bb-map-stats::after {
    content: '';
    display: inline-block;
    width: 0;
    margin-left: 0;
    overflow: hidden;
    vertical-align: middle;
    transition: width 160ms ease, margin-left 160ms ease;
}

.bb-map-stats.bb-map-refreshing::after {
    content: 'Bijwerken\2026';
    width: 5.4rem;
    margin-left: 0.5rem;
    color: #64748b;
}

/* ─── Marker styles ───────────────────────────────────────────── */

/* Custom marker icons are created in JS via L.divIcon */
.bb-marker {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

.bb-marker-inner {
    transform: rotate(45deg);
    font-size: 11px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
}

.bb-marker-low { background: #10b981; }
.bb-marker-mid { background: #f59e0b; }
.bb-marker-high { background: #ef4444; }
.bb-marker-luxury { background: #8b5cf6; }
.bb-marker-unknown { background: #6b7280; }

/* ─── Popup styles ────────────────────────────────────────────── */

.leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: 280px !important;
}

.bb-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.bb-popup-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.bb-popup-image-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6366f1;
    font-size: 14px;
}

.bb-popup-body {
    padding: 12px 14px;
}

.bb-popup-price {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 4px 0;
}

.bb-popup-address {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 8px 0;
}

.bb-popup-details {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.bb-popup-detail {
    font-size: 12px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bb-popup-detail strong {
    color: #1f2937;
}

.bb-popup-energy {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
}

.bb-popup-energy-A { background: #10b981; }
.bb-popup-energy-B { background: #84cc16; }
.bb-popup-energy-C { background: #eab308; }
.bb-popup-energy-D { background: #f59e0b; }
.bb-popup-energy-E { background: #f97316; }
.bb-popup-energy-F { background: #ef4444; }
.bb-popup-energy-G { background: #dc2626; }

.bb-popup-link {
    display: block;
    margin-top: 8px;
    padding: 8px 12px;
    background: #6366f1;
    color: white !important;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.bb-popup-link:hover {
    background: #5558e3;
}

/* ─── Cluster styles ──────────────────────────────────────────── */

.marker-cluster-small {
    background-color: rgba(99, 102, 241, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(99, 102, 241, 0.8);
}

.marker-cluster-medium {
    background-color: rgba(139, 92, 246, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(139, 92, 246, 0.8);
}

.marker-cluster-large {
    background-color: rgba(217, 70, 239, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(217, 70, 239, 0.8);
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
    color: white;
}

.marker-cluster span {
    line-height: 30px;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .bb-map-filters {
        width: calc(100% - 20px);
        max-height: 50%;
    }

    .bb-map-filters.collapsed {
        transform: translateY(-110%);
    }

    .bb-map-filters-toggle {
        transform: rotate(90deg);
    }

    .leaflet-popup-content {
        width: 240px !important;
    }
}
