/* =========================================
   RICH MAP STYLING & CUSTOMIZATIONS
   ========================================= */

/* --- Custom Marker Animations --- */
.custom-marker {
    transition: transform 0.2s ease-out, stroke-width 0.2s ease-out;
    transform-origin: center;
    transform-box: fill-box;
}

.custom-marker:hover {
    transform: scale(1.2);
    stroke-width: 3px;
}

/* Neon Glow Effects */
.marker-status-P {
    filter: drop-shadow(0 0 4px #10b981);
}

.marker-status-A {
    filter: drop-shadow(0 0 4px #f59e0b);
}

.marker-status-C {
    filter: drop-shadow(0 0 4px #ef4444);
}

/* Enhanced Clustering */
.marker-cluster-small {
    background-color: rgba(16, 185, 129, 0.6) !important;
}

.marker-cluster-small div {
    background-color: rgba(16, 185, 129, 0.8) !important;
}

.marker-cluster-medium {
    background-color: rgba(245, 158, 11, 0.6) !important;
}

.marker-cluster-medium div {
    background-color: rgba(245, 158, 11, 0.8) !important;
}

.marker-cluster-large {
    background-color: rgba(239, 68, 68, 0.6) !important;
}

.marker-cluster-large div {
    background-color: rgba(239, 68, 68, 0.8) !important;
}

.marker-cluster div {
    color: white !important;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- Glassmorphic Popups (Light Theme) --- */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 0;
    overflow: hidden;
    color: #0f172a;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95);
}

.leaflet-popup-content {
    margin: 0;
    width: 280px !important;
    font-family: 'Inter', system-ui, sans-serif;
}

.popup-header {
    background: #f8fafc;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.popup-title {
    font-weight: 700;
    font-size: 14px;
    color: #0f172a;
    line-height: 1.3;
    margin-bottom: 2px;
}

.popup-subtitle {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.popup-body {
    padding: 16px;
    background: #ffffff;
}

.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.data-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.data-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.data-value {
    font-size: 12px;
    color: #334155;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.status-badge.status-P {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.status-badge.status-A {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.status-badge.status-C {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* --- Custom Map Controls --- */
.leaflet-bar {
    border: none !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-bar a {
    background-color: #ffffff !important;
    color: #475569 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-weight: bold;
    transition: all 0.2s;
}

.leaflet-bar a:hover {
    background-color: #f8fafc !important;
    color: #0ea5e9 !important;
}

.leaflet-bar a:first-child {
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
}

.leaflet-bar a:last-child {
    border-bottom-left-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    border-bottom: none !important;
}

.leaflet-control-layers {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    color: #475569 !important;
    font-family: 'Inter', sans-serif;
    padding: 6px !important;
}

.leaflet-control-layers-expanded {
    padding: 12px !important;
}

.leaflet-control-layers-selector {
    accent-color: #0ea5e9;
}

/* --- LEGEND & FILTER WIDGET (New) --- */
.map-legend {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    color: #334155;
    width: 160px;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s;
}

.map-legend.collapsed {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.map-legend.collapsed .legend-content,
.map-legend.collapsed .legend-header span {
    display: none;
}

.map-legend.collapsed .legend-header {
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none;
}

.legend-header {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.toggle-icon {
    transition: transform 0.3s ease;
    width: 16px;
    height: 16px;
}

.map-legend.collapsed .toggle-icon {
    transform: rotate(180deg);
    /* Or change based on icon design */
    width: 20px;
    height: 20px;
    color: #0ea5e9;
}

.legend-content {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.legend-item:hover {
    background: #f1f5f9;
}

.legend-item.disabled {
    opacity: 0.5;
    filter: grayscale(1);
    text-decoration: line-through;
}

.legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.dot.status-P {
    background: #10b981;
}

.dot.status-A {
    background: #f59e0b;
}

.dot.status-C {
    background: #ef4444;
}

.dot.status-O {
    background: #3b82f6;
}

/* --- Unobtrusive Tooltips --- */
.marker-tooltip-simple {
    background: rgba(15, 23, 42, 0.9);
    border: none;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: 'Inter', sans-serif;
    transform: translateY(-2px);
}

.marker-tooltip-simple::before {
    border-top-color: rgba(15, 23, 42, 0.9);
}