/**
 * Circloud GUI - Topology Visualization Styles
 */

.topology-container {
  display: flex;
  gap: 0;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.topology-left {
  flex: 0 0 28.35%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, rgba(7, 10, 22, 0.96) 0%, rgba(9, 12, 28, 0.96) 55%, rgba(6, 8, 18, 0.98) 100%);
  border-radius: 8px;
  border: 1px solid rgba(94, 203, 255, 0.12);
  overflow: hidden;
  min-width: 260px;
  min-height: 0;
  position: relative;
  box-shadow: var(--shadow);
}

.topology-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(520px 320px at 8% 0%, rgba(94, 203, 255, 0.16) 0%, transparent 70%),
    radial-gradient(480px 320px at 95% 100%, rgba(107, 92, 255, 0.14) 0%, transparent 72%);
  background-size: auto, auto;
  background-position: 0 0, 0 0;
  background-repeat: no-repeat;
  opacity: 0.28;
  filter: blur(3px);
  pointer-events: none;
  z-index: 0;
}

.topology-left > * {
  position: relative;
  z-index: 1;
}

.topology-json-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  min-height: 28px;
  background: var(--surface-light);
  border-bottom: 1px solid var(--border);
}

.topology-json-header h4 {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topology-json-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.topology-json-actions .copy-btn {
  padding: 2px 6px;
}

.topology-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.topology-action-btn:hover {
  background: rgba(107, 92, 255, 0.2);
  border-color: var(--border-light);
}

.topology-apply-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.topology-apply-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
}

.topology-json-hint {
  margin: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.topology-json {
  flex: 1;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  border: 1px solid rgba(94, 203, 255, 0.16);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.4);
  background:
    linear-gradient(160deg, rgba(7, 10, 22, 0.92) 0%, rgba(10, 14, 28, 0.92) 60%, rgba(6, 8, 18, 0.95) 100%);
  background-size: auto;
  background-position: 0 0;
  background-repeat: no-repeat;
  white-space: pre;
  tab-size: 2;
}

.topology-json .json-key {
  color: #7dd3fc;
  font-weight: 600;
}

.topology-json .json-string {
  color: #86efac;
}

.topology-json .json-number {
  color: #fca5a5;
}

.topology-json .json-boolean {
  color: #fde047;
}

.topology-json .json-null {
  color: #c4b5fd;
}

.topology-json .json-brace {
  color: #e2c27d;
  font-weight: 600;
}

.topology-json:focus {
  outline: 1px solid var(--secondary);
  border-color: var(--secondary);
}

.topology-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, rgba(6, 9, 20, 0.98) 0%, rgba(8, 12, 26, 0.96) 60%, rgba(5, 7, 18, 0.99) 100%);
  border-radius: 10px;
  border: 1px solid rgba(94, 203, 255, 0.12);
  overflow: hidden;
  min-width: 320px;
  min-height: 0;
  position: relative;
  box-shadow: var(--shadow);
}

.topology-right::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(520px 320px at 8% 0%, rgba(94, 203, 255, 0.16) 0%, transparent 70%),
    radial-gradient(480px 320px at 95% 100%, rgba(107, 92, 255, 0.14) 0%, transparent 72%);
  background-size: auto, auto;
  background-position: 0 0, 0 0;
  background-repeat: no-repeat;
  opacity: 0.26;
  filter: blur(3px);
  pointer-events: none;
  z-index: 0;
}

.topology-right > * {
  position: relative;
  z-index: 1;
}

.topology-resizer {
  flex: 0 0 10px;
  width: 10px;
  align-self: stretch;
  cursor: col-resize;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0.26));
  border-left: 1px solid rgba(148, 163, 184, 0.2);
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  transition: background 0.2s ease;
  user-select: none;
  z-index: 2;
}

.topology-resizer:hover,
.topology-resizer.active {
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.25), rgba(96, 165, 250, 0.5));
}

.topology-canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  min-height: 28px;
  background: var(--surface-light);
  border-bottom: 1px solid var(--border);
}

