/* Sorting Visualizer Styles */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #1a1a2e;
  color: #eee;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 0.25rem;
}

.header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.header .subtitle {
  font-size: 0.7rem;
  color: #888;
}

/* Visualization Container */
.viz-container {
  flex: 1;
  min-height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 0.75rem;
  background: #16213e;
  border-radius: 8px;
}

/* Individual Bars */
.bar {
  flex: 1;
  min-width: 4px;
  max-width: 60px;
  background: linear-gradient(180deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 4px 4px 0 0;
  transition: height 0.1s ease-out, background 0.15s ease;
  position: relative;
}

.bar::after {
  content: attr(data-value);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #aaa;
  padding-bottom: 2px;
}

/* Bar States */
.bar.comparing {
  background: linear-gradient(180deg, #f7971e 0%, #ffd200 100%);
}

.bar.swapping {
  background: linear-gradient(180deg, #f953c6 0%, #b91d73 100%);
}

.bar.sorted {
  background: linear-gradient(180deg, #11998e 0%, #38ef7d 100%);
}

.bar.pivot {
  background: linear-gradient(180deg, #8e2de2 0%, #4a00e0 100%);
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.35rem;
  background: #16213e;
  border-radius: 8px;
}

.btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #4facfe;
  color: #000;
}

.btn-primary:hover {
  background: #00f2fe;
}

.btn-primary:disabled {
  background: #4facfe55;
  cursor: not-allowed;
}

.btn-secondary {
  background: #333;
  color: #fff;
}

.btn-secondary:hover {
  background: #444;
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
}

.btn-danger:hover {
  background: #c0392b;
}

/* Speed Control */
.speed-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed-control label {
  font-size: 0.875rem;
  color: #888;
}

.speed-control input[type="range"] {
  width: 100px;
  accent-color: #4facfe;
}

/* Size Control */
.size-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.size-control label {
  font-size: 0.875rem;
  color: #888;
}

.size-control input[type="range"] {
  width: 80px;
  accent-color: #4facfe;
}

/* Stats Display */
.stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-top: 0.35rem;
  padding: 0.35rem;
  background: #16213e;
  border-radius: 8px;
  font-size: 0.75rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-label {
  color: #888;
}

.stat-value {
  color: #4facfe;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Legend */
.legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.35rem;
  font-size: 0.65rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

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

.legend-color.comparing {
  background: linear-gradient(180deg, #f7971e 0%, #ffd200 100%);
}

.legend-color.swapping {
  background: linear-gradient(180deg, #f953c6 0%, #b91d73 100%);
}

.legend-color.sorted {
  background: linear-gradient(180deg, #11998e 0%, #38ef7d 100%);
}

/* Responsive */
@media (max-width: 500px) {
  .controls {
    flex-direction: column;
  }

  .stats {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }
}
