:root {
  --bg-main: #0b1320;
  --bg-panel: #121c2d;
  --bg-panel-soft: #18253a;

  --text-main: #e6edf3;
  --text-muted: #9fb3c8;

  --accent-primary: #4fc3f7;
  --accent-secondary: #64ffda;

  --compare: #ff6b6b;
  --sorted: #4dd599;

  --border-soft: #22324d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
}

/* TOP BAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: linear-gradient(180deg, #0e1a2b, #0b1320);
  border-bottom: 1px solid var(--border-soft);
}

.topbar h1 {
  font-size: 18px;
  letter-spacing: 1px;
}

/* TABS */
.tabs button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.tabs button.active {
  color: var(--accent-primary);
  background: rgba(79,195,247,0.15);
}

/* MAIN LAYOUT */
.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px;
}

/* PANEL */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
}

/* CONTROLS */
.controls h2 {
  margin-top: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.controls label {
  display: block;
  font-size: 12px;
  margin-top: 12px;
  color: var(--text-muted);
}

.controls input,
.controls select {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: #0e1a2b;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text-main);
}

/* BUTTONS */
.control-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, #4fc3f7, #64ffda);
  color: #001018;
}

.btn.ghost {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

/* VISUAL */
.visual {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  min-height: 300px;
  background: var(--bg-panel-soft);
}

/* BAR */
.bar {
  width: 30px;
  border-radius: 8px 8px 4px 4px;
  background: var(--accent-primary);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: #001018;
  font-weight: 600;
  transition: all 0.25s ease;
}

.bar.compare {
  background: var(--compare);
}

.bar.sorted {
  background: var(--sorted);
}

/* EXPLANATION */
.explanation {
  margin: 16px;
  background: rgba(79,195,247,0.08);
  border-left: 4px solid var(--accent-primary);
}

.explanation p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

/* STEPPER */
.stepper {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.stepper button {
  background: var(--bg-panel-soft);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

/* BUTTON MICRO INTERACTION */
.btn,
.tabs button,
.stepper button {
  transition: 
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79,195,247,0.25);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.tabs button:hover {
  background: rgba(79,195,247,0.1);
  color: var(--accent-primary);
}

.bar {
  transition:
    height 0.25s ease,
    transform 0.25s ease,
    background 0.25s ease;
}

.bar.swap {
  transform: translateY(-8px);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,107,0.4); }
  100% { box-shadow: 0 0 0 10px rgba(255,107,107,0); }
}

.bar.compare {
  animation: pulse 0.6s ease-out;
}

.credit {
  position: fixed;
  bottom: 14px;
  right: 18px;
  font-size: 15px;
  color: var(--text-muted);
  cursor: default;
}

.credit .name {
  color: var(--accent-secondary);
  font-weight: 600;
  cursor: pointer;
}

/* hidden text */
.credit .full-name {
  position: absolute;
  bottom: 140%;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-main);
  white-space: nowrap;

  opacity: 0;
  transform: translateY(6px) scale(0.95);
  pointer-events: none;

  transition: all 0.25s ease;
}

/* reveal on hover */
.credit:hover .full-name {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* highlight syllables */
.credit .full-name span {
  color: var(--accent-primary);
  font-weight: 600;
}

.panel {
  animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.visual.bar-mode {
  align-items: flex-end;
  gap: 12px;
  padding: 20px;
}

.visual.bar-mode .bar {
  width: 28px;
  border-radius: 8px 8px 4px 4px;
}

/* efek kedalaman */
.visual.bar-mode .bar {
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.bar.swap {
  transform: translateY(-10px) scale(1.05);
}

.visual.array-mode {
  align-items: center;
  gap: 10px;
  padding: 20px;
}

.array-box {
  min-width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 600;
  color: #001018;

  transition:
    transform 0.25s ease,
    background 0.25s ease;
}

.array-box.compare {
  background: var(--compare);
  transform: scale(1.08);
}

.array-box.sorted {
  background: var(--sorted);
}

.array-box.swap {
  transform: translateX(6px) scale(1.05);
}

/* MOBILE ENHANCEMENTS */
@media (max-width: 500px) {
  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .controls {
    padding: 12px;
  }

  .control-buttons {
    flex-direction: column;
  }

  .btn {
    font-size: 12px;
    padding: 8px;
  }

  .visual {
    min-height: 180px;
    padding: 12px;
    gap: 6px;
  }

  .bar {
    width: 18px;
    font-size: 10px;
  }

  .array-box {
    min-width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .stepper {
    flex-wrap: wrap;
    gap: 6px;
  }

  .stepper button {
    padding: 5px 8px;
    font-size: 11px;
  }

  .algo-info {
    padding: 8px 12px;
  }

  .algo-info h2 {
    font-size: 12px;
  }

  .algo-info p {
    font-size: 11px;
  }

  .explanation {
    margin: 12px 0;
    font-size: 12px;
  }
}


.algo-info {
  padding: 12px 24px;
  background: linear-gradient(
    90deg,
    rgba(79,195,247,0.12),
    rgba(79,195,247,0.02)
  );
  border-bottom: 1px solid var(--border-soft);
}

.algo-info h2 {
  margin: 0;
  font-size: 14px;
  color: var(--accent-primary);
}

.algo-info p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.algo-info.insertion {
  background: linear-gradient(
    90deg,
    rgba(79,195,247,0.15),
    rgba(79,195,247,0.03)
  );
}

.algo-info.shell {
  background: linear-gradient(
    90deg,
    rgba(100,255,218,0.15),
    rgba(100,255,218,0.03)
  );
}

.algo-info.heap {
  background: linear-gradient(
    90deg,
    rgba(255,171,64,0.15),
    rgba(255,171,64,0.03)
  );
}

.algo-info.shell h2 {
  color: var(--accent-secondary);
}

.algo-info.heap h2 {
  color: #ffab40;
}

.algo-info {
  animation: slideDown 0.35s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .algo-info {
    padding: 10px 16px;
  }

  .algo-info h2 {
    font-size: 13px;
  }

  .algo-info p {
    font-size: 12px;
  }
}

.algo-info {
  animation: algoEnter 0.35s ease;
}

.algo-info.switching {
  animation: algoExit 0.2s ease forwards;
}

@keyframes algoEnter {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes algoExit {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.visual.fade {
  opacity: 0.3;
  transition: opacity 0.25s ease;
}

.explanation.fade {
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.25s ease;
}

.explanation.compare {
  border-left-color: var(--compare);
}

.explanation.swap {
  border-left-color: var(--accent-primary);
}

.explanation.sorted {
  border-left-color: var(--sorted);
}

.bar, .array-box {
  transition: transform 300ms ease, background 200ms;
  will-change: transform;
}

.bar.key {
  background: #ffd166;
  box-shadow: 0 0 12px rgba(255,209,102,.6);
  transform: scale(1.05);
}

.bar.compare {
  background: #ef476f;
}

.bar.sorted {
  background: #06d6a0;
}

.gap {
  width: 30px;
  height: 10px;
  margin: 0 5px;
  opacity: 0;
}

.key-holder {
  min-height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.key-float {
  width: 30px;
  border-radius: 8px;
  background: #ffd166;
  color: #001018;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  box-shadow: 0 0 12px rgba(255,209,102,.6);
  transition: transform 300ms ease;
}

