/* Interactive Plots Map CSS - MapLibre GL JS Version */

/* Map container */
.interactive-plots-map {
    width: 100%;
    height: 500px;
    margin-bottom: 20px;
    background-color: #000;
   
    overflow: hidden;
  
}

/* MapLibre canvas - ensure proper rendering */
.maplibregl-canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.maplibregl-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Ensure proper map control styling */
.maplibregl-ctrl-top-right {
    top: 10px;
    right: 10px;
}

/* Plot label styling - used for our custom markers */
.plot-label {
    background: rgba(211, 47, 47, 0.95); /* Default fallback color */
    padding: 0.3em;
    border-radius: 50%;
    border: 2px solid #d32f2f; /* Slightly thicker border */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); /* Enhanced shadow for better visibility */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    color: white; /* Default to white text */
    width: 30px;
    height: 30px;
    /* Ensure the label stays crisp when moving */
    transform: translate(-50%, -50%);
    will-change: transform;
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); /* Better text visibility */
}

/* Enhanced plot label marker styling with fluid typography */
.plot-label-marker {
    /* Override base styles for our custom markers */
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 50%;
    border: 2px solid white;
    font-weight: bold;
    font-family: 'Arial', sans-serif;
    color: white;
    line-height: 1;
    box-sizing: border-box;
    
    /* Enhanced shadow for better visibility */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    
    /* Smooth transitions for zoom changes */
    transition: font-size 0.3s ease, width 0.3s ease, height 0.3s ease, border-width 0.3s ease;
    
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    
    /* Better text rendering */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* Ensure crisp rendering during zoom */
    will-change: font-size, width, height;
    
    /* Prevent pointer events to avoid interference */
    pointer-events: none;
}

/* Enhanced plot label for highlighted plots */
.plot-label.highlighted {
    background: rgba(255, 255, 255, 0.95); /* White background when highlighted */
    color: #333; /* Dark text when highlighted for contrast */
    border-color: #333; /* Dark border when highlighted */
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 1000;
    text-shadow: none; /* Remove text shadow for dark text */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); /* Stronger shadow when highlighted */
}

/* Map loading state */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    font-weight: 600;
    color: #333;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Map no data message */
.map-no-data {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    color: #666;
    max-width: 250px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Popup styling */
.maplibregl-popup-content {
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 320px;
    background: white;
}

/* Fix popup triangle/tip positioning */
.maplibregl-popup-tip {
    width: 0;
    height: 0;
    border: 10px solid transparent;
    pointer-events: none;
}

/* Popup pointing down (triangle at top) */
.maplibregl-popup-anchor-top .maplibregl-popup-tip {
    border-bottom-color: white;
    border-top: none;
}

/* Popup pointing up (triangle at bottom) */
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
    border-top-color: white;
    border-bottom: none;
}

/* Popup pointing right (triangle at left) */
.maplibregl-popup-anchor-left .maplibregl-popup-tip {
    border-right-color: white;
    border-left: none;
}

/* Popup pointing left (triangle at right) */
.maplibregl-popup-anchor-right .maplibregl-popup-tip {
    border-left-color: white;
    border-right: none;
}

/* Ensure proper popup positioning */
.maplibregl-popup {
    pointer-events: none;
}

.maplibregl-popup-content {
    pointer-events: auto;
    position: relative;
}

.maplibregl-popup-close-button {
    font-size: 18px;
    padding: 0 6px;
    background: #f8f9fa;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 1;
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
    border: none;
    color: #666;
}

/* Make sure popup content has proper styling */
.maplibregl-popup-content h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.maplibregl-popup-content p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.4;
    color: #666;
}

.maplibregl-popup-content .popup-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.maplibregl-popup-content .btn {
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.maplibregl-popup-content .btn-primary {
    background: #667eea;
    color: white;
}

.maplibregl-popup-content .btn-primary:hover {
    background: #5a67d8;
}

.maplibregl-popup-content .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.maplibregl-popup-content .btn-secondary:hover {
    background: #cbd5e0;
}

/* Single plot page specific styles */
.single-plot .plot-map-container .interactive-plots-map {
    height: 400px;
}

/* Zoom control styling improvements */
.maplibregl-ctrl-zoom {
    border-radius: 6px;
    overflow: hidden;
}

.maplibregl-ctrl-zoom button {
    background: rgba(255, 255, 255, 0.9);
    transition: background-color 0.2s ease;
}

.maplibregl-ctrl-zoom button:hover {
    background: rgba(255, 255, 255, 1);
}

/* Attribution styling */
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    border-radius: 4px;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .interactive-plots-map {
        height: 350px;
    }
    
    .single-plot .plot-map-container .interactive-plots-map {
        height: 300px;
    }
    
    .plot-label {
        font-size: 12px;
        width: 26px;
        height: 26px;
    }
    
    .maplibregl-popup-content {
        max-width: 280px;
        padding: 12px;
    }
}

