/* ─────────────────────────────────────────────
   Tree Visualizer Specific Styles
   ───────────────────────────────────────────── */

/* ── The Ultimate Star Background & Spacing Fix ── */
.visualizer-hero {
  position: relative;
  min-height: auto; /* REMOVED 55vh. Let the text size itself naturally! */
  padding: 140px 2rem 2rem; /* Pushes past the navbar, with tight padding below */
}

.visualizer-hero .hero-background {
  position: fixed; /* Keeps the stars attached to the screen, not the container */
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh; /* Keeps the math perfect for the infinite star loop */
  z-index: -10;
}

/* Ensure the main page content sits perfectly below the text */
.visualizer-section {
  position: relative;
  z-index: 2; 
  padding-top: 0; /* REMOVED the top padding so the canvas hugs the hero text */
}

.typing-text_visualizer {
  color: #06b6d4; 
  font-weight: 500;
  font-size: 1.2rem;
  white-space: nowrap;
}

.visualizer-hero .typing-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  min-height: 30px;
}

.visualizer-section {
  padding: 4rem 2rem;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.visualizer-container {
  display: flex;
  gap: 2rem;
  width: 100%;
  max-width: 1400px;
  align-items: stretch;
}

/* ── Control Panel ── */
.control-panel {
  width: 320px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.2rem;
  color: var(--primary-light);
  margin: 0;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.75rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-row input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: Poppins, sans-serif;
  outline: none;
}

.input-row input:focus {
  border-color: var(--primary);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-vis {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: Poppins, sans-serif;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.btn-vis:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

.btn-insert { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.3); color: #22c55e; }
.btn-insert:hover { background: rgba(34, 197, 94, 0.2); border-color: #22c55e; }

.btn-delete { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); color: #ef4444; }
.btn-delete:hover { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; }

.btn-danger {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #ef4444;
}
.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.status-box, .traversal-output {
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: "Fira Code", monospace;
  overflow-wrap: break-word;
}

/* ── Canvas Area ── */
.canvas-area {
  flex: 1;
  background: var(--dark-surface);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  min-height: 600px;
}

.tree-canvas {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: auto;
}

#edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none; /* Let clicks pass through to nodes */
  z-index: 1;
}

.tree-node {
  position: absolute;
  width: 40px;
  height: 40px;
  background: var(--glass-bg);
  border: 2px solid var(--primary-light);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-primary);
  font-weight: 600;
  font-family: "Orbitron", sans-serif;
  font-size: 0.9rem;
  transform: translate(-50%, -50%); /* Center node on coordinates */
  z-index: 2;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Animation States */
.tree-node.highlight {
  background: var(--primary);
  border-color: transparent;
  color: #ffffff; 
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 0 15px var(--primary);
}

.tree-node.found {
  background: #22c55e;
  border-color: transparent;
  color: #ffffff; 
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 0 15px #22c55e;
}

.tree-edge {
  stroke: var(--glass-border);
  stroke-width: 2px;
  transition: stroke 0.3s ease;
}

/* Responsive */
@media (max-width: 900px) {
  .visualizer-container {
    flex-direction: column;
  }
  .control-panel {
    width: 100%;
  }
}