/* ==============================================================
 * admin-upstream.css — Obsidian Aurora Upstream/Proxy/System Cards
 * ============================================================== */

/* ─── Upstream Config Card (Generic) ─────────────────────── */
.upstream-card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.upstream-card:hover {
  border-color: rgba(129,140,248,0.12);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.30);
}

/* Upstream Grid */
.upstream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

/* Upstream header row */
.ut-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.ut-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}
.ut-subtitle {
  font-size: 12px;
  color: var(--text-5);
  margin-top: 2px;
}

/* Status badge for upstream */
.ut-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid transparent;
}

/* Upstream info rows */
.ut-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
}
.ut-info-row:last-child { border-bottom: none; }
.ut-info-label { color: var(--text-4); font-weight: 500; }
.ut-info-value { color: var(--text-2); font-weight: 600; font-family: var(--mono); font-size: 12px; }

/* ─── Proxy Pool Card ─────────────────────────────────── */
.proxy-card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
}
.proxy-card:hover {
  border-color: rgba(56,189,248,0.12);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,0.30);
}

.proxy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

/* ─── System Info Cards ────────────────────────────────── */
.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.system-card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: var(--transition);
  border-left: 3px solid rgba(129,140,248,0.35);
}
.system-card:hover {
  border-color: rgba(129,140,248,0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.30);
}
.system-card.mint   { border-left-color: rgba(52,211,153,0.50); }
.system-card.sky    { border-left-color: rgba(56,189,248,0.50); }
.system-card.amber  { border-left-color: rgba(251,191,36,0.50); }
.system-card.violet { border-left-color: rgba(139,92,246,0.50); }

.system-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-4);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.system-card-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.02em;
}
.system-card-sub {
  font-size: 12px;
  color: var(--text-5);
  margin-top: 4px;
}

/* ─── Blocked IPs ──────────────────────────────────────── */
.blocked-ip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.blocked-ip-item {
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: var(--transition);
}
.blocked-ip-item:hover {
  border-color: var(--border-bold);
  background: rgba(255,255,255,0.02);
}
.blocked-ip-address {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.blocked-ip-reason {
  font-size: 12px;
  color: var(--text-4);
}
.blocked-ip-time {
  font-size: 11px;
  color: var(--text-5);
  white-space: nowrap;
}

/* ==============================================================
 * ─── PAIRED GATEWAYS & SYSTEM CONFIGS GRID (Obsidian Aurora) ──
 * ============================================================== */

/* Upstream Configs Grid */
.upstream-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
  padding: 24px;
}

@media (max-width: 900px) {
  .upstream-config-grid {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
}

/* Gateway Pair Card */
.gw-card {
  background: rgba(11, 15, 28, 0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl, 18px);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.gw-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sky, #38bdf8), var(--primary, #818cf8));
  opacity: 0.75;
  transition: opacity 0.25s ease;
}

.gw-card:hover {
  transform: translateY(-3px);
  border-color: rgba(129, 140, 248, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 24px rgba(129, 140, 248, 0.12);
}

.gw-card:hover::before {
  opacity: 1;
}

/* Primary Gateway Card Highlight */
.gw-card-primary {
  background: linear-gradient(150deg, rgba(14, 24, 48, 0.92) 0%, rgba(9, 14, 28, 0.95) 100%);
  border-color: rgba(56, 189, 248, 0.32);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 35px rgba(56, 189, 248, 0.09);
}

.gw-card-primary::before {
  height: 3.5px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
  opacity: 1;
}

.gw-card-primary:hover {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6), 0 0 40px rgba(56, 189, 248, 0.2);
}

/* Card Header */
.gw-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.gw-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.gw-icon-box {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #38bdf8;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.12);
  transition: transform 0.2s ease, background 0.2s ease;
}

.gw-card:hover .gw-icon-box {
  transform: scale(1.06);
  background: rgba(56, 189, 248, 0.18);
}

.gw-icon-box svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.gw-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text-1, #f1f5f9);
  line-height: 1.3;
}

.gw-desc {
  font-size: 12px;
  color: var(--text-4, #64748b);
  margin-top: 3px;
  line-height: 1.4;
}

/* Badges */
.gw-badges,
.uc-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.uc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.uc-badge-protected {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.32);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.12);
}

