/* --- Base Page Configuration --- */

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: black;
  background-color: white;
  user-select: none;
}

/* --- The Main CSS Grid --- */

.dashboard-container {
  display: grid;
  grid-template-columns: 72.5% 27.5%;
  grid-template-rows: 50px minmax(0, 1fr) 20%;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* --- The Header Styling --- */

.dashboard-header {
  grid-column: 1 / 2; 
  grid-row: 1 / 2;
  background-color: #2a6dff;
  color: white;
  padding: 0 20px;
  display: flex;
  align-items: center; 
  justify-content: space-between;
  border-right: 1px solid lightgrey;
  border-bottom: 1px solid lightgrey;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.dashboard-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.1;
}

.header-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: #bfdbfe;
  letter-spacing: 0.02em;
}

.dashboard-header p {
  margin: 0;
  font-size: 14px;
  color: #bfdbfe;
}

.reset-selection-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: white;
  font-size: 12px;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.reset-selection-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.8);
}

/* --- Map Area --- */

.map-zone {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  position: relative;
  border-right: 1px solid lightgrey;
}

#my-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* --- Floating Top-Left Controls --- */

#map-controls-top-left {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dropdown-group {
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid lightgrey;
  border-radius: 4px;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
  overflow: hidden;
  transition: all 0.2s ease;
}

.dropdown-group:hover {
  background-color: white;
  border-color: darkgrey;
}

.dropdown-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: black;
  padding: 5px 4px 5px 10px;
  white-space: nowrap;
}

.dropdown-select {
  flex: 1;
  border: none;
  background-color: transparent;
  padding: 5px 10px 5px 2px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: darkslategray;
  cursor: pointer;
  outline: none;
}

.brush-button,
.heatmap-button {
  border: 1px solid lightgrey;
  background-color: rgba(255, 255, 255, 0.95);
  color: #1f2937;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
}

.brush-button:hover,
.heatmap-button:hover {
  background-color: white;
  border-color: darkgrey;
}

.brush-button.active,
.heatmap-button.active {
  background-color: #2a6dff;
  border-color: #2a6dff;
  color: white;
}

/* --- Floating Service Type Legend --- */

#service-type-legend {
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid lightgrey;
  border-radius: 4px;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
  padding: 6px 8px; 
}

.legend-title {
  font-size: 12px;
  font-weight: 700;
  color: black;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid lightgrey;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.legend-color-picker {
  width: 16px; 
  height: 20px;
  border-radius: 3px;
  padding: 0; 
  cursor: pointer;
  flex-shrink: 0;
  background: none;
}

.legend-checkbox {
  cursor: pointer;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin: 0;
}

.legend-label {
  font-size: 12px;
  color: #1f2937;
  user-select: none;
}

.legend-info-icon {
  font-size: 11px;
  color: #9ca3af;
  cursor: default;
  flex-shrink: 0;
  line-height: 1;
}

.legend-info-icon:hover {
  color: #6b7280;
}

.legend-row.hidden .legend-label {
  color: #9ca3af;
  text-decoration: line-through;
}

.legend-color-picker.disabled {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}

/* --- Floating Bottom-Left Note --- */

#missing-data-note {
  position: absolute;
  bottom: 15px;
  left: 15px;
  z-index: 1000;
  font-size: 11px;
  color: #555;
  background-color: rgba(255, 255, 255, 0.75);
  padding: 4px 8px;
  border-radius: 3px;
  pointer-events: none;
}

/* --- Chart Column --- */

.chart-column {
  grid-column: 2 / 3;
  grid-row: 1 / 4;
  background-color: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-wrapper {
  flex: 1;
  position: relative;
  border-bottom: 1px solid lightgrey;
  overflow: hidden;
}

.chart-wrapper:last-child {
  border-bottom: none;
}

/* Chart wrapper promoted to the main map area on swap */
.chart-wrapper.in-main {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  border-right: 1px solid lightgrey;
  border-bottom: none;
}

.chart-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Map zone demoted to the chart column on swap */
.map-zone.in-column {
  flex: 1;
  border-right: none;
  border-bottom: 1px solid lightgrey;
}

.map-zone.in-column:last-child {
  border-bottom: none;
}

.map-zone.in-column #map-controls-top-left,
.map-zone.in-column #missing-data-note {
  display: none;
}

/* --- Chart Top-Left Controls (swap button + scale selector) --- */

.chart-controls {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 3px;
}

.swap-button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid lightgrey;
  border-radius: 3px;
  cursor: pointer;
  padding: 1px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
  line-height: 0;
}

.swap-button svg {
  width: 14px;
  height: 11px;
}

.swap-button:hover {
  background: white;
  border-color: darkgrey;
}

#map-swap-btn {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1000;
}

.scale-selector {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid lightgrey;
  border-radius: 3px;
  cursor: pointer;
  padding: 1px 2px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  color: darkslategray;
  outline: none;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.15);
}

.scale-selector:hover {
  background: white;
  border-color: darkgrey;
}

.chart-wrapper.in-main .swap-button {
  padding: 4px 6px;
  border-radius: 5px;
}

.chart-wrapper.in-main .swap-button svg {
  width: 20px;
  height: 16px;
}

.chart-wrapper.in-main .scale-selector {
  font-size: 13px;
  padding: 3px 4px;
  right: 5px;
}

/* --- Bar Chart Configurations --- */
.chart-title {
  font-size: 24px;
}

.axis-title {
  font-size: 18px;
}

.axis .tick text {
  font-size: 14px;
}

/* --- Timeline Area --- */

.timeline-zone {
  grid-column: 1 / 2;
  grid-row: 3 / 4;
  background-color: white;
  border-top: 1px solid lightgrey;
  border-right: 1px solid lightgrey;
}

.timeline-container {
  height: 100%;
  width: 100%;
}

.axis-label {
  font-size: 12px;
  fill: #333;
}

/* --- Tooltip Styles --- */

#tooltip {
  position: absolute;
  opacity: 0; 
  z-index: 1000000;
  pointer-events: none;
  background-color: white;
  font-size: 12px;
  line-height: 1.25;
  padding: 6px 8px;
  border: 1px solid darkgrey;
  border-radius: 4px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
  white-space: nowrap;
}

#tooltip strong {
  font-weight: 700;
  color: black;
  margin-right: 4px;
}

.brush .selection {
  fill: rgba(42, 109, 255, 0.2);
  stroke: #2a6dff;
  stroke-width: 1.5px;
}

#my-map.brush-enabled {
  cursor: crosshair;
}

.brush-button:disabled {
  opacity: 0.4;
}

.timeline-brush-blocked .overlay {
  cursor: auto !important;
}

.heatmap-canvas {
  z-index: 350;
  opacity: 0.8;
}

/* --- Focussing Configurations -- */

.bar,
.timeline-point,
.dot {
  cursor: pointer;
}

.focused {
  stroke: black;
  stroke-width: 1px;
}

.dot.focused {
  opacity: 0.95;
}

.has-focus .dot:not(.focused) {
  opacity: 0.25;
  stroke: none;
}

.has-focus .bar:not(.focused) {
  opacity: 0.25;
}

.has-focus .timeline-point:not(.focused) {
  opacity: 0.25;
}
