/**
 * Parametric PCB Configurator - Universal Shared Design System & Layout
 * Single Source of Truth for Layout, Viewports, Interactive Tooltips & Cyberpunk Aesthetics
 */

:root {
  --bg-dark: #000000;
  --sidebar-bg: #08080a;
  --neon-lime: #39ff14;
  --neon-magenta: #ff007f;
  --neon-cyan: #00f0ff;
  --neon-orange: #fb923c;
  --neon-purple: #c084fc;
  
  --font-wide: 'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: #fff;
  font-family: var(--font-mono);
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* =========================================================
   APPLICATION CONTAINER & HEADER
   ========================================================= */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: #000;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #0a0a0c;
  border-bottom: 2px solid var(--neon-magenta);
  box-shadow: 0 4px 15px rgba(255, 0, 127, 0.2);
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.back-link {
  color: var(--neon-cyan);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: bold;
  transition: opacity 0.15s;
}
.back-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.header-left h1 {
  font-size: 1.35rem;
  font-family: var(--font-wide);
  color: #fff;
  margin: 0;
  letter-spacing: -0.5px;
}

.badge {
  color: var(--neon-lime);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* =========================================================
   MAIN APPLICATION LAYOUT & SIDEBAR
   ========================================================= */
.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: 360px;
  min-width: 360px;
  height: 100%;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 2px solid var(--neon-lime);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.8);
  scrollbar-width: thin;
  scrollbar-color: var(--neon-lime) #111;
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: #111;
}
.sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, var(--neon-lime), var(--neon-cyan));
  border-radius: 3px;
}

.panel-section {
  background: #111116;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 14px;
}

