/* ==================== DASHBOARD.CSS ==================== */
/* Dashboard specific styles including stats grid, charts, gauges, activities, alerts, and performance cards */

/* Dashboard Section */
.dashboard {
  padding: 40px;
  width: 100%;
  box-sizing: border-box;
  background: var(--off-white);
  min-height: calc(100vh - 80px);
}

.section.dashboard {
  display: block;
  width: 100% !important;
}

.section.dashboard.active {
  display: block;
  width: 100% !important;
}

.stats-grid,
.charts-row,
.dashboard-grid {
  width: 100%;
  box-sizing: border-box;
}

.dashboard-header {
  margin-bottom: 40px;
  position: relative;
  width: 100%;
}

.dashboard-header h2 {
  font-family: 'Cairo', sans-serif;
  color: var(--navy);
  font-size: 2.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.dashboard-header p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
}

.dashboard-header::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 0;
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--teal), var(--gold));
  border-radius: 2px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 40px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
  align-items: stretch;
}

.dashboard-map {
  background: var(--white);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 45, 66, 0.06);
}

.dashboard-map-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, var(--white) 0%, var(--off-white) 100%);
}

.dashboard-map-header h3 {
  font-family: 'Cairo', sans-serif;
  color: var(--navy);
  font-size: 1.2rem;
  font-weight: 600;
}

.recent-projects {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 45, 66, 0.06);
}

.recent-projects h3 {
  font-family: 'Cairo', sans-serif;
  color: var(--navy);
  font-size: 1.2rem;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--gray-100);
  font-weight: 600;
  position: relative;
}

.recent-projects h3::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--teal));
}

/* Dashboard Header Actions */
.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.last-updated {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.last-updated strong {
  color: var(--cyan);
}

/* Charts Row */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
  align-items: stretch;
}

.charts-row.two-cols {
  grid-template-columns: 1fr 1fr;
}

.charts-row.three-cols {
  grid-template-columns: 1.2fr 0.8fr 1fr;
}