.uc-badge-custom {
  background: rgba(129, 140, 248, 0.12);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.30);
}

.uc-badge-secret {
  background: rgba(251, 113, 133, 0.12);
  color: #fda4af;
  border: 1px solid rgba(251, 113, 133, 0.30);
}

/* Paired Fields Container */
.gw-fields-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(6, 9, 18, 0.60);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px 16px;
}

.gw-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gw-field-group:not(:last-child) {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.gw-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3, #94a3b8);
}

.gw-key-tag {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 10.5px;
  font-weight: 600;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.12);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(59, 130, 246, 0.22);
}

/* Value Row */
.uc-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(12, 16, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.uc-value-row:hover {
  border-color: rgba(129, 140, 248, 0.28);
  background: rgba(15, 21, 40, 0.85);
}

.uc-value-code {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 12.5px;
  color: #e2e8f0;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.uc-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-3, #94a3b8);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.uc-btn-icon:hover {
  background: rgba(129, 140, 248, 0.16);
  border-color: rgba(129, 140, 248, 0.35);
  color: #fff;
  transform: translateY(-1px);
}

.uc-btn-eye:hover {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}

/* Footer & Actions */
.uc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.uc-updated {
  font-size: 11.5px;
  color: var(--text-4, #64748b);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono, 'IBM Plex Mono', monospace);
}

.uc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Action Buttons */
.uc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  line-height: 1.2;
}

.uc-btn svg {
  flex-shrink: 0;
}

.uc-btn-test {
  background: rgba(52, 211, 153, 0.10);
  border-color: rgba(52, 211, 153, 0.25);
  color: #34d399;
}

.uc-btn-test:hover {
  background: rgba(52, 211, 153, 0.20);
  border-color: rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(52, 211, 153, 0.22);
}

.uc-btn-edit {
  background: rgba(129, 140, 248, 0.10);
  border-color: rgba(129, 140, 248, 0.25);
  color: #818cf8;
}

.uc-btn-edit:hover {
  background: rgba(129, 140, 248, 0.20);
  border-color: rgba(129, 140, 248, 0.45);
  color: #c7d2fe;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(129, 140, 248, 0.22);
}

.uc-btn-del {
  background: rgba(244, 63, 94, 0.10);
  border-color: rgba(244, 63, 94, 0.25);
  color: #f43f5e;
  padding: 7px 10px;
}

.uc-btn-del:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.20);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.22);
}

.uc-btn-del.uc-btn-dis,
.uc-btn-del:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--text-5, #475569);
  pointer-events: none;
}

/* Standalone Config Card */
.uc-card {
  background: rgba(11, 15, 28, 0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl, 18px);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.uc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: linear-gradient(90deg, #64748b, #94a3b8);
  opacity: 0.5;
}

.uc-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.uc-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.uc-key-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.uc-type-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.uc-key-name {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1, #f1f5f9);
}

.uc-key-desc {
  font-size: 12px;
  color: var(--text-4, #64748b);
  margin-top: 2px;
}

/* Skeleton loader */
.uc-skeleton {
  min-height: 240px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.07) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: ucSkeleton 1.6s ease-in-out infinite;
  border-radius: var(--radius-xl, 18px);
}

@keyframes ucSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State */
.upstream-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl, 18px);
}

/* Upstream Test Result Box */
#upstreamTestResult {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(8, 12, 24, 0.9);
  padding: 16px;
}

.ut-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #38bdf8;
  font-size: 13px;
  padding: 8px 0;
}

.ut-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  animation: utPulse 1s infinite alternate;
}

@keyframes utPulse {
  0% { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.3); }
}

.ut-endpoint {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 12px;
  color: var(--text-4, #64748b);
  word-break: break-all;
}

.ut-latency {
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 12px;
  color: #fbbf24;
  margin-left: 8px;
}

.ut-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3, #94a3b8);
  margin-left: 8px;
}

.ut-error {
  padding: 10px 14px;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: 8px;
  color: #fb7185;
  font-size: 12.5px;
  margin-top: 10px;
}

.ut-pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 12px;
  color: #cbd5e1;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 10px;
}

/* Primary Gateway Badge in Quick-Edit */
#upstreamPrimaryBadge {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-family: var(--mono, 'IBM Plex Mono', monospace);
  font-size: 10.5px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}
