.history-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

/* Header */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #404040;
}

.page-actions {
  display: flex;
  gap: 0.75rem;
}

.action-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #4080ff;
  background-color: #4080ff;
  color: #ffffff;
  border-radius: 2px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: inherit;
}

.action-btn:hover,
.action-btn:focus {
  background-color: #2060ff;
  border-color: #2060ff;
  outline: none;
  box-shadow: 0 0 8px rgba(64, 128, 255, 0.4);
}

.action-btn:focus {
  outline: 2px solid #4080ff;
  outline-offset: 2px;
}

/* Controls */
.history-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.control-section-title {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Date selectors */
.date-controls {
  background-color: #2a2a2a;
  padding: 1rem;
  border-radius: 2px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
  border: 1px solid #404040;
}

.date-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.date-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-label {
  font-size: 0.9rem;
  color: #b0b0b0;
  font-weight: 600;
  min-width: 40px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.date-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #606060;
  border-radius: 2px;
  background-color: #404040;
  font-size: 0.9rem;
  color: #e0e0e0;
  font-family: inherit;
}

.date-input:focus {
  outline: 2px solid #4080ff;
  border-color: #4080ff;
  box-shadow: 0 0 8px rgba(64, 128, 255, 0.4);
}

/* Map */
.history-main .map-container {
  background-color: #1a1a1a;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  position: relative;
  height: 560px; /* Same as dashboard map - TODO: standardize somewhere? */
  border: 1px solid #404040;
}

.history-main .world-map {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
}

/* Make sure map takes up full space */
.history-main #map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.time-slider-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26, 26, 26, 0.95);
  padding: 15px 20px;
  border-radius: 2px;
  color: #ffffff;
  min-width: 400px;
  z-index: 1000;
  border: 1px solid #404040;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

.time-slider-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-slider-label {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e0e0e0;
}

.slider-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.time-start,
.time-end {
  font-size: 12px;
  color: #b0b0b0;
  min-width: 80px;
  font-family: inherit;
}

.time-start {
  text-align: right;
}

.time-end {
  text-align: left;
}

.time-slider {
  flex: 1;
  height: 6px;
  background: #404040;
  border-radius: 1px;
  outline: none;
  -webkit-appearance: none; /* Override default Chrome style */
  appearance: none; /* Standard prop for compatibility */
}

.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #4080ff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(64, 128, 255, 0.5);
}

.time-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #4080ff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(64, 128, 255, 0.5);
}

.current-time {
  text-align: center;
  font-size: 12px;
  color: #b0b0b0;
  margin-top: 5px;
  font-family: inherit;
}

@media screen and (max-width: 767px) {
  .history-main {
    padding: 1rem;
  }

  /* Stack header */
  .history-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .page-actions {
    justify-content: center;
  }

  .action-btn {
    flex: 1;
    max-width: 150px;
  }

  /* Controls use single column layout */
  .history-controls {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .date-controls,
  .legend-section,
  .map-controls {
    padding: 0.75rem;
  }

  .control-section-title,
  .legend-title,
  .control-title {
    font-size: 0.9rem;
  }

  .history-main .map-container {
    height: 300px;
  }

  .time-slider-overlay {
    min-width: 280px;
    left: 10px;
    right: 10px;
    transform: none;
    padding: 10px 15px;
  }

  .slider-controls {
    flex-direction: column;
    gap: 8px;
  }

  .time-start,
  .time-end {
    min-width: auto;
    text-align: center;
    order: 2;
  }

  .time-slider {
    order: 1;
    width: 100%;
  }

  .current-time {
    font-size: 11px;
  }

  /* Map controls responsive */
  .map-controls .control-group {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .map-controls .power-filter {
    width: 100%;
    margin-top: 0.5rem;
  }
}

@media screen and (min-width: 768px) and (max-width: 1023px) {
  .history-main {
    padding: 1.25rem;
  }

  /* Controls using two column layout */
  .history-controls {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  /* Legend section spans full width on bottom */
  .legend-section {
    grid-column: 1 / -1;
  }

  .history-main .map-container {
    height: 400px;
  }

  .time-slider-overlay {
    min-width: 350px;
  }
}

@media screen and (min-width: 1024px) and (max-width: 1199px) {
  .history-main {
    max-width: 100%;
    padding: 0 1.5rem;
  }

  /* Map adjustments */
  .history-main .map-container {
    height: 500px;
  }
}

@media screen and (max-width: 479px) {
  .history-main {
    padding: 0.75rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .action-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .date-controls,
  .legend-section,
  .map-controls {
    padding: 0.5rem;
  }

  .control-section-title,
  .legend-title,
  .control-title {
    font-size: 0.85rem;
  }

  .history-main .map-container {
    height: 250px;
  }

  /* Time slider overlay extra small on mobile */
  .time-slider-overlay {
    min-width: 260px;
    padding: 8px 12px;
    bottom: 10px;
  }

  .time-slider-label {
    font-size: 12px;
  }

  .time-start,
  .time-end {
    font-size: 10px;
  }

  .current-time {
    font-size: 10px;
  }

  .map-controls .control-btn {
    padding: 0.5rem;
    min-width: 28px;
    font-size: 0.85rem;
  }

  /* Legend */
  .legend-list {
    gap: 0.375rem;
  }

  .legend-item {
    font-size: 0.85rem;
  }
}

@media screen and (min-width: 1400px) {
  .history-main {
    max-width: 1400px;
  }
}

/* Make touch targets bigger for mobile */
@media screen and (max-width: 767px) {
  .action-btn,
  .date-input,
  .power-filter,
  .control-btn {
    min-height: 44px;
  }

  .time-slider {
    height: 8px;
  }

  .time-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  .time-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }
}