.topology-canvas-header h4 {
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topology-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topology-ctrl-btn {
  background: var(--glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topology-ctrl-btn:hover {
  background: rgba(107, 92, 255, 0.2);
  border-color: var(--border-light);
  color: var(--text);
}

.topology-canvas-container {
  flex: 1;
  position: relative;
  min-height: 400px;
}

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

.topology-svg-container {
  flex: 1;
  position: relative;
  min-height: 450px;
  background: linear-gradient(160deg, rgba(6, 9, 20, 0.98) 0%, rgba(8, 12, 26, 0.96) 60%, rgba(5, 7, 18, 0.99) 100%);
  overflow: hidden;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topology-svg-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(520px 320px at 10% 0%, rgba(94, 203, 255, 0.16) 0%, transparent 70%),
    radial-gradient(480px 320px at 95% 100%, rgba(107, 92, 255, 0.14) 0%, transparent 72%);
  background-size: auto, auto;
  background-position: 0 0, 0 0;
  background-repeat: no-repeat;
  opacity: 0.22;
  filter: blur(3px);
  pointer-events: none;
  z-index: 0;
}

.topology-svg-container > * {
  position: relative;
  z-index: 1;
}

.topology-svg-container svg {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
}

.topology-svg-container svg .deleting {
  opacity: 0.45;
  filter: grayscale(0.65);
}

.topology-svg-container .empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #8b949e;
  font-size: 14px;
}

.topology-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.legend-color--internet {
  background: #7dd3fc;
}

.legend-color--vpc {
  background: #34d399;
}

.legend-color--subnet {
  background: #60a5fa;
}

.legend-color--pod {
  background: #fb923c;
}

.legend-color--replica {
  background: #7ea6ff;
}

.legend-color--tunnel {
  background: #f2a65a;
}

.legend-probe {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #1a1a2e;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.legend-probe--autoheal {
  background: #22c55e;
}

.legend-probe--persistent {
  background: #5ecbff;
}

.legend-probe--autoscale {
  background: #a78bfa;
}

.legend-probe--tunnel {
  background: #f2a65a;
}

.legend-probe--delete {
  background: #ef4444;
}

.legend-console {
  width: 16px;
  height: 12px;
  border: 1px solid #94a3b8;
  border-radius: 2px;
  display: inline-block;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.legend-console::before,
.legend-console::after {
  content: '';
  position: absolute;
  left: 3px;
  height: 1px;
  background: #cbd5f5;
}

.legend-console::before {
  top: 4px;
  width: 5px;
}

.legend-console::after {
  top: 7px;
  width: 7px;
}

/* CIRSYNC:card-header-unified-topology */
.card-header-unified,
.card-header-blue,
.topology-json-header,
.topology-canvas-header {
  padding: 3px 8px !important;
  min-height: 24px !important;
  display: flex !important;
  align-items: center !important;
  background: linear-gradient(135deg, rgba(5, 20, 54, 0.7) 0%, rgba(15, 52, 118, 0.7) 52%, rgba(28, 96, 172, 0.7) 100%) !important;
  border-bottom: 1px solid rgba(8, 18, 38, 0.72) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 18px rgba(4, 20, 56, 0.45) !important;
  backdrop-filter: blur(14px);
}

/* Collapsible JSON blocks */
.topology-json .json-toggle {
  cursor: pointer;
  user-select: none;
  color: #64748b;
  font-size: 9px;
  margin-right: 2px;
  display: inline;
}
.topology-json .json-toggle:hover { color: #94a3b8; }
.topology-json .json-block.collapsed > .json-collapsible-body { display: none; }
.topology-json .json-block.collapsed > .json-collapsible-hint { display: inline; }
.topology-json .json-block.collapsed > .json-toggle { display: inline-block; transform: rotate(-90deg); }
.topology-json .json-collapsible-hint {
  display: none;
  color: #64748b;
  font-size: 10px;
  font-style: italic;
  margin: 0 4px;
}
.topology-json .json-collapsible-body { display: inline; }

/* Scrollbar styling */
.topology-json::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.topology-json::-webkit-scrollbar-track {
  background: #0d1117;
}

.topology-json::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 4px;
}

.topology-json::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .topology-container {
    flex-direction: column;
    height: auto;
  }

  .topology-left {
    flex: none;
    height: 250px;
  }

  .topology-right {
    flex: none;
    height: 450px;
  }
}
