/* VibeGDS schematic editor — full-screen overlay (see schematic.js) */
.sch-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: var(--bg); color: var(--text);
  display: grid; grid-template-rows: auto auto 1fr; min-height: 0;
}
.sch-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.sch-toolbar .sch-title { font-weight: 700; margin-right: 4px; }
.sch-toolbar .sch-counts { font-family: var(--mono); font-size: 11px; }
.sch-toolbar .sch-spacer { flex: 1; }
.sch-toolbar .sch-dirty { color: var(--warn); font-size: 11px; font-family: var(--mono); }
#sch-error { max-height: 30vh; border-top: 0; border-bottom: 1px solid #5a2626; }

.sch-body { display: grid; grid-template-columns: 220px 1fr 280px; min-height: 0; grid-row: 3; } /* row 3 even while #sch-error is hidden */
.sch-palette, .sch-props { min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.sch-palette { border-right: 1px solid var(--line); }
.sch-props { border-left: 1px solid var(--line); overflow: auto; padding: 10px 12px; gap: 6px; }
.sch-palette input, .sch-props input:not([type="checkbox"]), .sch-props select, .sch-modal textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
  font-family: var(--mono); font-size: 12px; color: var(--text); outline: none; width: 100%; min-width: 0;
}
.sch-palette input:focus, .sch-props input:focus, .sch-props select:focus { border-color: var(--accent); }
.sch-props select option { background: var(--bg-2); }
.sch-palette input { margin: 10px 10px 6px; width: calc(100% - 20px); }
.sch-cells { flex: 1; overflow: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.sch-cell {
  text-align: left; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.sch-cell:hover { border-color: var(--accent); }
.sch-cell .n { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-cell .pill { padding: 1px 6px; font-size: 10px; flex: none; }
.sch-palette .sch-src { padding: 0 12px 8px; font-size: 11px; }

.sch-canvas-wrap { position: relative; min-width: 0; min-height: 0; background: #070a0e; overflow: hidden; }
#sch-svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; -webkit-user-select: none; }
#sch-svg.panning { cursor: grabbing; }
#sch-svg text { font-family: var(--sans); pointer-events: none; fill: var(--text); }
#sch-svg .sch-inst .box { fill: var(--bg-3); stroke: var(--line); stroke-width: 1.5; cursor: move; }
#sch-svg .sch-inst:hover .box { stroke: #3a4c60; }
#sch-svg .sch-inst.selected .box { stroke: var(--accent); stroke-width: 2; }
#sch-svg .sch-inst .name { font-size: 11px; font-weight: 600; }
#sch-svg .sch-inst .cell { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
#sch-svg .sch-inst .plabel { font-size: 9px; fill: var(--muted); font-family: var(--mono); }
#sch-svg .port { stroke: #070a0e; stroke-width: 1; cursor: crosshair; }
#sch-svg .port.optical { fill: #64d2ff; }
#sch-svg .port.electrical { fill: #fbbf24; }
#sch-svg .port:hover { stroke: #fff; }
#sch-svg .sch-wire .line { fill: none; stroke-width: 2; pointer-events: none; }
#sch-svg .sch-wire.abut .line { stroke-dasharray: 5 4; }
#sch-svg .sch-wire .hit { fill: none; stroke: transparent; stroke-width: 12; cursor: pointer; }
#sch-svg .sch-wire:hover .line { stroke-width: 3; }
#sch-svg .sch-wire.selected .line { stroke: #ffffff; stroke-width: 3; }
#sch-svg .sch-temp { fill: none; stroke: #ffffff; stroke-width: 1.5; stroke-dasharray: 4 3; pointer-events: none; }
#sch-svg .sch-ext .tri { fill: #16324a; stroke: var(--accent); stroke-width: 1.5; }
#sch-svg .sch-ext .tri.electrical { fill: #3a2f10; stroke: #fbbf24; }
#sch-svg .sch-ext text { font-size: 10px; font-family: var(--mono); fill: var(--accent); font-weight: 600; }
#sch-svg .sch-ext text.electrical { fill: #fbbf24; }
.sch-hint {
  position: absolute; left: 10px; bottom: 10px; pointer-events: none; font-size: 11px;
  background: rgba(16, 22, 32, .85); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px;
}
.sch-fit { position: absolute; top: 10px; left: 10px; }

.sch-props h4 { margin: 10px 0 4px; }
.sch-props h4:first-child { margin-top: 2px; }
.sch-field { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.sch-field .k { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-field.check { display: flex; gap: 6px; }
.sch-port-row { display: grid; grid-template-columns: 10px 34px auto 1fr; align-items: center; gap: 6px; font-size: 12px; font-family: var(--mono); }
.sch-port-row .dot { width: 8px; height: 8px; border-radius: 2px; }
.sch-port-row .dot.optical { background: #64d2ff; }
.sch-port-row .dot.electrical { background: #fbbf24; }
.sch-port-row label { color: var(--muted); display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.sch-props .btn.danger { border-color: #5a2626; color: var(--bad); margin-top: 8px; align-self: flex-start; }
.sch-props .sch-empty { color: var(--muted); font-size: 12px; line-height: 1.5; }

.sch-modal { z-index: 30; }
.sch-modal textarea { min-height: 320px; resize: vertical; margin: 12px 16px; width: calc(100% - 32px); white-space: pre; }
.sch-modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 14px; }
.sch-modal .error { margin: 0 16px 12px; border: 1px solid #5a2626; border-radius: 8px; }

@media (max-width: 900px) {
  .sch-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .sch-palette { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: center; }
  .sch-palette input { margin: 6px 10px; width: 160px; flex: none; }
  .sch-cells { flex-direction: row; padding: 6px 10px 6px 0; overflow-x: auto; }
  .sch-cell { flex: none; }
  .sch-palette .sch-src { display: none; }
  .sch-props { border-left: 0; border-top: 1px solid var(--line); max-height: 38vh; }
}