.panel-section h3 {
  font-family: var(--font-wide);
  font-size: 0.85rem;
  color: var(--neon-cyan);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.param-row label {
  font-size: 0.85rem;
  color: #d1d5db;
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-with-unit input[type="number"] {
  width: 70px;
  background: #000;
  border: 1px solid var(--neon-cyan);
  color: #fff;
  padding: 4px 8px;
  font-family: var(--font-mono);
  text-align: right;
  border-radius: 4px;
  outline: none;
}
.input-with-unit input[type="number"]:focus {
  border-color: var(--neon-lime);
  box-shadow: 0 0 6px rgba(57, 255, 20, 0.4);
}

.param-hint {
  font-size: 0.72rem;
  color: #9ca3af;
  margin-top: -4px;
  margin-bottom: 10px;
  line-height: 1.3;
}

.spec-list {
  list-style: none;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #e5e7eb;
}

.spec-list li {
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.spec-list strong {
  color: var(--neon-lime);
}

/* =========================================================
   BUTTONS & CONTROLS
   ========================================================= */
.btn {
  padding: 8px 14px;
  font-family: var(--font-wide);
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn.primary {
  background: var(--neon-magenta);
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}
.btn.primary:hover:not(:disabled) {
  background: #ff1a8c;
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.7);
  transform: translateY(-1px);
}

.btn.secondary {
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
}
.btn.secondary:hover:not(:disabled) {
  background: #374151;
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn.full-width {
  width: 100%;
  padding: 12px;
}

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

.btn-route-board {
  background: #083344;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 10px;
  border-radius: 4px;
  font-family: var(--font-wide);
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-route-board:hover:not(:disabled) {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.drc-box {
  padding: 8px;
  font-size: 0.8rem;
  text-align: center;
  font-weight: bold;
  border-radius: 4px;
  margin-bottom: 10px;
}
.drc-pass {
  background: rgba(57, 255, 20, 0.15);
  color: var(--neon-lime);
  border: 1px solid var(--neon-lime);
}
.drc-fail {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid #ef4444;
}

.stats-box {
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #9ca3af;
}
.stats-box span {
  color: #fff;
  font-weight: bold;
}

/* Range sliders */
input[type="range"] {
  width: 100%;
  height: 6px;
  background: #222;
  border: 1px solid #444;
  appearance: none;
  outline: none;
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--neon-magenta);
  border: 2px solid #fff;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 0, 127, 0.6);
}

/* =========================================================
   WORKSPACE, TABS & VIEWPORTS (100% Full Height, No Cutoffs)
   ========================================================= */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: #000;
  position: relative;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: #0d0d11;
  border-bottom: 2px solid #1f2937;
  padding: 8px 16px 0;
  gap: 8px;
  z-index: 5;
  flex-shrink: 0;
}

.tab-btn {
  padding: 8px 16px;
  background: #111;
  color: #9ca3af;
  border: 1px solid #1f2937;
  border-bottom: none;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  font-family: var(--font-wide);
  font-size: 0.78rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: none;
  margin: 0;
  transition: all 0.15s ease;
}
.tab-btn:hover {
  color: #fff;
  background: #1c1c24;
}
.tab-btn.active {
  background: #1f2430;
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
  border-bottom: 2px solid var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Viewport Absolute Layer Canvas (Fills entire container) */
.viewport-canvas, .viewport-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #09090b;
}

.viewport-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.viewport-overlay-hint {
  position: absolute;
  bottom: 16px;
  right: 20px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: #9ca3af;
  pointer-events: none;
  z-index: 10;
}

/* =========================================================
   2D INTERACTIVE SVG HOVER TOOLTIPS & NET HIGHLIGHTING
   ========================================================= */
.pcb-2d-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(12, 14, 20, 0.96);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.35), inset 0 0 8px rgba(0, 240, 255, 0.08);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #f3f4f6;
  z-index: 100;
  max-width: 340px;
  line-height: 1.4;
  display: none;
  backdrop-filter: blur(8px);
}
.pcb-2d-tooltip.active {
  display: block;
}

.tooltip-header {
  font-family: var(--font-wide);
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.tooltip-label {
  color: #9ca3af;
  white-space: nowrap;
}

.tooltip-val {
  color: #fff;
  font-weight: bold;
  text-align: right;
  word-break: break-word;
}
.tooltip-val.val-cyan { color: var(--neon-cyan); }
.tooltip-val.val-pink { color: var(--neon-magenta); }
.tooltip-val.val-lime { color: var(--neon-lime); }
.tooltip-val.val-orange { color: var(--neon-orange); }

/* Interactive Hover Highlighting */
.pcb-trace {
  cursor: pointer;
  transition: stroke-width 0.12s ease, filter 0.12s ease;
}

.pcb-trace.net-hovered {
  stroke: #ffffff !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 6px #00f0ff);
}

.pcb-pad, .pcb-hole, .pad-hover-group circle, .pad-hover-group rect {
  cursor: pointer;
  transition: fill 0.12s ease, stroke 0.12s ease, filter 0.12s ease;
}

.pcb-pad.net-hovered, .pcb-hole.net-hovered, .pad-hover-group.net-hovered circle, .pad-hover-group.net-hovered rect {
  fill: #ffffff !important;
  stroke: #00f0ff !important;
  stroke-width: 2.5px !important;
  filter: drop-shadow(0 0 8px #00f0ff);
}

/* =========================================================
   VAPORWAVE CYBERPUNK COMPILATION OVERLAY
   ========================================================= */
.compile-overlay.vaporwave-mode {
  background: radial-gradient(circle at 50% 45%, #18032b 0%, #030008 100%);
  overflow: hidden;
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.compile-overlay.vaporwave-mode.is-visible {
  display: flex;
}

.vaporwave-sun {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #ff007f 0%, #ff8c00 100%);
  box-shadow: 0 0 40px rgba(255, 0, 127, 0.4), 0 0 80px rgba(255, 140, 0, 0.2);
  animation: sun-glitch 4.5s infinite;
}

.vaporwave-sun::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(24, 3, 43, 0) 20%, rgba(3, 0, 8, 1) 95%),
              repeating-linear-gradient(to bottom, transparent, transparent 12px, #030008 12px, #030008 16px);
  border-radius: 50%;
}

.vaporwave-grid {
  position: absolute;
  bottom: 0;
  left: -50%;
  width: 200%;
  height: 45%;
  background-image: 
    linear-gradient(to right, rgba(0, 240, 255, 0.2) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(0, 240, 255, 0.2) 2px, transparent 2px);
  background-size: 50px 50px;
  transform: perspective(220px) rotateX(60deg);
  transform-origin: top center;
  animation: grid-move 2.5s linear infinite;
  mask-image: linear-gradient(to top, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
}

.vaporwave-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 180px;
}

.spinner-neon {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(0, 240, 255, 0.1);
  border-top: 4px solid var(--neon-cyan);
  border-right: 4px solid var(--neon-magenta);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.5, 0.15, 0.45, 0.85) infinite;
  filter: drop-shadow(0 0 6px var(--neon-cyan)) drop-shadow(0 0 6px var(--neon-magenta));
  margin-bottom: 24px;
}

.vaporwave-text {
  font-family: var(--font-wide);
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 10px var(--neon-magenta), 0 0 20px var(--neon-cyan);
  animation: text-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes grid-move {
  from { background-position: 0 0; }
  to { background-position: 0 50px; }
}

@keyframes text-pulse {
  from { opacity: 0.75; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1.03); }
}

@keyframes sun-glitch {
  0%, 91%, 95%, 100% {
    transform: translate(-50%, -50%) skewX(0deg) scale(1);
    filter: hue-rotate(0deg) saturate(1);
  }
  92% {
    transform: translate(-52%, -48%) skewX(-12deg) scaleY(0.85);
    filter: hue-rotate(120deg) saturate(1.8) brightness(1.2);
  }
  93% {
    transform: translate(-48%, -52%) skewX(12deg) scaleX(1.15);
    filter: hue-rotate(-60deg) saturate(2) contrast(1.5);
  }
  94% {
    transform: translate(-50%, -50%) skewX(-5deg) scaleY(1.05);
    filter: hue-rotate(180deg) invert(0.1);
  }
}
