/* Circuit Lab — Teoría de Circuitos style (dark / neon) */

:root {
  --cl-bg: #0a192f;
  --cl-panel: rgba(17, 34, 64, 0.95);
  --cl-accent: #64ffda;
  --cl-green: #00ff9d;
  --cl-text: #a8b2d1;
  --cl-grid: rgba(100, 255, 218, 0.06);
}

.circuit-lab-root {
  margin: 0;
  color: var(--cl-text);
  font-family: "Fira Code", "Consolas", monospace;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.circuit-lab-root *,
.circuit-lab-root *::before,
.circuit-lab-root *::after {
  box-sizing: border-box;
}

.circuit-lab-root .subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin: 0 0 0.75rem;
  flex-shrink: 0;
}

.circuit-lab-layout {
  display: grid;
  grid-template-columns: 140px 1fr 300px;
  gap: 0.75rem;
  min-height: 70vh;
}

@media (max-width: 1100px) {
  .circuit-lab-layout {
    grid-template-columns: 1fr;
  }
}

.cl-palette {
  background: var(--cl-panel);
  border: 1px solid rgba(0, 255, 157, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cl-palette h3 {
  color: var(--cl-accent);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.35rem;
}

.cl-part {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border: 1px dashed rgba(100, 255, 218, 0.25);
  border-radius: 6px;
  cursor: grab;
  font-size: 0.78rem;
  color: var(--cl-text);
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.cl-part:hover {
  background: rgba(0, 255, 157, 0.06);
  border-color: rgba(0, 255, 157, 0.35);
}

.cl-part:active {
  cursor: grabbing;
}

.cl-part .sym {
  width: 36px;
  height: 28px;
  flex-shrink: 0;
}

.cl-part .sym.cl-sym {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cl-green);
}

.cl-part .sym.cl-sym svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.cl-btn {
  background: transparent;
  border: 1px solid rgba(0, 255, 157, 0.45);
  color: var(--cl-green);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.cl-btn:hover {
  background: rgba(0, 255, 157, 0.1);
}

.cl-btn.active {
  background: rgba(0, 255, 157, 0.2);
  border-color: var(--cl-green);
}

.cl-btn-primary {
  background: rgba(0, 255, 157, 0.15);
}

.cl-mode-hint {
  font-size: 0.75rem;
  opacity: 0.8;
}

.cl-canvas-wrap {
  position: relative;
  background: rgba(10, 25, 47, 0.6);
  border: 1px solid rgba(0, 255, 157, 0.25);
  border-radius: 8px;
  overflow: auto;
  min-height: 420px;
}

#circuitSvg {
  display: block;
  min-width: 800px;
  min-height: 480px;
}

.cl-side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cl-panel {
  background: var(--cl-panel);
  border: 1px solid rgba(0, 255, 157, 0.15);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.8rem;
}

.cl-panel h3 {
  color: var(--cl-accent);
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}

.cl-panel label {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  opacity: 0.9;
}

.cl-panel input[type="number"],
.cl-panel select {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.35rem;
  background: rgba(10, 25, 47, 0.8);
  border: 1px solid rgba(0, 255, 157, 0.35);
  color: var(--cl-text);
  border-radius: 4px;
  font-family: inherit;
}

.cl-num-input {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.45rem;
  background: rgba(10, 25, 47, 0.8);
  border: 1px solid rgba(0, 255, 157, 0.35);
  color: var(--cl-text);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
}

.cl-results {
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

#scopeCanvas {
  width: 100%;
  height: 180px;
  background: #050d18;
  border-radius: 6px;
  border: 1px solid rgba(0, 255, 157, 0.2);
}

.cl-probe-list {
  font-size: 0.72rem;
  margin-top: 0.35rem;
  max-height: 80px;
  overflow-y: auto;
}

.cl-error {
  color: #ff6b6b;
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

.cl-legend {
  font-size: 0.65rem;
  opacity: 0.75;
  margin-top: 0.5rem;
}

.interact-btn.open-circuit-lab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--cl-green);
  color: var(--cl-green);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.interact-btn.open-circuit-lab:hover {
  background: rgba(0, 255, 157, 0.1);
  transform: translateY(-1px);
}

/* Modal embebido en Data Lab */
#circuitLabModal .modal-content.circuit-lab-modal-content {
  max-width: 1400px;
  width: 98%;
  max-height: 95vh;
  height: 95vh;
  padding-top: 2.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 157, 0.5) rgba(10, 25, 47, 0.95);
}

#circuitLabModal .modal-content.circuit-lab-modal-content::-webkit-scrollbar {
  width: 12px;
}

#circuitLabModal .modal-content.circuit-lab-modal-content::-webkit-scrollbar-track {
  background: rgba(10, 25, 47, 0.9);
  border-radius: 6px;
}

