/* ==========================================
   Map Specific Styles
   ========================================== */

/* Custom Marker Styles */
.custom-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: relative;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: var(--transition-fast);
}

.marker-pin:hover {
    transform: rotate(-45deg) scale(1.1);
}

.marker-pulse {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    position: absolute;
    opacity: 0.3;
    animation: pulse-marker 2s infinite;
}

@keyframes pulse-marker {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 0;
    }
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
}

/* Custom Cluster Styles */
.custom-cluster {
    background-clip: padding-box;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.custom-cluster div {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cluster-small {
    font-size: 12px;
}

.cluster-medium {
    font-size: 14px;
}

.cluster-large {
    font-size: 16px;
}

/* Custom Popup Styles */
.custom-popup .leaflet-popup-content-wrapper {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    padding: 0;
    overflow: hidden;
    min-width: 320px;
    max-width: 420px;
}

.custom-popup .leaflet-popup-tip {
    background: var(--bg-primary);
}

.popup-content {
    padding: var(--spacing-md);
    max-width: 100%;
}

/* Ensure Leaflet popup allows internal scrolling */
.leaflet-popup-content {
    overflow: visible !important;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.popup-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.provider-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.provider-badge.converge {
    background: var(--converge-primary);
}

.provider-badge.globe {
    background: var(--globe-primary);
}

.popup-body {
    font-size: 0.875rem;
}

.popup-row {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.popup-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
}

.popup-value {
    color: var(--text-primary);
    flex: 1;
}

/* Popup Link Styles */
.popup-link {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
    transition: text-decoration 0.2s ease;
}

.popup-link:hover {
    text-decoration: underline;
}

/* Full Text Row */
.popup-fulltext .popup-value {
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.4;
    padding-right: var(--spacing-xs);
}

.popup-fulltext {
    flex-direction: column;
    gap: var(--spacing-xs);
}

.popup-fulltext .popup-label {
    margin-bottom: var(--spacing-xs);
}

/* Comment Field Styles */
.popup-row.comment-row {
    flex-direction: column;
    margin-bottom: var(--spacing-sm);
}

.popup-row.comment-row .popup-label {
    margin-bottom: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.popup-row.comment-row .comment-text {
    height: calc(0.875rem * 1.5 * 10); /* Exactly 10 lines: font-size * line-height * lines */
    max-height: calc(0.875rem * 1.5 * 10);
    overflow-y: auto !important; /* Force scrollbar when needed */
    overflow-x: hidden;
    padding: var(--spacing-sm);
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    line-height: 1.5;
    font-size: 0.875rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    display: block;
    position: relative;
    box-sizing: border-box;
}

/* Custom scrollbar for comment text - more visible */
.comment-text::-webkit-scrollbar {
    width: 8px;
    display: block !important;
}

.comment-text::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.comment-text::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    min-height: 30px;
}

.comment-text::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Force scrollbar to always show on comment text */
.comment-text {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(0, 0, 0, 0.3) rgba(0, 0, 0, 0.1); /* Firefox */
}

/* Choropleth Popup */
.choropleth-popup {
    padding: var(--spacing-md);
}

.choropleth-popup h4 {
    margin: 0 0 var(--spacing-sm) 0;
    color: var(--text-primary);
}

.choropleth-popup p {
    margin: 0;
    color: var(--text-secondary);
}

.choropleth-popup strong {
    color: var(--text-primary);
    font-size: 1.25rem;
}

/* Map Controls Override */
.leaflet-control-zoom {
    display: none; /* Hide default zoom controls */
}

.leaflet-control-attribution {
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(10px);
    padding: 2px 5px;
    font-size: 10px;
    color: #E5E7EB;
}

.dashboard[data-theme="light"] .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8);
    color: #111827;
}

/* Map Loading State */
.map-zooming {
    cursor: zoom-in;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .custom-popup .leaflet-popup-content-wrapper {
        max-width: 250px;
    }
    
    .popup-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
}
