/* BMU Map specific styles */

.map-container {
  height: 700px;
  width: 100%;
  border-radius: 15px;
  overflow: hidden;
}

#map, #substation-map, #embedded-map-container {
  height: 100%;
  width: 100%;
}

/* Layer control styling */
.layer-control {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.layer-button {
  font-size: 14px;
  padding: 8px 15px;
  border-radius: 20px;
}

.layer-button.active {
  background: rgba(48, 162, 255, 0.9);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Legend styles */
.map-legend {
  background: rgba(44, 62, 80, 0.85);
  backdrop-filter: blur(var(--blur-intensity));
  -webkit-backdrop-filter: blur(var(--blur-intensity));
  color: white;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 250px;
  max-height: 400px;
  overflow-y: auto;
}

.legend-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.legend-color {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  margin-right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Interconnector Flow Map styles */
.legend-flow-arrow {
  width: 40px;
  height: 6px;
  margin-right: 10px;
  position: relative;
  border-radius: 3px;
}

.legend-flow-arrow.import {
  background-color: #4CAF50;
  border-top: none;
}

.legend-flow-arrow.export {
  background-color: #30a2ff;
  border-top: none;
}

.flow-label {
  background-color: transparent !important;
  border: none !important;
}

.flow-value {
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.flow-value.import {
  background-color: rgba(76, 175, 80, 0.9);
  color: white;
}

.flow-value.export {
  background-color: rgba(48, 162, 255, 0.9);
  color: white;
}

.import-flow {
  color: #4CAF50;
}

.export-flow {
  color: #30a2ff;
}

/* Map theme toggle */
.map-theme-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.toggle-label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  margin: 0 10px;
}

.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.type-group {
  margin-bottom: 15px;
}

.type-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Marker clusters */
.marker-cluster {
  background: rgba(48, 162, 255, 0.7) !important;
  border: 3px solid white !important;
  border-radius: 50% !important;
  box-shadow: 0 0 10px rgba(0,0,0,0.3) !important;
}

.marker-cluster div {
  background: transparent !important;
  width: calc(100% - 10px) !important;
  height: calc(100% - 10px) !important;
  margin: 5px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: bold !important;
  font-size: 16px !important;
  color: white !important;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  background: rgba(44, 62, 80, 0.95);
  color: white;
  backdrop-filter: blur(var(--blur-intensity));
}

.leaflet-popup-content {
  margin: 15px;
}

.leaflet-popup-tip {
  background: rgba(44, 62, 80, 0.95);
}

/* Substation tooltip specific styling - for mouseover */
.substation-tooltip-container {
  background: white;
  color: #333;
  border: 2px solid #FF5722;
  border-radius: 5px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
  padding: 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  pointer-events: none; /* Allow mouse events to pass through */
}

.substation-tooltip-container .leaflet-tooltip-content {
  min-width: 200px;
  margin: 0;
  padding: 10px;
}

/* Dark tooltip style to match BMU map */
.dark-tooltip {
  background: rgba(33, 33, 33, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
  padding: 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  pointer-events: none;
}

.dark-tooltip .popup-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: #FF5722;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 5px;
}

.dark-tooltip .popup-content {
  padding: 0;
}

.dark-tooltip .popup-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.dark-tooltip .popup-label {
  font-weight: 500;
  margin-right: 10px;
  color: rgba(255, 255, 255, 0.7);
}

.dark-tooltip .popup-value {
  font-weight: 600;
  color: #fff;
}

.substation-tooltip h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #FF5722;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
}

.substation-tooltip p {
  margin: 5px 0;
  line-height: 1.4;
}

/* Override Leaflet's default tooltip arrow */
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  border-color: #FF5722 !important;
}

/* Add highlighting for polygons on hover */
.substation-polygon:hover {
  cursor: pointer;
}

.popup-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  color: #30a2ff;
}

.popup-content {
  font-size: 14px;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  align-items: center;
}