#circuitLabModal .modal-content.circuit-lab-modal-content::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 157, 0.35);
  border-radius: 6px;
  border: 2px solid rgba(10, 25, 47, 0.9);
}

#circuitLabModal .modal-content.circuit-lab-modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 157, 0.55);
}

#circuitLabModal .modal-content.circuit-lab-modal-content > h3 {
  flex-shrink: 0;
  margin: 0 0 0.35rem;
  padding-right: 2.5rem;
  color: var(--cl-green);
  font-size: 1.25rem;
}

#circuitLabModal .circuit-lab-root {
  flex: 1;
  min-height: 0;
}

#circuitLabModal .circuit-lab-layout {
  flex: 1;
  min-height: 0;
  grid-template-columns: 118px minmax(180px, 1fr) minmax(400px, min(560px, 40vw));
  gap: 0.65rem;
  align-content: stretch;
}

#circuitLabModal .cl-canvas-wrap {
  min-height: 200px;
  max-height: 100%;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 157, 0.5) rgba(10, 25, 47, 0.95);
}

#circuitLabModal #circuitSvg {
  min-width: 520px;
  min-height: 360px;
}

#circuitLabModal .cl-side {
  overflow-y: auto;
  max-height: 100%;
  min-width: 0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 157, 0.5) rgba(10, 25, 47, 0.95);
}

#circuitLabModal .cl-side::-webkit-scrollbar {
  width: 12px;
}

#circuitLabModal .cl-side::-webkit-scrollbar-track {
  background: rgba(10, 25, 47, 0.9);
  border-radius: 6px;
}

#circuitLabModal .cl-side::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 157, 0.35);
  border-radius: 6px;
  border: 2px solid rgba(10, 25, 47, 0.9);
}

#circuitLabModal .cl-side::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 157, 0.55);
}

#circuitLabModal .cl-canvas-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

#circuitLabModal .cl-canvas-wrap::-webkit-scrollbar-track {
  background: rgba(10, 25, 47, 0.9);
  border-radius: 6px;
}

#circuitLabModal .cl-canvas-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 157, 0.35);
  border-radius: 6px;
  border: 2px solid rgba(10, 25, 47, 0.9);
}

#circuitLabModal .cl-canvas-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 157, 0.55);
}

#circuitLabModal .cl-results,
#circuitLabModal .cl-probe-list {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 255, 218, 0.55) rgba(10, 25, 47, 0.9);
}

#circuitLabModal .cl-results::-webkit-scrollbar,
#circuitLabModal .cl-probe-list::-webkit-scrollbar {
  width: 10px;
}

#circuitLabModal .cl-results::-webkit-scrollbar-track,
#circuitLabModal .cl-probe-list::-webkit-scrollbar-track {
  background: rgba(10, 25, 47, 0.85);
  border-radius: 5px;
}

#circuitLabModal .cl-results::-webkit-scrollbar-thumb,
#circuitLabModal .cl-probe-list::-webkit-scrollbar-thumb {
  background: rgba(100, 255, 218, 0.4);
  border-radius: 5px;
}

#circuitLabModal .cl-results::-webkit-scrollbar-thumb:hover,
#circuitLabModal .cl-probe-list::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 255, 218, 0.6);
}

#circuitLabModal .cl-panel {
  padding: 1rem 1.1rem;
  font-size: 0.88rem;
}

#circuitLabModal .cl-panel h3 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  letter-spacing: 0.02em;
}

#circuitLabModal .cl-panel label {
  font-size: 0.8rem;
  margin-top: 0.55rem;
}

#circuitLabModal .cl-panel input[type="number"],
#circuitLabModal .cl-panel select {
  padding: 0.5rem 0.45rem;
  font-size: 0.85rem;
}

#circuitLabModal .cl-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

#circuitLabModal .cl-toolbar .cl-btn {
  padding: 0.4rem 0.75rem;
}

#circuitLabModal .cl-results {
  max-height: 220px;
  font-size: 0.8rem;
}

#circuitLabModal #scopeCanvas {
  height: 240px;
}

#circuitLabModal .cl-probe-list,
#circuitLabModal .cl-legend {
  font-size: 0.78rem;
}

.cl-prop-hint {
  font-size: 0.78rem;
  opacity: 0.88;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.cl-select-comp {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.45rem;
  background: rgba(10, 25, 47, 0.8);
  border: 1px solid rgba(0, 255, 157, 0.35);
  color: var(--cl-text);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.82rem;
}

.cl-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0.35rem;
}

.cl-chip {
  background: rgba(0, 255, 157, 0.08);
  border: 1px solid rgba(0, 255, 157, 0.35);
  color: var(--cl-text);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cl-chip:hover {
  background: rgba(0, 255, 157, 0.16);
  border-color: var(--cl-green);
}

.cl-prop-field {
  margin-top: 0.5rem;
}
