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

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

.topology-left {
  flex: 0 0 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: 12px;
  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%),
    var(--network-lines-lg);
  background-size: auto, auto, 1400px 900px;
  background-position: 0 0, 0 0, center 10%;
  background-repeat: no-repeat;
  opacity: 0.28;
  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: 10px 12px;
  background: var(--surface-light);
  border-bottom: 1px solid var(--border);
}

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

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

.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);
  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%),
    var(--network-lines-lg);
  background-size: auto, 1400px 900px;
  background-position: 0 0, center 20%;
  background-repeat: no-repeat;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.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: 12px;
  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%),
    var(--network-lines-lg);
  background-size: auto, auto, 1400px 900px;
  background-position: 0 0, 0 0, center 10%;
  background-repeat: no-repeat;
  opacity: 0.26;
  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: 10px 12px;
  background: var(--surface-light);
  border-bottom: 1px solid var(--border);
}

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

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

.topology-ctrl-btn {
  background: var(--glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 12px;
  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-x: hidden;
  overflow-y: auto;
  padding: 0;
}

.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%),
    var(--network-lines-lg);
  background-size: auto, auto, 1400px 900px;
  background-position: 0 0, 0 0, center 12%;
  background-repeat: no-repeat;
  opacity: 0.22;
  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: #5bc0ff;
}

.legend-color--vpc {
  background: #6d78ff;
}

.legend-color--subnet {
  background: #9b7bff;
}

.legend-color--pod {
  background: #3ad0b5;
}

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

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

.legend-probe {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  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: #facc15;
  color: #1f2937;
}

.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;
}

/* 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;
  }
}
