/**
 * Optimal Routes Page Styles
 */

.optimal-routes-container {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* Control Panel */
.control-panel {
  width: 400px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.25rem;
}

.panel-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h4 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
}

.control-section {
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 0.5rem);
  padding: 1rem;
  margin-bottom: 1rem;
}

.control-section:last-child {
  margin-bottom: 0;
}

/* Area Stats */
.area-stats {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.stat-row:not(:last-child) {
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Progress Stages */
.progress-stages {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.stage {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  opacity: 0.5;
  transition: all 0.3s ease;
}

.stage.active {
  opacity: 1;
  background: var(--primary);
  color: white;
}

.stage.completed {
  opacity: 1;
  background: var(--success);
  color: white;
}

.stage-icon {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.stage-label {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Progress Message */
.progress-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.5rem;
}

.elapsed-time {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-align: center;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.stat-card.deadhead .stat-icon {
  background: var(--warning, #f59e0b);
}

.stat-card .stat-content {
  flex: 1;
}

.stat-card .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Export Buttons */
.export-buttons {
  display: flex;
  gap: 0.5rem;
}

.export-buttons .btn {
  flex: 1;
}

/* Error Section */
.error-section {
  background: rgb(239 68 68 / 10%);
  border-color: var(--danger, #ef4444);
  text-align: center;
}

.error-icon {
  font-size: 2rem;
  color: var(--danger, #ef4444);
  margin-bottom: 0.5rem;
}

.error-message {
  color: var(--danger, #ef4444);
  margin-bottom: 0.5rem;
}

/* Route History */
.route-history {
  max-height: 150px;
  overflow-y: auto;
}

.route-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.route-history-item:hover {
  background: var(--surface-4, var(--surface-2));
}

.route-history-item .route-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.route-history-item .route-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  background: var(--surface-0);
}

#route-map {
  width: 100%;
  height: 100%;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.map-legend h6 {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-color {
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

/* Generate Button */
#generate-route-btn {
  background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
  border: none;
  font-weight: 600;
  transition: all 0.3s ease;
}

#generate-route-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgb(147 51 234 / 40%);
}

#generate-route-btn:disabled {
  background: var(--surface-3);
  color: var(--text-tertiary);
}

/* Progress Bar */
.progress {
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #9333ea 0%, #7c3aed 50%, #9333ea 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Responsive */
@media (width <= 992px) {
  .optimal-routes-container {
    flex-direction: column;
  }

  .control-panel {
    width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .map-container {
    min-height: 50vh;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (width <= 576px) {
  .progress-stages {
    flex-wrap: wrap;
  }

  .stage {
    flex: 0 0 calc(33.33% - 0.25rem);
    margin-bottom: 0.25rem;
  }
}
