/* ==========================================================================
   CODEXSEC LABS • PROTOCOL 02 // RECURSION VISUALIZER PRO
   VisuAlgo-grade Dual-Representation Spatial & Array Memory Engine
   ========================================================================== */

:root {
  --vis-canvas-bg: #030712;
  --vis-panel-bg: rgba(11, 19, 38, 0.85);
  --vis-node-bg: #0d172b;
  --vis-node-border: rgba(0, 245, 155, 0.4);
  --vis-node-glow: rgba(0, 245, 155, 0.25);
  --vis-compare-bg: rgba(245, 158, 11, 0.2);
  --vis-compare-border: #f59e0b;
  --vis-swap-bg: rgba(217, 70, 239, 0.2);
  --vis-swap-border: #d946ef;
  --vis-sorted-bg: rgba(16, 185, 129, 0.25);
  --vis-sorted-border: #10b981;
}

[data-theme="light"] {
  --vis-canvas-bg: #f8fafc;
  --vis-panel-bg: rgba(255, 255, 255, 0.9);
  --vis-node-bg: #ffffff;
  --vis-node-border: rgba(14, 165, 233, 0.5);
  --vis-node-glow: rgba(14, 165, 233, 0.15);
}

[data-theme="nebula"] {
  --vis-canvas-bg: #070617;
  --vis-panel-bg: rgba(18, 13, 46, 0.85);
}

[data-theme="crimson"] {
  --vis-canvas-bg: #120406;
  --vis-panel-bg: rgba(36, 10, 16, 0.85);
}

/* Page Container */
.pro-visualizer-container {
  max-width: 1720px;
  margin: 1.5rem auto 7rem;
  padding: 0 1.5rem;
}

/* Hero Header */
.vis-pro-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
  background: radial-gradient(circle at 15% 50%, rgba(0, 245, 155, 0.08) 0%, rgba(10, 16, 29, 0.7) 100%);
  border: 1px solid rgba(0, 245, 155, 0.2);
  border-radius: 1.25rem;
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.vis-pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0, 245, 155, 0.12);
  color: var(--lime);
  border: 1px solid rgba(0, 245, 155, 0.3);
  margin-bottom: 0.5rem;
}

.vis-pro-title {
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.vis-pro-desc {
  font-size: 0.88rem;
  color: #94a3b8;
  margin-top: 0.35rem;
  max-width: 720px;
}

.vis-stats-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.vis-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.6rem 1rem;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  font-family: var(--font-mono);
}

.vis-stat-pill .label {
  font-size: 0.65rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vis-stat-pill .value {
  font-size: 0.92rem;
  font-weight: 700;
  color: #38bdf8;
}

/* Category Tabs */
.vis-category-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.4rem;
  background: rgba(10, 16, 29, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  margin-bottom: 1.25rem;
  scrollbar-width: thin;
}

.vis-cat-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem;
  border-radius: 0.75rem;
  font-family: var(--font-outfit);
  font-size: 0.86rem;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.vis-cat-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.vis-cat-btn.active {
  color: #030712;
  background: var(--lime);
  border-color: var(--lime);
  font-weight: 800;
  box-shadow: 0 0 20px rgba(0, 245, 155, 0.4);
}

.vis-cat-btn svg {
  width: 17px;
  height: 17px;
}

/* Action Control Toolbar */
.vis-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(12px);
}

.vis-ops-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.vis-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.vis-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
  border-color: rgba(0, 245, 155, 0.4);
}

.vis-btn-primary {
  background: linear-gradient(135deg, rgba(0, 245, 155, 0.2) 0%, rgba(0, 210, 255, 0.2) 100%);
  color: var(--lime);
  border: 1px solid rgba(0, 245, 155, 0.4);
}

.vis-btn-primary:hover {
  background: var(--lime);
  color: #030712;
  box-shadow: 0 0 15px rgba(0, 245, 155, 0.4);
}

.vis-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.vis-btn-danger:hover {
  background: #ef4444;
  color: #fff;
}

.vis-input-field {
  padding: 0.48rem 0.8rem;
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #fff;
  outline: none;
  width: 120px;
  transition: border-color 0.2s;
}

.vis-input-field:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 2px rgba(0, 245, 155, 0.2);
}

.vis-input-wide {
  width: 240px;
}

.vis-mode-switch {
  display: flex;
  align-items: center;
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.6rem;
  padding: 2px;
}

