/**
 * WantsMap Leaflet Custom Styles
 * Mobile-first, dark theme styling for markers and clusters
 */

/* ===== Map Container ===== */
#wants-map-container {
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    z-index: 1;
}

/* Ensure markers and clusters render above MapLibre GL canvas (all map instances).
   MapLibre GL may ignore custom pane option; force tile pane (where GL renders) below markers. */
.leaflet-tile-pane {
    z-index: 1 !important;
}
.leaflet-marker-pane,
.leaflet-overlay-pane {
    z-index: 650 !important;
}

/* ===== Individual Markers ===== */
.wants-marker-container {
    background: transparent !important;
    border: none !important;
}

.wants-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-weight: 700;
    font-size: 11px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wants-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.wants-marker-small {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.wants-marker-medium {
    width: 30px;
    height: 30px;
    font-size: 11px;
}

.wants-marker-large {
    width: 36px;
    height: 36px;
    font-size: 12px;
}

/* ===== Cluster Icons ===== */
.marker-cluster {
    background: transparent !important;
}

.cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid #000000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.cluster-icon:hover {
    transform: scale(1.1);
}

/* Deep blue clusters with white text and black outline - distinct from Bad Address (red) */
.cluster-icon.cluster-small,
.marker-cluster-small .cluster-icon {
    width: 30px;
    height: 30px;
    font-size: 11px;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
}

.cluster-icon.cluster-medium,
.marker-cluster-medium .cluster-icon {
    width: 40px;
    height: 40px;
    font-size: 13px;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
}

.cluster-icon.cluster-large,
.marker-cluster-large .cluster-icon {
    width: 50px;
    height: 50px;
    font-size: 14px;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
}

/* ===== Popup Styles ===== */
.leaflet-popup-content-wrapper {
    background: #1a1a2e;
    border: 1px solid #2d3a5a;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-content {
    margin: 12px 14px;
    color: #e0e0e0;
}

.leaflet-popup-tip {
    background: #1a1a2e;
    border: 1px solid #2d3a5a;
    box-shadow: none;
}

.wants-popup {
    min-width: 180px;
}

.popup-address {
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
    margin-bottom: 6px;
    line-height: 1.3;
}

.popup-count {
    font-size: 12px;
    color: #60a5fa;
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2d3a5a;
}

/* Popup persons list - vertical scroll when multiple */
.popup-persons {
    margin-bottom: 10px;
    max-height: 140px;
    overflow-y: auto;
}

.popup-names {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.popup-person {
    padding: 6px 0;
    border-bottom: 1px dotted #2d3a5a;
}

.popup-person:last-child {
    border-bottom: none;
}

.popup-person-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.popup-person-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    border: 2px solid #3b82f6;
    background-color: #2d3a5a;
}

.popup-person-name {
    font-size: 12px;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

/* Charges - each want/incarceration on its own row, finger-scroll horizontally (no visible scrollbar) */
.popup-charges {
    margin-left: 40px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.popup-charge-row {
    min-width: 0;
}

.popup-charge-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar - finger scroll only */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.popup-charge-scroll::-webkit-scrollbar {
    display: none;
}

/* Catalog ID (e.g. TNSullivanSheriff) in goldenrod to offset from rest of charge data */
.popup-catalog-id {
    color: goldenrod;
    font-weight: 600;
}

.popup-charge-chip {
    display: inline-block;
    font-size: 10px;
    color: #a0aec0;
    background: rgba(45, 58, 90, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.popup-charge-incarceration {
    border-left: 2px solid #60a5fa;
}

/* Tip chip - matches wants list CardCopIXPersonTips (slate blue #2d4a6f) */
.popup-charge-tip {
    background-color: #2d4a6f !important;
    color: #e2e8f0 !important;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.25);
}

.popup-charge-tip .popup-tip-catalog {
    color: #93c5fd !important;
}

.popup-charge-tip .popup-tip-id {
    font-size: 0.9em;
    color: #cbd5e1 !important;
}

.popup-no-charges {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
}

/* Loading and error states */
.popup-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #a0aec0;
    padding: 8px 0;
}

.popup-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #3b82f6;
    border-top-color: transparent;
    border-radius: 50%;
    animation: popup-spin 0.8s linear infinite;
}

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

.popup-error,
.popup-empty {
    font-size: 12px;
    color: #6b7280;
    padding: 8px 0;
}

.popup-more {
    font-size: 11px;
    color: #6b7280;
    font-style: italic;
    padding-top: 4px;
}

.popup-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    /* Mobile touch target - minimum 44px */
    min-height: 44px;
}

.popup-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.popup-btn:active {
    transform: scale(0.98);
}

/* ===== Wants Map Page Layout ===== */
.wants-map-page {
    position: relative;
    min-height: calc(100dvh - 60px);
}

/* ===== Status Bar - upper right corner (Wants map only) ===== */
.wants-map-page .map-status-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    left: auto;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    font-size: 14px;
    border: 1px solid #2d3a5a;
    border-radius: 8px;
    min-height: 44px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.status-text {
    color: #4ade80;
}

.status-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fbbf24;
}