/* Animation for plot highlighting */
@keyframes plotHighlight {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.plot-label.highlighted {
    animation: plotHighlight 0.6s ease-out;
}

/* Plot Legend Styling */
.plot-legend {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 12px;
    margin: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 180px;
}

.legend-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

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

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

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.legend-text {
    font-size: 12px;
    color: #555;
    line-height: 1.3;
    font-weight: 500;
}

/* Responsive legend */
@media (max-width: 768px) {
    .plot-legend {
        min-width: 160px;
        padding: 10px;
        margin: 8px;
    }
    
    .legend-title {
        font-size: 13px;
    }
    
    .legend-text {
        font-size: 11px;
    }
    
    .legend-color {
        width: 14px;
        height: 14px;
    }
}

/* Road Labels Styling */
.road-label {
    background: rgba(25, 118, 210, 0.9) !important;
    color: white !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25) !important;
    backdrop-filter: blur(4px) !important;
    border: 1px solid rgba(25, 118, 210, 0.2) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease !important;
}

.road-label:hover {
    background: rgba(25, 118, 210, 1) !important;
    transform: scale(1.05) !important;
}

/* Road lines styling enhancements via maplibre paint properties are handled in JS */

/* Responsive road labels */
@media (max-width: 768px) {
    .road-label {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
}

/* Location Markers Styling (like Tanques, San Jorge) */
.location-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    z-index: 10;
}

.location-pin {
    width: 12px;
    height: 12px;
    background: #d32f2f;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
}

.location-label {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(2px);
    min-width: 60px;
    text-align: center;
}

.location-marker:hover .location-pin {
    transform: scale(1.2);
    transition: transform 0.2s ease;
}

.location-marker:hover .location-label {
    background: rgba(0, 0, 0, 0.9);
    transition: background 0.2s ease;
}

/* Responsive location markers */
@media (max-width: 768px) {
    .location-pin {
        width: 10px;
        height: 10px;
    }
    
    .location-label {
        font-size: 11px;
        padding: 3px 6px;
        min-width: 50px;
    }
}

/* Enhanced Section Filter Above Map - Clean & Minimalistic */
.section-filter-above-map {


   
    margin-bottom: 20px;
   
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;

}

.enhanced-filter-title {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 21px;
    color: #172B45;
    margin-bottom: 8px;
    text-align: center;
}

.filter-tagline {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 21px;
    font-weight: 300;
    color: #172B45;
    margin-bottom: 24px;
    text-align: center;
}

.filter-description {
    display: none;
}

.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

