/* ── Path Tracer ─────────────────────────────────────────────── */

.pathtrace-page {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Header ─────────────────────────────────────────────────── */

.pt-header {
  display: flex;
  align-items: flex-end;
  gap: 1.2rem;
}

.pt-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-primary, #00ffaa);
  font-family: var(--font-tech, monospace);
  text-shadow: 0 0 18px #00ffaa88;
}

.pt-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted, #667);
  font-family: var(--font-tech, monospace);
  letter-spacing: 0.08em;
  padding-bottom: 0.15rem;
}

/* ── Layout ──────────────────────────────────────────────────── */

.pt-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .pt-body { grid-template-columns: 1fr; }
}

/* ── Agent grid ──────────────────────────────────────────────── */

.pt-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.pt-agent-card {
  background: rgba(0, 255, 170, 0.04);
  border: 1px solid rgba(0, 255, 170, 0.12);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}

.pt-agent-card:hover {
  background: rgba(0, 255, 170, 0.08);
  border-color: rgba(0, 255, 170, 0.3);
}

.pt-agent-card.selected {
  background: rgba(0, 255, 170, 0.14);
  border-color: #00ffaa;
  box-shadow: 0 0 12px #00ffaa33;
}

.pt-agent-card.offline {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.07);
}

.pt-agent-card-order {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.65rem;
  font-family: var(--font-tech, monospace);
  color: #000;
  background: #00ffaa;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.pt-agent-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary, #e0e0e0);
  font-family: var(--font-tech, monospace);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.pt-agent-ip {
  font-size: 0.7rem;
  color: #00ffaa99;
  font-family: monospace;
}

.pt-agent-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
}
.pt-agent-status-dot.online  { background: #00ffaa; box-shadow: 0 0 5px #00ffaa; }
.pt-agent-status-dot.offline { background: #555; }

/* ── Chain visualizer ────────────────────────────────────────── */

.pt-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pt-chain-panel {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 255, 170, 0.14);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pt-chain-title {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #00ffaa88;
  font-family: var(--font-tech, monospace);
  margin-bottom: 0.25rem;
}

.pt-chain-empty {
  font-size: 0.72rem;
  color: #444;
  font-family: var(--font-tech, monospace);
  text-align: center;
  padding: 1rem 0;
}

.pt-chain-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.pt-chain-hop {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pt-chain-hop-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00ffaa22;
  border: 1px solid #00ffaa55;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-family: var(--font-tech, monospace);
  color: #00ffaa;
  flex-shrink: 0;
}

.pt-chain-hop-name {
  font-size: 0.72rem;
  color: #ccc;
  font-family: var(--font-tech, monospace);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pt-chain-arrow {
  font-size: 0.65rem;
  color: #00ffaa55;
  padding-left: 10px;
}

/* Status badges */
.pt-hop-status {
  font-size: 0.6rem;
  font-family: var(--font-tech, monospace);
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  margin-left: auto;
}
.pt-hop-status.pending { background: rgba(255,200,0,0.15); color: #ffc800; border: 1px solid #ffc80033; }
.pt-hop-status.ready   { background: rgba(0,255,170,0.15); color: #00ffaa; border: 1px solid #00ffaa33; }
.pt-hop-status.failed  { background: rgba(255,80,80,0.15);  color: #ff5050; border: 1px solid #ff505033; }

/* ── Action buttons ──────────────────────────────────────────── */

.pt-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: var(--font-tech, monospace);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.pt-btn-primary {
  background: linear-gradient(135deg, #00ffaa22, #00ffaa11);
  border-color: #00ffaa;
  color: #00ffaa;
  text-shadow: 0 0 8px #00ffaa;
}
.pt-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #00ffaa44, #00ffaa22);
  box-shadow: 0 0 14px #00ffaa44;
}
.pt-btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pt-btn-danger {
  background: rgba(255,80,80,0.1);
  border-color: #ff5050;
  color: #ff5050;
}
.pt-btn-danger:hover {
  background: rgba(255,80,80,0.2);
}

.pt-btn-ghost {
  background: transparent;
  border-color: #444;
  color: #888;
}
.pt-btn-ghost:hover {
  border-color: #666;
  color: #aaa;
}

.pt-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Error / status banner ───────────────────────────────────── */

.pt-error-banner {
  background: rgba(255, 80, 80, 0.1);
  border: 1px solid rgba(255,80,80,0.3);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.72rem;
  color: #ff5050;
  font-family: var(--font-tech, monospace);
}

.pt-info-banner {
  background: rgba(0, 200, 255, 0.07);
  border: 1px solid rgba(0, 200, 255, 0.2);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.72rem;
  color: #00c8ff;
  font-family: var(--font-tech, monospace);
}

/* ── QR Modal ────────────────────────────────────────────────── */

.pt-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.pt-modal {
  background: #0e1117;
  border: 1px solid #00ffaa44;
  border-radius: 14px;
  box-shadow: 0 0 60px #00ffaa22;
  padding: 2rem;
  max-width: 520px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  animation: pt-modal-in 0.2s ease;
}

@keyframes pt-modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pt-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #00ffaa;
  font-family: var(--font-tech, monospace);
  text-shadow: 0 0 12px #00ffaa66;
}

.pt-qr-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem;
  background: #000;
  border-radius: 10px;
  border: 1px solid #00ffaa33;
}

.pt-qr-img {
  width: 260px;
  height: 260px;
  image-rendering: pixelated;
}

.pt-config-box {
  background: rgba(0,0,0,0.5);
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.65rem;
  font-family: monospace;
  color: #aaa;
  white-space: pre;
  max-height: 180px;
  overflow: auto;
}

.pt-modal-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pt-hint {
  font-size: 0.65rem;
  color: #555;
  font-family: var(--font-tech, monospace);
  text-align: center;
  line-height: 1.5;
}

/* ── Section label ───────────────────────────────────────────── */

.pt-section-label {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #00ffaa55;
  font-family: var(--font-tech, monospace);
  margin-bottom: 0.4rem;
}

.pt-section-panel {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(0,255,170,0.08);
  border-radius: 10px;
  padding: 1rem;
}

/* Spinner */
.pt-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #00ffaa33;
  border-top-color: #00ffaa;
  border-radius: 50%;
  animation: pt-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes pt-spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .pt-page {
    padding: 0;
  }

  .pt-chain {
    flex-direction: column;
    align-items: stretch;
  }

  .pt-hop-card {
    max-width: 100%;
  }

  .pt-modal-backdrop {
    align-items: flex-end;
    padding: 0.5rem;
  }

  .pt-modal {
    max-width: 100%;
    margin: 0;
    border-radius: 14px 14px 0 0;
    max-height: 90dvh;
    overflow-y: auto;
  }

  .pt-qr-wrap img {
    max-width: min(280px, 100%);
    height: auto;
  }
}