.status-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #fbbf24;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.status-count {
    color: #60a5fa;
    font-weight: 600;
}

/* ===== Control Buttons ===== */
.map-controls {
    position: absolute;
    top: 70px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid #2d3a5a;
    background: rgba(26, 26, 46, 0.95);
    color: #e0e0e0;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.map-control-btn:hover {
    background: rgba(45, 58, 90, 0.95);
}

.map-control-btn:active {
    transform: scale(0.95);
}

/* ===== Legend ===== */
.map-legend {
    position: absolute;
    bottom: 80px;
    right: 10px;
    background: rgba(26, 26, 46, 0.95);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #2d3a5a;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.legend-title {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: #a0aec0;
    font-size: 11px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-marker {
    border-radius: 50%;
    border: 2px solid #ffffff;
    flex-shrink: 0;
}

.legend-marker.small {
    width: 12px;
    height: 12px;
    background: #ef4444;
}

.legend-marker.medium {
    width: 16px;
    height: 16px;
    background: #f97316;
}

.legend-marker.large {
    width: 20px;
    height: 20px;
    background: #dc2626;
}

/* ===== Instructions ===== */
.map-instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(26, 26, 46, 0.95);
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid #2d3a5a;
    color: #a0aec0;
    font-size: 12px;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .wants-map-page .map-status-bar {
        padding: 8px 12px;
        font-size: 12px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .map-legend {
        bottom: 70px;
        right: 8px;
        padding: 10px 12px;
    }

    .legend-item {
        font-size: 10px;
    }

    .map-instructions {
        bottom: 15px;
        padding: 8px 16px;
        font-size: 11px;
        max-width: 80%;
    }

    .popup-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .map-controls {
        top: 60px;
        right: 8px;
    }

    /* Larger touch targets on mobile */
    .wants-marker-small {
        width: 28px;
        height: 28px;
    }

    .wants-marker-medium {
        width: 34px;
        height: 34px;
    }

    .wants-marker-large {
        width: 40px;
        height: 40px;
    }

    .cluster-small {
        width: 36px;
        height: 36px;
    }

    .cluster-medium {
        width: 46px;
        height: 46px;
    }

    .cluster-large {
        width: 56px;
        height: 56px;
    }
}

/* ===== Dark Mode Leaflet Overrides ===== */
.leaflet-control-zoom a {
    background: rgba(26, 26, 46, 0.95) !important;
    color: #e0e0e0 !important;
    border: 1px solid #2d3a5a !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(45, 58, 90, 0.95) !important;
}

.leaflet-control-attribution {
    background: transparent !important;
    color: #6b7280 !important;
}

.leaflet-control-attribution a {
    color: #60a5fa !important;
}

/* Outer cluster container transparent; inner .cluster-icon has gradient */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: transparent !important;
}
