/* ==========================================================================
   DOUSEA SYSTEMS — INDUSTRIAL NETWORKING LAB STYLES
   Matches plc-lab.css dark controls aesthetic with Purdue-layered canvas
   ========================================================================== */

body.net-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 18% 0%, rgba(14, 165, 233, 0.13), transparent 44%),
              radial-gradient(circle at 86% 12%, rgba(99, 102, 241, 0.12), transparent 42%),
              #070d1c;
}

#dousea-site-nav,
.net-topbar {
  flex-shrink: 0;
}

.net-topbar {
  border-bottom: 1px solid rgba(99, 134, 204, 0.22);
  background: rgba(11, 18, 34, 0.92);
  backdrop-filter: blur(10px);
  z-index: 80;
}

.net-topbar-inner {
  max-width: 1720px;
  margin: 0 auto;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.net-tool-group {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(99, 134, 204, 0.28);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.net-tool-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.net-tool-btn:hover { color: #e2e8f0; background: rgba(56, 189, 248, 0.1); }
.net-tool-btn.active {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.35);
}
.net-tool-btn.wire-active {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}
.net-tool-btn.del-active {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

/* Main 3-Column Shell — Independently Scrollable Panes on Desktop (matching PLC Lab) */
.net-shell {
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 14px 0 16px;
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr) 316px;
  gap: 12px;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.net-sidebar,
.net-center-col,
.net-right-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 14px 6px 28px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 134, 204, 0.35) transparent;
  scrollbar-gutter: stable;
}

.net-sidebar > *,
.net-center-col > *,
.net-right-col > * {
  flex-shrink: 0;
}

.net-sidebar::-webkit-scrollbar,
.net-center-col::-webkit-scrollbar,
.net-right-col::-webkit-scrollbar {
  width: 6px;
}
.net-sidebar::-webkit-scrollbar-track,
.net-center-col::-webkit-scrollbar-track,
.net-right-col::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}
.net-sidebar::-webkit-scrollbar-thumb,
.net-center-col::-webkit-scrollbar-thumb,
.net-right-col::-webkit-scrollbar-thumb {
  background: rgba(99, 134, 204, 0.32);
  border-radius: 999px;
}
.net-sidebar::-webkit-scrollbar-thumb:hover,
.net-center-col::-webkit-scrollbar-thumb:hover,
.net-right-col::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.52);
}

.net-center-col {
  min-width: 0;
}

/* Packet Speed Switch (matches PLC Lab RUN/SLOW/STEP) */
.net-speed-switch {
  display: inline-flex;
  align-items: center;
  background: rgba(11, 18, 35, 0.95);
  border: 1px solid rgba(99, 134, 204, 0.32);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.net-speed-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s ease;
}
.net-speed-btn:hover { color: #fff; }
.net-speed-btn.active[data-speed="normal"] { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.net-speed-btn.active[data-speed="slow"]   { background: rgba(56, 189, 248, 0.24); color: #38bdf8; }
.net-speed-btn.active[data-speed="step"]   { background: rgba(168, 85, 247, 0.26); color: #c084fc; }

.net-card {
  background: rgba(13, 22, 42, 0.9);
  border: 1px solid rgba(99, 134, 204, 0.24);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.35);
}

.net-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(99, 134, 204, 0.16);
}

.net-card-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Canvas Workspace */
.net-canvas-wrap {
  position: relative;
  width: 100%;
  background: radial-gradient(circle at 50% 45%, rgba(15, 29, 56, 0.85), rgba(7, 13, 28, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.net-canvas-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 920 / 540;
  cursor: default;
}

.net-canvas-wrap.mode-wire .net-canvas-svg { cursor: crosshair; }
.net-canvas-wrap.mode-delete .net-canvas-svg { cursor: not-allowed; }
.net-canvas-wrap.drag-over {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35) inset;
}

.net-canvas-banner {
  display: none;
  padding: 7px 12px;
  background: rgba(16, 185, 129, 0.14);
  border-bottom: 1px solid rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
  font-size: 0.76rem;
  font-weight: 700;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.net-canvas-banner.open { display: flex; }

.net-node-g { cursor: grab; }
.net-node-g:active { cursor: grabbing; }
.net-canvas-wrap.mode-wire .net-node-g { cursor: crosshair; }
.net-link-hit { cursor: pointer; }
.net-link-hit:hover + .net-link-line { stroke-width: 4.5; filter: drop-shadow(0 0 7px rgba(56, 189, 248, 0.75)); }

/* Live Magnetic Cable Preview */
@keyframes netWireFlow {
  from { stroke-dashoffset: 24; }
  to   { stroke-dashoffset: 0; }
}
.net-wire-preview-path {
  fill: none;
  stroke-linecap: round;
  animation: netWireFlow 0.7s linear infinite;
}
.net-wire-preview-path.snapped {
  animation: none;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.85));
}
.net-wire-preview-path.snapped.invalid {
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.85));
}

