/* Activity Heatmap Styles */

/* Ensure heatmap spans full width and doesn't overlap */
#activity-heatmap-container {
    width: 100%;
    margin: 0 0 50px 0;  /* Increased bottom margin */
    position: static;     
    display: block;
    clear: both;
    border: 2px solid #e1e5e9;  /* More visible border */
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);  /* Stronger shadow */
}

#activity-heatmap-container.span-two-columns {
    grid-column: 1 / -1;  /* Span full width of grid */
}

/* Remove all conflicting CSS - let the simple heatmap work */

.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;  /* Smaller padding */
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border-bottom: 2px solid #34495e;
    margin-bottom: 0;
}

.heatmap-header h3 {
    margin: 0;
    font-size: 1.1em;  /* Smaller font */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.heatmap-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.species-filter {
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    min-width: 150px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.species-filter:focus {
    outline: none;
    border-color: #3498db;
    background: rgba(255,255,255,0.2);
}

.species-filter option {
    background: #2c3e50;
    color: white;
}

.refresh-btn {
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.refresh-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.map-container {
    flex: 1;
    width: 100%;
    position: relative;
    min-height: 300px;
    max-height: 350px;  /* Prevent excessive height */
}

#heatmap-map {
    height: 100%;
    width: 100%;
    background: #f8f9fa;
    position: relative;
}

/* Hide Leaflet attribution and zoom controls clutter */
#heatmap-map .leaflet-control-attribution {
    display: none !important;
}

#heatmap-map .leaflet-control-zoom {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;  /* Lower z-index to avoid conflicts */
}

/* Clean up any bottom-right elements */
#heatmap-map .leaflet-bottom.leaflet-right {
    display: none !important;
}

/* Ensure proper dashboard integration */
.dashboard-grid #activity-heatmap-container {
    grid-column: 1 / -1;  /* Full width */
    margin: 0 0 30px 0;   /* Clear margins */
}

/* Remove any conflicting positioning */
.activity-heatmap-container {
    position: static !important;
}

/* Ensure the charts below have proper spacing */
.dashboard-grid > .chart-container:not(#activity-heatmap-container) {
    margin-top: 20px;
}

/* Make sure species and timeline charts don't move up */
.charts-section,
.charts-column,
.chart-card {
    position: relative;
    clear: both;
}

/* Override any dashboard chart-container positioning for heatmap */
#activity-heatmap-container.chart-container {
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    float: none !important;
    display: block !important;
    width: 100% !important;
}

.heatmap-legend {
    padding: 15px 25px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.legend-title {
    font-weight: 600;
    color: #2c3e50;
    margin-right: 10px;
}

.legend-items {
    display: flex;
    gap: 20px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

.legend-color {
    width: 30px;
    height: 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
    display: block;
}

.heatmap-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.heatmap-loading {
    text-align: center;
    padding: 40px;
    background: rgba(255,255,255,0.9);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.heatmap-error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    margin: 20px;
    border-radius: 8px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Location popup styles */
.location-popup {
    min-width: 200px;
}

.location-popup h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.popup-stats {
    margin-bottom: 10px;
}

.popup-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.popup-stat .stat-label {
    font-weight: 600;
    color: #555;
}

.popup-stat .stat-value {
    color: #2c3e50;
    font-weight: 500;
}

.popup-description {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.popup-description .stat-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    display: block;
}

.popup-description p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Span two columns in dashboard grid */
.chart-container.span-two-columns {
    grid-column: span 2;
}

/* Responsive styles */
@media (max-width: 768px) {
    .heatmap-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .heatmap-controls {
        width: 100%;
        justify-content: center;
    }
    
    .species-filter {
        min-width: 200px;
    }
    
    .map-container {
        height: 300px;
    }
    
    .heatmap-legend {
        flex-direction: column;
        gap: 15px;
    }
    
    .legend-items {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .heatmap-stats {
        flex-direction: column;
        gap: 20px;
    }
    
    .stat-item {
        padding-bottom: 15px;
        border-bottom: 1px solid #dee2e6;
    }
    
    .stat-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

@media (max-width: 480px) {
    .heatmap-header h3 {
        font-size: 1.1em;
    }
    
    .map-container {
        height: 250px;
    }
    
    .legend-items {
        flex-direction: column;
        gap: 10px;
    }
    
    .species-filter {
        min-width: 150px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .heatmap-container {
        border: 2px solid #000;
    }
    
    .heatmap-header {
        background: #000;
        color: #fff;
    }
    
    .legend-color {
        border: 2px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .heatmap-container {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .heatmap-stats,
    .heatmap-legend {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
    
    .stat-value {
        color: #fff;
    }
    
    .stat-label,
    .legend-title {
        color: #ccc;
    }
    
    .location-popup h4 {
        color: #fff;
    }
    
    .popup-stat .stat-label,
    .popup-description .stat-label {
        color: #ccc;
    }
    
    .popup-stat .stat-value {
        color: #fff;
    }
}

/* Heatmap Section - Completely separate from dashboard grid */
.heatmap-section {
    width: 100%;
    margin: 20px 0 30px 0;
    padding: 0;
    position: relative;
    z-index: 10;
}

/* Heatmap container - clean and simple */
#activity-heatmap-container {
    width: 100%;
    height: 350px;
    min-height: 350px;
    max-height: 350px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e1e5e9;
    overflow: hidden;
    position: relative;
}

/* Dashboard grid adjustment */
.dashboard-grid {
    margin-top: 0 !important;
    clear: both;
}

/* Spinner animation for loading state */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ensure heatmap map fills container */
#heatmap-map {
    width: 100% !important;
    height: 100% !important;
}

/* ===== PROFESSIONAL POPUP STYLING ===== */

/* Leaflet popup container */
.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    background: #ffffff !important;
    min-width: 260px !important;
}

/* Popup content */
.leaflet-popup-content {
    margin: 0 !important;
    padding: 16px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* Location popup container */
.location-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Popup title */
.location-popup h4 {
    margin: 0 0 12px 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1a202c !important;
    letter-spacing: -0.2px !important;
}

/* Stats container */
.popup-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Individual stat row */
.popup-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Stat labels */
.popup-stat .stat-label {
    font-size: 11px !important;
    color: #718096 !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stat values */
.popup-stat .stat-value {
    font-size: 14px !important;
    color: #2d3748 !important;
    font-weight: 500 !important;
}

/* Clickable activity count */
.clickable-count {
    cursor: pointer !important;
    color: #667eea !important;
    font-weight: 600 !important;
    font-size: 20px !important;
    transition: all 0.2s ease !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    background: rgba(102, 126, 234, 0.1) !important;
}

.clickable-count:hover {
    background: rgba(102, 126, 234, 0.2) !important;
    transform: scale(1.05) !important;
}

/* Popup footer */
.popup-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
    font-size: 11px;
    color: #718096;
    text-align: center;
    font-weight: 400;
}

/* Popup arrow (tip) */
.leaflet-popup-tip-container {
    display: none !important; /* Clean look without arrow */
}

/* Alternative: Style the arrow if you want to keep it */
.leaflet-popup-tip {
    background: #ffffff !important;
}

/* Close button */
.leaflet-popup-close-button {
    color: #718096 !important;
    font-size: 20px !important;
    font-weight: 300 !important;
    padding: 4px 8px !important;
    transition: color 0.2s ease !important;
}

.leaflet-popup-close-button:hover {
    color: #1a202c !important;
    background: transparent !important;
}

/* Leaflet map specific fixes */
#heatmap-map .leaflet-container {
    width: 100%;
    height: 100%;
}