@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg: hsl(220, 14%, 10%);
  --card: hsl(220, 13%, 14%);
  --foreground: hsl(210, 20%, 90%);
  --muted: hsl(215, 15%, 55%);
  --border: hsl(220, 12%, 20%);
  --neon-blue: hsl(190, 100%, 50%);
  --neon-purple: hsl(270, 91%, 65%);
  --surface: hsl(220, 13%, 17%);
  --input-bg: hsl(220, 12%, 18%);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neon-blue);
  text-shadow: 0 0 12px hsla(190, 100%, 50%, 0.5);
  letter-spacing: -0.02em;
}

.sidebar-header p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.controls {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.field-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 3px hsla(190, 100%, 50%, 0.15);
}

/* ── Select dropdown ── */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--muted);
  pointer-events: none;
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

select.input option {
  background: var(--card);
  color: var(--foreground);
}

/* ── Hidden utility ── */
.hidden {
  display: none !important;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.3s, background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--neon-blue);
  color: var(--bg);
  box-shadow: 0 0 12px hsla(190, 100%, 50%, 0.3), 0 0 4px hsla(190, 100%, 50%, 0.15);
}

.btn-primary:hover {
  box-shadow: 0 0 20px hsla(190, 100%, 50%, 0.45), 0 0 8px hsla(190, 100%, 50%, 0.25);
}

.btn-execute {
  width: 100%;
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}

.btn-outline.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-purple-active {
  background: hsla(270, 91%, 65%, 0.15);
  color: var(--neon-purple);
  border: 1px solid hsla(270, 91%, 65%, 0.4);
  box-shadow: 0 0 12px hsla(270, 91%, 65%, 0.2);
}

.divider {
  height: 1px;
  background: var(--border);
}

.type-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-bar {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-blue);
  animation: pulse-glow 3s ease-in-out infinite;
}

.status-bar span:last-child {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Canvas ── */
.canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background-image: radial-gradient(circle, hsl(220, 12%, 22%) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: auto;
}

.linked-list {
  display: flex;
  align-items: center;
  gap: 0;
}

.node-group {
  display: flex;
  align-items: center;
  animation: fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.node-group:nth-child(2) { animation-delay: 80ms; }
.node-group:nth-child(3) { animation-delay: 160ms; }

.node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px;
  min-width: 72px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  transition: border-color 0.2s, box-shadow 0.3s;
}

.node:hover {
  border-color: hsla(190, 100%, 50%, 0.4);
  box-shadow: 0 0 20px hsla(190, 100%, 50%, 0.12);
}

.node-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--foreground);
}

.node-idx {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

.arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  color: var(--neon-blue);
  font-size: 1.25rem;
}

/* ── SVG icon inside buttons ── */
.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ── Animations ── */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .canvas {
    min-height: 300px;
  }
}