/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  color: #f0f0f0;
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header Styles */
header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #00c6ff, #0072ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.subtitle {
  font-size: 1.2rem;
  color: #aaa;
  font-weight: 300;
  max-width: 800px;
  margin: 0 auto;
}

/* Control Panel */
.control-panel {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  padding: 25px;
  margin-bottom: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.controls {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 160px;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.primary {
  background: linear-gradient(90deg, #3498db, #2980b9);
  color: white;
}

.success {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  color: white;
}

.warning {
  background: linear-gradient(90deg, #f39c12, #e67e22);
  color: white;
}

.danger {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
  color: white;
}

.speed-control,
.array-size-control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}

.speed-control label,
.array-size-control label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 1.1rem;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

/* Visualization Container */
.visualization-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.array-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 350px;
  gap: 8px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}

.array-bar {
  background: linear-gradient(to top, #3498db, #2980b9);
  border-radius: 5px 5px 0 0;
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  padding-top: 5px;
  min-width: 30px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.array-bar.unsorted {
  background: linear-gradient(to top, #3498db, #2980b9);
}

.array-bar.comparing {
  background: linear-gradient(to top, #f39c12, #e67e22);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(243, 156, 18, 0.5);
}

.array-bar.swapping {
  background: linear-gradient(to top, #e74c3c, #c0392b);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.array-bar.sorted {
  background: linear-gradient(to top, #2ecc71, #27ae60);
}

.legend {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-box {
  width: 25px;
  height: 25px;
  border-radius: 5px;
}

.unsorted {
  background: linear-gradient(to top, #3498db, #2980b9);
}

.comparing {
  background: linear-gradient(to top, #f39c12, #e67e22);
}

.swapping {
  background: linear-gradient(to top, #e74c3c, #c0392b);
}

.sorted {
  background: linear-gradient(to top, #2ecc71, #27ae60);
}

/* Info Panel */
.info-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

@media (max-width: 1100px) {
  .info-panel {
    grid-template-columns: 1fr;
  }
}

.stats,
.algorithm-info {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  padding: 25px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3498db;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.stat {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  transition: transform 0.3s ease;
}

.stat:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.08);
}

.stat-label {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Roboto Mono', monospace;
  color: #2ecc71;
}

/* Algorithm Steps */
.steps {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.step {
  display: flex;
  gap: 15px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border-left: 4px solid transparent;
  transition: all 0.3s ease;
}

.step.active {
  background: rgba(52, 152, 219, 0.1);
  border-left: 4px solid #3498db;
}

.step-number {
  width: 35px;
  height: 35px;
  background: #3498db;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 1.1rem;
  margin-bottom: 5px;
  color: #f0f0f0;
}

.step-content p {
  color: #aaa;
  font-size: 0.95rem;
}

/* Code Preview */
.code-preview {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  padding: 25px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.code-container {
  background: #1e1e1e;
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.95rem;
  line-height: 1.5;
}

pre {
  margin: 0;
  color: #d4d4d4;
}

code {
  display: block;
}

.keyword {
  color: #569cd6;
}

.comment {
  color: #6a9955;
}

.string {
  color: #ce9178;
}

.number {
  color: #b5cea8;
}

/* Footer */
footer {
  text-align: center;
  padding: 25px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  color: #aaa;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

footer p {
  margin-bottom: 10px;
}

.footer-note {
  font-size: 0.85rem;
  color: #777;
}

/* Responsive Design */
@media (max-width: 768px) {
  .control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    justify-content: center;
  }

  .btn {
    min-width: 140px;
  }

  h1 {
    font-size: 2.2rem;
    flex-direction: column;
    gap: 10px;
  }

  .info-panel {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .array-container {
    height: 250px;
  }

  .array-bar {
    min-width: 20px;
    font-size: 0.7rem;
  }
}

/* Animation for sorting */
@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.pulse {
  animation: pulse 0.5s ease;
}

/* Tooltip for array bars */
.array-bar::after {
  content: attr(data-value);
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

.array-bar:hover::after {
  opacity: 1;
}