.vis-mode-opt {
  padding: 0.35rem 0.75rem;
  border-radius: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.vis-mode-opt.active {
  background: rgba(0, 245, 155, 0.2);
  color: var(--lime);
  border: 1px solid rgba(0, 245, 155, 0.3);
}

/* Category-Specific Toolbar Panels */
.category-ops-panel {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.category-ops-panel.active {
  display: flex;
}

/* Main Visualizer Split Layout */
.vis-stage-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
  .vis-stage-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Canvas Stage */
.vis-canvas-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vis-viewport-frame {
  background: var(--vis-canvas-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), inset 0 0 80px rgba(0, 245, 155, 0.02);
  display: flex;
  flex-direction: column;
}

.vis-viewport-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.vis-vp-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vis-vp-badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(0, 210, 255, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(0, 210, 255, 0.3);
}

/* SVG Rendering Canvas */
.vis-svg-viewport {
  width: 100%;
  height: 400px;
  background: radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.5) 0%, rgba(2, 6, 23, 0.95) 100%);
  display: block;
  user-select: none;
}

/* Dual View: Array Memory Buffer */
.vis-array-viewport {
  background: rgba(8, 14, 29, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem 1.25rem;
}

.vis-array-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.vis-array-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.vis-array-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.vis-array-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.6rem;
  overflow: hidden;
  transition: all 0.2s ease;
  cursor: pointer;
}

.vis-array-cell:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.vis-array-cell.comparing {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.vis-array-cell.swapping {
  border-color: #d946ef;
  background: rgba(217, 70, 239, 0.18);
  box-shadow: 0 0 12px rgba(217, 70, 239, 0.4);
}

.vis-array-cell.sorted {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

.vis-cell-idx {
  width: 100%;
  text-align: center;
  padding: 0.2rem 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #64748b;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.vis-cell-val {
  padding: 0.6rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.vis-cell-addr {
  width: 100%;
  text-align: center;
  padding: 0.15rem 0;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: #475569;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* Right Transparency Panel */
.vis-sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vis-card {
  background: var(--vis-panel-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
}

.vis-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.15rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.vis-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Narration Box */
.vis-narration-body {
  padding: 1.15rem;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.vis-step-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--lime);
  background: rgba(0, 245, 155, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  margin-bottom: 0.5rem;
  width: fit-content;
}

.vis-narration-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e2e8f0;
}

.vis-narration-text strong {
  color: #38bdf8;
  font-weight: 700;
}

/* Pseudocode Window */
.vis-code-body {
  background: #020617;
  padding: 0.75rem 0;
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.6;
}

.vis-code-line {
  display: flex;
  align-items: flex-start;
  padding: 0.15rem 1rem;
  color: #94a3b8;
  transition: all 0.15s ease;
  white-space: pre;
}

.vis-code-line.active {
  background: rgba(0, 245, 155, 0.18);
  color: #fff;
  font-weight: 700;
  border-left: 3px solid var(--lime);
}

.vis-line-num {
  width: 28px;
  color: #475569;
  user-select: none;
  font-size: 0.7rem;
}

/* Invariants & Complexity */
.vis-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.vis-meta-table td {
  padding: 0.55rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.vis-meta-table tr:last-child td {
  border-bottom: none;
}

.vis-meta-table .key {
  color: #64748b;
  width: 40%;
}

.vis-meta-table .val {
  color: #f1f5f9;
  font-weight: 600;
}

.vis-meta-table .val.lime {
  color: var(--lime);
}

/* Bottom VCR Playback Controls */
.vis-vcr-dock {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: calc(100% - 3rem);
  max-width: 1200px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(0, 245, 155, 0.35);
  border-radius: 1.25rem;
  padding: 0.85rem 1.5rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 30px rgba(0, 245, 155, 0.15);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.vis-vcr-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.vcr-ctrl-btn {
  width: 38px;
  height: 38px;
  border-radius: 0.6rem;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.vcr-ctrl-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
  border-color: rgba(0, 245, 155, 0.4);
}

.vcr-ctrl-btn.play-btn {
  width: 44px;
  height: 44px;
  background: var(--lime);
  color: #030712;
  border-color: var(--lime);
  box-shadow: 0 0 16px rgba(0, 245, 155, 0.4);
}

.vcr-ctrl-btn.play-btn:hover {
  transform: scale(1.05);
}

.vis-vcr-scrubber-group {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.vis-timeline-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.vis-timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px rgba(0, 245, 155, 0.6);
  cursor: pointer;
  transition: transform 0.1s;
}

.vis-timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.vis-vcr-step-counter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #38bdf8;
  white-space: nowrap;
}

.vis-vcr-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.vis-speed-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.6rem;
  padding: 2px;
}

.vis-speed-btn {
  padding: 0.3rem 0.6rem;
  border-radius: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
}

.vis-speed-btn.active {
  background: rgba(0, 245, 155, 0.2);
  color: var(--lime);
}