/* Contextual Floating Device & Cable Action Popover */
.net-canvas-popover {
  position: absolute;
  z-index: 40;
  min-width: 214px;
  max-width: 256px;
  background: rgba(11, 20, 39, 0.97);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(2, 6, 23, 0.78), 0 0 0 1px rgba(15, 23, 42, 0.9) inset;
  backdrop-filter: blur(12px);
  padding: 9px;
  animation: netPopIn 0.13s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes netPopIn {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.net-pop-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 3px 8px;
  margin-bottom: 7px;
  border-bottom: 1px solid rgba(99, 134, 204, 0.2);
}
.net-pop-icon {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}
.net-pop-meta {
  min-width: 0;
  flex: 1;
}
.net-pop-title {
  font-size: 0.79rem;
  font-weight: 800;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.net-pop-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  color: #7dd3fc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.net-pop-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.78rem;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
}
.net-pop-close:hover { color: #f8fafc; background: rgba(148, 163, 184, 0.16); }
.net-pop-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.net-pop-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(99, 134, 204, 0.24);
  background: rgba(18, 31, 58, 0.85);
  color: #e2e8f0;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
}
.net-pop-btn:hover {
  background: rgba(30, 52, 92, 0.95);
  border-color: rgba(56, 189, 248, 0.55);
  color: #fff;
}
.net-pop-btn.primary {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}
.net-pop-btn.primary:hover {
  background: rgba(14, 165, 233, 0.34);
  border-color: #38bdf8;
  color: #fff;
}
.net-pop-btn.wire {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}
.net-pop-btn.wire:hover {
  background: rgba(16, 185, 129, 0.32);
  border-color: #34d399;
  color: #fff;
}
.net-pop-btn.danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.42);
  color: #fca5a5;
}
.net-pop-btn.danger:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: #f87171;
  color: #fff;
}

/* Hop Trace Console */
.net-trace-console {
  margin-top: 8px;
  background: #070d1a;
  border: 1px solid rgba(99, 134, 204, 0.24);
  border-radius: 10px;
  padding: 10px 12px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.76rem;
}

.net-trace-hop {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.net-trace-hop:last-child { margin-bottom: 0; }
.net-trace-hop.fail { color: #fca5a5; }
.net-trace-hop.ok { color: #cbd5e1; }
.net-trace-hop.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.16);
}
.net-trace-hop.active.return-phase {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.55);
}
.net-trace-hop.active.fail {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.65);
}
.net-trace-hop.pending {
  opacity: 0.3;
}
.net-trace-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

@keyframes netPulseRing {
  0%   { opacity: 0.95; stroke-width: 3; }
  50%  { opacity: 0.35; stroke-width: 6; }
  100% { opacity: 0.95; stroke-width: 3; }
}
.net-active-node-halo {
  animation: netPulseRing 0.9s ease-in-out infinite;
}

@keyframes netLoopDash {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}
.net-loop-link {
  animation: netLoopDash 0.85s linear infinite;
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.72));
}
.net-trace-hop.storm {
  background: rgba(239, 68, 68, 0.11);
  border-color: rgba(239, 68, 68, 0.32);
}
.net-trace-hop.storm.active {
  background: rgba(239, 68, 68, 0.24);
  border-color: rgba(248, 113, 113, 0.8);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.28);
}

/* Device Palette (Right Sidebar) */
.net-pal-cat {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7dd3fc;
  margin: 8px 0 6px;
}
.net-pal-cat:first-child { margin-top: 0; }

.net-pal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.net-pal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(15, 29, 56, 0.78);
  border: 1px solid rgba(99, 134, 204, 0.26);
  color: #e2e8f0;
  cursor: grab;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.net-pal-item:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(20, 40, 74, 0.92);
}
.net-pal-item:active { cursor: grabbing; }
.net-pal-icon { font-size: 1.2rem; line-height: 1; }
.net-pal-name { font-size: 0.72rem; font-weight: 700; line-height: 1.2; }

/* Probe Controls */
.net-port-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.net-port-chip {
  border: 1px solid rgba(99, 134, 204, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: #93c5fd;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
}
.net-port-chip:hover,
.net-port-chip.active {
  background: rgba(14, 165, 233, 0.22);
  border-color: #38bdf8;
  color: #fff;
}

/* Health Issues List */
.net-issue-row {
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 0.74rem;
  line-height: 1.4;
  margin-bottom: 6px;
}
.net-issue-row.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}
.net-issue-row.warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

/* Device Config Modal Tables */
.net-cfg-section {
  background: rgba(10, 17, 34, 0.78);
  border: 1px solid rgba(99, 134, 204, 0.22);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.net-cfg-section h4 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #7dd3fc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.net-cfg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.net-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.net-mini-table th {
  text-align: left;
  color: #94a3b8;
  font-size: 0.68rem;
  text-transform: uppercase;
  padding: 5px 6px;
  border-bottom: 1px solid rgba(99, 134, 204, 0.2);
}
.net-mini-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(99, 134, 204, 0.1);
  vertical-align: middle;
}
.net-mini-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(99, 134, 204, 0.32);
  border-radius: 6px;
  color: #f8fafc;
  padding: 5px 7px;
  font-size: 0.76rem;
  font-family: 'JetBrains Mono', monospace;
}
.net-mini-input:focus {
  outline: none;
  border-color: #38bdf8;
}
.net-mini-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 1260px) {
  body.net-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .net-shell {
    grid-template-columns: 1fr;
    overflow: visible;
    flex: none;
    padding: 14px 14px 28px;
  }
  .net-sidebar,
  .net-center-col,
  .net-right-col {
    height: auto;
    overflow: visible;
    padding: 0;
  }
  .net-pal-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}
