/* Grid Stability specific styles */

:root {
  --stability-color: #673AB7;
}

.stability-info {
  margin-top: 20px;
}

/* Standard card styling for all stability views */
.glass-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Card for explaining synchronous compensators */
.info-card {
  background: rgba(103, 58, 183, 0.2);
  border-left: 4px solid var(--stability-color);
  padding: 15px;
  margin: 15px 0;
  border-radius: 8px;
}

.info-card h4 {
  margin-top: 0;
  color: #FFF;
}

.info-card p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.9);
}

/* Map container */
.map-container {
  height: 500px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(0, 0, 0, 0.2);
}

#stability-map {
  height: 100%;
  width: 100%;
  background-color: #f5f5f5;
  z-index: 5;
}

/* Map legend */
.map-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.9rem;
}

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

.legend-marker {
  font-size: 1.2rem;
  line-height: 1;
}

.legend-marker.online {
  color: #4CAF50;
}

.legend-marker.offline {
  color: #F44336;
}

.legend-marker.no-data {
  color: #9E9E9E;
}

/* Error message */
.error-message {
  background-color: rgba(244, 67, 54, 0.2);
  color: #fff;
  padding: 15px;
  border-radius: 8px;
  margin: 15px 0;
  border-left: 4px solid #f44336;
  display: none;
}

/* Standardize summary cards */
.summary-stats,
.service-summary-card,
.stat-item,
#stability-summary,
#sffr-summary,
#stor-summary,
#eac-summary,
#sop-summary-grid > div,
#sop-visuals > div,
#sop-data-table-container,
#compensator-summary,
#compensator-map-container,
#compensator-data-table-container,
#sffr-summary,
#sffr-chart-container,
#sffr-provider-table-container,
#stor-summary,
#stor-chart-container,
#stor-provider-table-container,
#eac-summary,
#eac-chart-container,
#eac-table-container {
  background: rgba(255, 255, 255, 0.1) !important;
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Table styles */
.table-container {
  max-height: 300px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  position: sticky;
  top: 0;
  background: rgba(103, 58, 183, 0.3);
  backdrop-filter: blur(var(--blur-intensity));
  cursor: pointer;
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sort-indicator {
  margin-left: 5px;
  opacity: 0.5;
}

th[data-sort="asc"] .sort-indicator,
th[data-sort="desc"] .sort-indicator {
  opacity: 1;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .map-container {
    height: 400px;
  }
  
  .table-container {
    max-height: 250px;
  }
  
  .map-legend {
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }
}

/* Add styles for SFFR and STOR views */

/* Status color indicators */
.active-status {
  color: #4CAF50;
  font-weight: bold;
}

.inactive-status {
  color: #F44336;
  font-weight: bold;
}

/* Row styling based on status */
.active-row {
  background: rgba(76, 175, 80, 0.1);
}

.inactive-row {
  background: rgba(244, 67, 54, 0.1);
}

/* Chart container styles */
.chart-container {
  width: 100%;
  height: 350px;
  padding: 15px;
  margin: 15px 0;
  position: relative;
  box-sizing: border-box;
  background: transparent !important; /* Ensure transparent background */
  border: none !important; /* Remove any borders */
  box-shadow: none !important; /* Remove any shadows */
}

.chart-container h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); /* Add text shadow for better readability */
}

.chart-container canvas {
  width: 100% !important;
  height: calc(100% - 30px) !important;
  background: transparent !important; /* Ensure canvas has transparent background */
}

/* Empty chart state - keep a subtle background for empty states */
.chart-container.empty-chart {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.1) !important; /* Keep subtle background for empty state */
  border-radius: 10px;
  padding: 30px;
}

/* View-specific content */
.view-overview, .view-sffr, .view-stor {
  transition: all 0.3s ease;
}

/* Responsive table layout for small screens */
@media (max-width: 768px) {
  #sffr-table, #stor-table {
    display: block;
    overflow-x: auto;
  }
}

/* Grid layout for overview page */
.grid-3-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

/* Service summary cards for overview - matching glass-card style */
.service-summary-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-intensity));
  -webkit-backdrop-filter: blur(var(--blur-intensity));
  border-radius: 15px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 var(--glass-shadow);
  padding: 25px;
  margin: 15px 0; /* Slightly less margin than glass-card */
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.service-summary-card:hover {
  background: var(--glass-bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 var(--glass-shadow-hover);
}

.service-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.service-card-header svg {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  color: #fff;
}

.service-card-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.service-card-content {
  padding-top: 5px;
}

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

.stat-pair .stat-label {
  color: rgba(255, 255, 255, 0.7);
}

.stat-pair .stat-value {
  font-weight: 600;
  color: #fff;
}

/* EAC Charts Layout */
.chart-container {
  width: 100%;
}

.chart-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
}

/* Ensure charts don't overflow their containers */
.chart-container {
  flex: 1 1 calc(50% - 10px);
  min-width: 0;
  box-sizing: border-box;
}

/* EAC View specific styles */
.eac-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  width: 100%;
  margin-top: 20px;
}

.eac-charts-grid .service-summary-card {
  display: flex;
  flex-direction: column;
  height: 450px; /* A fixed height guarantees alignment and prevents cut-offs */
  padding: 20px;
}

.eac-charts-grid .service-summary-card h4 {
  flex-shrink: 0; /* Don't shrink the title */
  margin-bottom: 15px;
}

.eac-charts-grid .service-summary-card canvas {
  flex-grow: 1; /* Grow to fill available space */
  min-height: 0; /* Critical for flexbox canvas sizing */
  width: 100% !important;
  height: 100% !important;
}

.eac-charts-grid .empty-chart-message {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .chart-container {
    flex: 1 1 100%;
  }
}

/* Chart container */
.chart-container {
  min-height: 350px;
  position: relative;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 15px;
}

/* Chart axis styling */
.chart-container canvas {
  background: transparent;
}

/* Remove Y-axis titles */
#stability-chart .y-axis-title,
#sffr-chart .y-axis-title,
#stor-utilization-chart .y-axis-title {
  display: none !important;
}

/* Add percentage to Y-axis on overview chart */
#stability-chart .y-axis-label::after {
  content: '%';
}

.chart-column {
  flex: 1;
  min-width: 0; /* Prevent flex items from overflowing */
}

.chart-column .service-summary-card {
  height: 100%;
  width: 100%;
}

/* Responsive layout for mobile */
@media (max-width: 768px) {
  .grid-3-col {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .service-summary-card {
    padding: 12px;
  }
  
  /* Stack charts vertically on mobile */
  .chart-row {
    flex-direction: column;
  }
}

/* SOP Table Styles */
.sop-group-header {
  background: rgba(103, 58, 183, 0.4);
  font-weight: bold;
  font-size: 1.05em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-tooltip {
  margin-left: 5px;
  cursor: help;
  opacity: 0.8;
  font-size: 0.9em;
}

.warning-value {
  color: #FF9800;
  font-weight: bold;
}

/* SOP chart layout - 2x2 grid */
#sop-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 15px;
  width: 100%;
  box-sizing: border-box;
}

#sop-charts .chart-container {
  margin: 0;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

@media (max-width: 992px) {
  #sop-charts {
    grid-template-columns: 1fr;
  }
}