.popup-label {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.popup-value {
  color: white;
}

/* Responsive styles */
@media (max-width: 768px) {
  .map-container {
    height: 500px;
  }
  
  .layer-control {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-panel {
    grid-template-columns: repeat(1, 1fr);
  }
}

/* Compact Control Panel - Applied across all pages */
.compact-controls {
  padding: 10px 15px !important;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  min-height: 105px;
}

.compact-header {
  padding: 0 0 10px 0 !important;
  margin-bottom: 10px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.compact-header h3 {
  font-size: 18px !important;
  margin: 0 !important;
}

.controls-flex-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.compact-group {
  flex: 1;
  min-width: 150px;
  margin-bottom: 0;
}

.compact-group label {
  font-size: 14px;
  display: block;
  margin-bottom: 5px;
}

.compact-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 8px;
}

.compact-slider {
  margin-top: 5px;
}

.compact-slider input[type="range"] {
  width: 100%;
  margin: 0;
}

.period-display {
  font-size: 13px;
  margin-top: 5px;
}

.period-control {
  flex: 2;
}

.compact-button {
  padding: 8px 15px !important;
  font-size: 14px !important;
  height: 38px !important;
  border-radius: 8px !important;
  min-width: 120px !important;
  margin-top: 22px !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.compact-group .type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.compact-group .layer-button {
  font-size: 12px;
  padding: 4px 8px;
}

.compact-group .toggle-buttons {
  display: flex;
}

.compact-group .toggle-button {
  flex: 1;
  text-align: center;
}

@media (max-width: 768px) {
  .controls-flex-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .compact-group, .compact-button {
    width: 100%;
    min-width: 100%;
  }
  
  .compact-group .type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    flex-direction: row;
  }
  
  .compact-group .layer-button {
    font-size: 11px;
    padding: 3px 5px;
    display: flex;
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .compact-group .type-selector {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .compact-group .layer-button {
    font-size: 10px;
    padding: 2px 3px;
  }
}

/* Realtime indicator and button styling */
.card-header .realtime-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4CAF50;
  margin-left: auto;
  padding: 4px 8px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 4px;
}

/* Realtime button active styling is handled in main.css */

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* Fuel Mix Chart Styles */
.fuel-mix-container {
  min-height: 400px;
  height: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.6s ease forwards;
  animation-delay: 0.25s;
}

#fuelMixChartDiv {
  width: 100%;
  flex: 1;
  min-height: 350px;
  padding: 10px;
  position: relative;
}

.fuel-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  padding-bottom: 10px;
}

.fuel-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 6px 12px;
  border-radius: 20px;
  color: white;
  font-size: 13px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.fuel-legend-item:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.fuel-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 6px;
}

/* No data message */
.no-data-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding: 20px;
}

.no-data-icon {
  margin-bottom: 15px;
  opacity: 0.7;
}

/* Compact legend below map */
.map-legend-compact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
  padding: 10px;
  background: rgba(44, 62, 80, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-item-compact {
  display: flex;
  align-items: center;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.legend-item-compact .legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 5px;
}

/* Style for flow arrows in compact legend */
.legend-item-compact .legend-flow-arrow {
  width: 30px;
  height: 5px;
  margin-right: 8px;
  position: relative;
}

.legend-item-compact .legend-flow-arrow:before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.legend-item-compact .legend-flow-arrow.import {
  background-color: #4CAF50;
  border-top: none;
}

.legend-item-compact .legend-flow-arrow.import:before {
  display: none;
}

.legend-item-compact .legend-flow-arrow.export {
  background-color: #30a2ff;
  border-top: none;
}

.legend-item-compact .legend-flow-arrow.export:before {
  display: none;
}

@media (max-width: 768px) {
  .map-legend-compact {
    padding: 5px;
    gap: 5px;
  }
  
  .legend-item-compact {
    font-size: 10px;
    padding: 3px 6px;
  }
  
  .legend-item-compact .legend-color {
    width: 10px;
    height: 10px;
    margin-right: 3px;
  }
}

/* Adjust card header for the toggle */
.card-header {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
  padding: 15px 20px;
  justify-content: space-between;
}

.card-header .card-icon {
  margin-right: 10px;
  flex-shrink: 0;
}

.card-header h3 {
  flex: 1;
  margin-right: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Using standard toggle styles from main.css instead of custom toggle styles */

/* Responsive adjustments for toggle */
@media (max-width: 768px) {
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .card-header .toggle-container {
    margin-left: 0;
    margin-top: 10px;
    margin-bottom: 5px;
  }
}

/* Animation for flow lines */
@keyframes dash-animation-import {
  0% {
    stroke-dashoffset: 40;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes dash-animation-export {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -40;
  }
}

.animated-flow.import-flow {
  animation: dash-animation-import 2s linear infinite;
}

.animated-flow.export-flow {
  animation: dash-animation-export 2s linear infinite;
}

/* Update the legend to match the new animated dashed lines */
.legend-flow-arrow:before,
.legend-flow-arrow.import:before,
.legend-flow-arrow.export:before,
.legend-item-compact .legend-flow-arrow:before,
.legend-item-compact .legend-flow-arrow.import:before,
.legend-item-compact .legend-flow-arrow.export:before {
  display: none;
}

/* Chart colors to match map legend */
.chart-import-color {
  color: #4CAF50;
  background-color: #4CAF50;
  fill: #4CAF50;
}

.chart-export-color {
  color: #30a2ff;
  background-color: #30a2ff;
  fill: #30a2ff;
}

/* Map container styles */
#bmu-map, #embedded-generation-map, #substation-map, #embedded-demand-map {
  width: 100%;
  height: 600px;
  border-radius: 8px;
  z-index: 1;
}

/* Embedded demand map container styles */
#embedded-demand-map {
  background-color: #f7f7f7;
  border: 1px solid #ddd;
}

/* Connection Type Grid Styles */
.connection-type-grid {
  width: 100%;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.connection-type-row {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr 2fr 1fr;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.connection-type-row:last-child {
  border-bottom: none;
}

.connection-type-row.header {
  background: rgba(48, 162, 255, 0.2);
  font-weight: bold;
  padding: 10px 12px;
}

.connection-type-cell {
  padding: 4px 8px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .connection-type-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }
  
  .connection-type-row.header {
    display: none;
  }
  
  .connection-type-cell {
    position: relative;
  }
  
  .connection-type-cell:nth-child(odd):before {
    content: attr(data-label);
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
  }
}