.chart-card.large {
  grid-column: span 1;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.chart-header h3 {
  font-family: 'Cairo', sans-serif;
  font-size: 1.1rem;
  color: var(--navy);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-header h3 i {
  color: var(--cyan);
  font-size: 1rem;
  transition: transform 0.3s ease;
}

.chart-card:hover .chart-header h3 i {
  transform: scale(1.2);
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-actions {
  display: flex;
  gap: 4px;
}

.chart-btn {
  padding: 8px 16px;
  border: 1px solid var(--gray-200);
  background: transparent;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.chart-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0, 180, 216, 0.05);
}

.chart-btn.active {
  background: linear-gradient(135deg, var(--cyan-dark), var(--cyan));
  border-color: transparent;
  color: var(--white);
  box-shadow: 0 4px 15px rgba(0, 180, 216, 0.3);
}

.chart-container {
  position: relative;
  height: 280px;
}

/* Custom Chart Legend */
.chart-legend-custom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

.chart-legend-custom .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.chart-legend-custom .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-legend-custom .dot.producing { background: var(--green); }
.chart-legend-custom .dot.injection { background: var(--cyan); }
.chart-legend-custom .dot.maintenance { background: var(--orange); }
.chart-legend-custom .dot.inactive { background: var(--red); }

/* Heat Map */
.heatmap-container {
  position: relative;
  padding: 20px 0 40px 40px;
}

.heatmap-map-container {
  position: relative;
}

.heatmap-map-container .dashboard-map-container {
  height: 280px;
  border-radius: 12px;
  overflow: hidden;
}

.heatmap-map-container .heatmap-legend {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 45, 66, 0.85);
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 10;
}

.heatmap-map-container .heatmap-gradient {
  background: linear-gradient(90deg, 
    rgba(0, 180, 216, 0.4), 
    rgba(0, 191, 166, 0.6), 
    rgba(212, 168, 67, 0.8), 
    rgba(255, 140, 0, 0.9), 
    rgba(255, 69, 0, 1)
  );
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  height: 180px;
}

.heatmap-cell {
  border-radius: 3px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 10;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.heatmap-gradient {
  width: 120px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(0, 180, 216, 0.1), rgba(0, 180, 216, 0.9));
}

.heatmap-labels {
  position: absolute;
}

.heatmap-y-labels {
  position: absolute;
  left: 0;
  top: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.heatmap-x-labels {
  position: absolute;
  bottom: 20px;
  left: 40px;
  right: 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Map Card in Dashboard */
.map-card {
  padding: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.map-card .chart-header {
  padding: 20px 24px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.dashboard-map-container {
  flex: 1;
  width: 100%;
  position: relative;
  background: #1a1a2e;
  overflow: hidden;
  min-height: 350px;
}

/* Ensure ArcGIS map renders properly */
.dashboard-map-container .esri-view {
  height: 100% !important;
  width: 100% !important;
}

.dashboard-map-container .esri-view-surface {
  height: 100% !important;
  width: 100% !important;
}

.dashboard-map-container .esri-view-surface canvas {
  display: block !important;
}

#dashboardMapView {
  height: 100% !important;
  width: 100% !important;
  display: block;
}

#geospatialHeatmapView {
  height: 100% !important;
  width: 100% !important;
  display: block;
}

#dashboardMapView .esri-view-root,
#geospatialHeatmapView .esri-view-root {
  height: 100% !important;
  width: 100% !important;
}

#activityHeatmapView {
  height: 280px !important;
  width: 100% !important;
  display: block !important;
  min-height: 280px;
  position: relative;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
}

/* Gauge Cards */
.gauge-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.gauge-card {
  background: var(--white);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 5px 25px rgba(0, 45, 66, 0.06);
  border: 1px solid rgba(0, 180, 216, 0.08);
  flex: 1;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.gauge-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.gauge-card:nth-child(1)::after { background: linear-gradient(90deg, var(--gold), var(--orange)); }
.gauge-card:nth-child(2)::after { background: linear-gradient(90deg, var(--green), var(--teal)); }
.gauge-card:nth-child(3)::after { background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.gauge-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 45, 66, 0.12);
  border-color: rgba(0, 180, 216, 0.2);
}

.gauge-card:hover::after {
  opacity: 1;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.gauge-header h4 {
  font-size: 0.95rem;
  color: var(--navy);
  font-weight: 600;
}

.gauge-value {
  font-family: 'Cairo', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  transition: transform 0.3s ease;
}

.gauge-card:hover .gauge-value {
  transform: scale(1.1);
}

.gauge-value.green { color: var(--green); }
.gauge-value.cyan { color: var(--cyan); }

.gauge-container {
  position: relative;
}

.gauge-svg {
  width: 100%;
  height: 60px;
}

.gauge-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 12;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.gauge-fill.efficiency {
  stroke: url(#gaugeGradientGold);
}

.gauge-fill.uptime {
  stroke: url(#gaugeGradientGreen);
}

.gauge-fill.safety {
  stroke: url(#gaugeGradientCyan);
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Activities Card */
.activities-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.activities-card .chart-header {
  padding: 20px 24px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.view-all {
  font-size: 0.85rem;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.view-all:hover {
  color: var(--cyan-dark);
  text-decoration: none;
  transform: translateX(3px);
}

.activities-list {
  padding: 0 24px 24px;
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.activity-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--green);
}

.activity-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--orange);
}

.activity-icon.info {
  background: rgba(0, 180, 216, 0.1);
  color: var(--cyan);
}

.activity-icon.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

.activity-content {
  flex: 1;
}

.activity-content h4 {
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 2px;
}

.activity-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--gray-300);
}

/* Alerts Card */
.alerts-card {
  padding: 0;
}

.alerts-card .chart-header {
  padding: 20px 24px;
  margin-bottom: 0;
}

.alert-count {
  background: var(--red);
  color: var(--white);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.alerts-list {
  padding: 0 24px 24px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.alert-item:last-child {
  margin-bottom: 0;
}

.alert-item.critical {
  background: rgba(239, 68, 68, 0.08);
  border-left: 4px solid var(--red);
}

.alert-item.warning {
  background: rgba(245, 158, 11, 0.08);
  border-left: 4px solid var(--orange);
}

.alert-item.info {
  background: rgba(0, 180, 216, 0.08);
  border-left: 4px solid var(--cyan);
}

.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.alert-item.critical .alert-icon {
  background: var(--red);
  color: var(--white);
}

.alert-item.warning .alert-icon {
  background: var(--orange);
  color: var(--white);
}

.alert-item.info .alert-icon {
  background: var(--cyan);
  color: var(--white);
}

.alert-content {
  flex: 1;
}

.alert-content h4 {
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 4px;
}

.alert-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.alert-time {
  font-size: 0.75rem;
  color: var(--gray-300);
}

.alert-action {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--white);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-action:hover {
  background: var(--cyan);
  color: var(--white);
}

/* Performance Card */
.performance-card {
  padding: 24px;
}

.performance-metrics {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.metric-label {
  font-size: 0.9rem;
  color: var(--navy);
  font-weight: 500;
}

.metric-value {
  font-family: 'Cairo', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
}

.metric-value small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.metric-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.metric-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 4px;
  transition: width 1s ease;
}

.metric-progress.green {
  background: linear-gradient(90deg, var(--green), var(--green-light));
}

.metric-progress.cyan {
  background: linear-gradient(90deg, var(--cyan), var(--cyan-light));
}

.metric-progress.success {
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.metric-target {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Dashboard Responsive */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-row {
    grid-template-columns: 1fr;
  }
  
  .charts-row.two-cols,
  .charts-row.three-cols {
    grid-template-columns: 1fr;
  }
  
  .gauge-cards {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .gauge-card {
    flex: 1 1 calc(33.333% - 12px);
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .dashboard {
    padding: 24px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .dashboard-header-actions {
    flex-wrap: wrap;
  }
  
  .chart-legend-custom {
    grid-template-columns: 1fr;
  }
  
  .gauge-card {
    flex: 1 1 100%;
  }
}