/* Custom Dropdown Styling */
.custom-dropdown {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.custom-dropdown-trigger {
    width: 100%;
    padding: 8px 20px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #D9D9D9;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: #172B45;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 20px;
    text-align: center;
}

.custom-dropdown-trigger:hover {
    border-color: #9ca3af;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.custom-dropdown-trigger:focus,
.custom-dropdown.open .custom-dropdown-trigger {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-dropdown-trigger.placeholder {
    color: #9ca3af;
    font-style: italic;
}

.custom-dropdown-arrow {
    display: none;
}

.custom-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
}

.custom-dropdown-option {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 400;
    color: #374151;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.custom-dropdown-option:last-child {
    border-bottom: none;
}

.custom-dropdown-option:hover {
    background: #f9fafb;
}

.custom-dropdown-option.selected {
    background: #3b82f6;
    color: white;
    font-weight: 500;
}

.custom-dropdown-option.selected:hover {
    background: #2563eb;
}

.filter-stats {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    color: #999;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* Current selection indicator - centered and no icon */
.current-filter-indicator {
    margin-top: 15px;
    padding: 12px;
    background: #eef2ff;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #4338ca;
    text-align: center;
}

.section-filter-above-map .legend-content {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
    padding-top: 0;
    border-top: none;
}

.section-filter-above-map .legend-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #172B45;
    text-align: left;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    flex: 1;
    transition: all 0.3s ease;
    opacity: 1;
}

.section-filter-above-map .legend-item:hover {
    background: rgba(23, 43, 69, 0.05);
}

.section-filter-above-map .legend-item-dimmed {
    opacity: 0.3;
    filter: grayscale(50%);
}

.section-filter-above-map .legend-icon {
    width: 40px;
    height: 36px;
    flex-shrink: 0;
}

.section-filter-above-map .legend-text-container {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.section-filter-above-map .legend-text {
    font-weight: 500;
    color: #172B45;
    font-size: 14px;
    margin: 0;
}

.section-filter-above-map .legend-code {
    font-size: 21px;
    color: #172B45;
    font-weight: 500;
    margin: 0;
}

.section-filter-above-map .legend-color {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .section-filter-above-map {
        
        margin-bottom: 16px;
     
    }

    .enhanced-filter-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .filter-tagline {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .filter-controls {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .custom-dropdown {
        max-width: 100%;
    }

    .custom-dropdown-trigger {
        padding: 14px 16px;
        font-size: 15px;
    }

    .custom-dropdown-option {
        padding: 12px 16px;
    }

    .filter-label {
        display: none;
    }

    .current-filter-indicator {
        font-size: 13px;
        padding: 10px 12px;
        max-width: 100%;
    }

    .section-filter-above-map .legend-content {
        gap: 12px;
        margin-top: 20px;
        flex-direction: column;
    }

    .section-filter-above-map .legend-item {
        padding: 10px;
        font-size: 13px;
        flex: 1;
        min-width: 100px;
    }

    .section-filter-above-map .legend-icon {
        width: 32px;
        height: 29px;
    }
}

/* Legend Below Map */
.legend-below-map {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 12px;
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.legend-below-map .legend-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.legend-below-map .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.section-filter-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.section-filter select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.section-filter select:hover {
    border-color: #4a8bfc;
}

.section-filter select:focus {
    outline: none;
    border-color: #4a8bfc;
    box-shadow: 0 0 0 2px rgba(74, 139, 252, 0.2);
}

/* Responsive section filter */
@media (max-width: 768px) {
    .section-filter {
        min-width: 180px;
        max-width: 200px;
        padding: 10px;
        margin: 8px;
    }
    
    .section-filter-above-map {
        max-width: 100%;
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .legend-below-map {
        padding: 10px;
        margin-top: 10px;
    }
    
    .legend-below-map .legend-content {
        gap: 10px;
    }
    
    .section-filter-title {
        font-size: 13px;
    }
    
    .section-filter select {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* Enhanced directional roads styling */
.maplibregl-popup-content .road-info {
  margin: 10px 0;
  padding: 8px;
  background: rgba(25, 118, 210, 0.1);
  border-left: 3px solid #1976d2;
  border-radius: 4px;
}

.maplibregl-popup-content .road-destination {
  font-weight: bold;
  color: #1976d2;
  margin-bottom: 5px;
}

.maplibregl-popup-content .road-direction {
  font-size: 12px;
  color: #666;
  font-style: italic;
}

/* Road overlay enhancements */
.maplibregl-canvas-container .maplibregl-map {
  font-feature-settings: "liga" off; /* Improve text rendering */
}

/* Custom road markers - legacy fallback */
.custom-road-marker {
  background: linear-gradient(45deg, #1976d2, #42a5f5);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(25, 118, 210, 0.4);
  border: 2px solid white;
  position: relative;
}

.custom-road-marker::before {
  content: "▶";
  margin-right: 6px;
  font-size: 14px;
}

.custom-road-marker:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.6);
}

@media (max-width: 768px) {
  .custom-road-marker {
    font-size: 10px;
    padding: 4px 8px;
  }
  
  .custom-road-marker::before {
    font-size: 12px;
  }
}

/* Legacy Section Filter Styling (for control version) */
.section-filter {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    padding: 12px;
    margin: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 200px;
    max-width: 250px;
}

/* Legacy filter styles */
.section-filter-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.section-filter select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.section-filter select:hover {
    border-color: #4a8bfc;
}

.section-filter select:focus {
    outline: none;
    border-color: #4a8bfc;
    box-shadow: 0 0 0 2px rgba(74, 139, 252, 0.2);
}
