/* Port Checker — extends ping-tool topology & stats */

/* ── Input panel ── */
.pc-input-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 12px;
  box-sizing: border-box;
}

.pc-input-panel--common {
  grid-template-columns: 1fr;
}

.pc-input-panel--common .pc-field--port {
  display: none;
}

.pc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.pc-field-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--te-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pc-field .te-input,
.pc-field .pt-host-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.pc-port-input {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  padding-left: 8px !important;
  padding-right: 8px !important;
}

.pc-mode {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.pc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  justify-content: center;
  align-items: center;
}

.pc-actions .te-btn {
  min-width: 140px;
}

/* Scan progress */
.pc-progress {
  margin: 16px 0 8px;
}

.pc-progress-track {
  position: relative;
  height: 8px;
  background: rgba(67, 86, 163, 0.1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--te-border);
}

.pc-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4356a3, #0093e9);
  transition: width 0.35s ease;
}

.pc-progress-track--busy .pc-progress-bar {
  width: 38% !important;
  animation: pc-progress-shimmer 1.4s ease-in-out infinite;
}

@keyframes pc-progress-shimmer {
  0% { transform: translateX(-120%); width: 38%; }
  50% { transform: translateX(80%); width: 42%; }
  100% { transform: translateX(220%); width: 38%; }
}

.pc-progress-label {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--te-muted);
  min-height: 18px;
}

.pc-progress-label strong {
  color: var(--te-accent);
  font-variant-numeric: tabular-nums;
}

/* Stats */
.pc-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 12px;
}

.pc-stat {
  text-align: center;
  padding: 12px 4px;
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 10px;
  transition: border-color 0.25s, transform 0.25s;
}

.pc-stat--flash {
  animation: pc-stat-flash 0.45s ease;
}

@keyframes pc-stat-flash {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); border-color: var(--te-accent); }
  100% { transform: scale(1); }
}

.pc-stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--te-muted);
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.pc-stat-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--te-text);
}

.pc-stat-value--open { color: #059669; }
.pc-stat-value--closed { color: #dc2626; }
.pc-stat-value--filtered { color: #ea580c; }
.pc-stat-value--accent { color: var(--te-accent); }

.pc-status-line {
  text-align: center;
  font-size: 13px;
  color: var(--te-muted);
  margin-bottom: 14px;
  min-height: 20px;
  line-height: 1.6;
}

.pc-status-line strong {
  color: var(--te-text);
  font-weight: 800;
}

.pc-status-line code {
  font-size: 12px;
  background: rgba(67, 86, 163, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #4356a3;
}

/* Port chip grid */
.pc-port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 12px;
}

.pc-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1.5px solid rgba(67, 86, 163, 0.16);
  background: #fff;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
  min-height: 54px;
}

.pc-chip-num {
  font-size: 14px;
  font-weight: 800;
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  color: #4356a3;
  direction: ltr;
}

.pc-chip-svc {
  font-size: 9px;
  font-weight: 700;
  color: var(--te-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pc-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(100, 116, 139, 0.35);
}

.pc-chip--scanning {
  border-color: #0093e9;
  background: rgba(0, 147, 233, 0.06);
  box-shadow: 0 0 0 3px rgba(0, 147, 233, 0.1);
  animation: pc-chip-pulse 0.9s ease-in-out infinite;
}

@keyframes pc-chip-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.pc-chip--scanning .pc-chip-dot {
  background: #0093e9;
  animation: pc-dot-blink 0.6s ease-in-out infinite;
}

@keyframes pc-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pc-chip--open {
  border-color: #059669;
  background: rgba(5, 150, 105, 0.08);
}

.pc-chip--open .pc-chip-dot { background: #059669; }
.pc-chip--open .pc-chip-num { color: #059669; }

.pc-chip--closed {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.05);
}

.pc-chip--closed .pc-chip-dot { background: #dc2626; }
.pc-chip--closed .pc-chip-num { color: #991b1b; }

.pc-chip--filtered,
.pc-chip--timeout {
  border-color: rgba(234, 88, 12, 0.35);
  background: rgba(234, 88, 12, 0.06);
}

.pc-chip--filtered .pc-chip-dot,
.pc-chip--timeout .pc-chip-dot {
  background: #ea580c;
}

.pc-chip--revealed {
  animation: pc-chip-reveal 0.35s ease;
}

@keyframes pc-chip-reveal {
  from { opacity: 0.5; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Results table */
.pc-table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--te-border);
  margin-bottom: 14px;
  background: var(--te-card);
}

.pc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pc-table th,
.pc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--te-border);
  vertical-align: middle;
}

.pc-table th {
  background: linear-gradient(90deg, rgba(67, 86, 163, 0.08), rgba(0, 147, 233, 0.06));
  color: #4356a3;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.pc-table td {
  color: var(--te-text);
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  font-size: 12px;
}

.pc-table tr:last-child td { border-bottom: none; }

.pc-table tr.pc-row--new {
  animation: pc-row-in 0.35s ease;
}

@keyframes pc-row-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

.pc-state {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.pc-state--open {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

.pc-state--closed {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.pc-state--filtered,
.pc-state--timeout {
  background: rgba(234, 88, 12, 0.1);
  color: #ea580c;
}

/* Console */
.pc-console-wrap {
  height: 188px;
  min-height: 188px;
  max-height: 188px;
  border: 1px solid var(--te-border);
  border-radius: 10px;
  background: #0c1222;
  overflow: hidden;
}

.pc-console {
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
  padding: 12px 14px;
  font-family: Consolas, 'Cascadia Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #e2e8f0;
  scroll-behavior: smooth;
}

.pc-console-line { white-space: pre-wrap; word-break: break-word; }
.pc-console-line--hint { color: #94a3b8; }
.pc-console-line--head { color: #93c5fd; margin-top: 4px; }
.pc-console-line--open { color: #86efac; }
.pc-console-line--closed { color: #fca5a5; }
.pc-console-line--filtered { color: #fdba74; }
.pc-console-line--scan { color: #cbd5e1; }
.pc-console-line--done { color: #93c5fd; margin-top: 8px; }

.pc-link-port {
  font-size: 11px;
  font-weight: 800;
  color: var(--te-accent);
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  min-height: 16px;
  direction: ltr;
}

@media (max-width: 560px) {
  .pc-input-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .pc-input-panel:not(.pc-input-panel--common) {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .pc-actions .te-btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .pc-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .pc-stat-value {
    font-size: 18px;
  }

  .pc-port-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 10px;
  }

  .pc-chip {
    min-height: 48px;
    padding: 6px 2px;
  }

  .pc-chip-num {
    font-size: 13px;
  }

  .pc-console-wrap {
    height: 150px;
    min-height: 150px;
    max-height: 150px;
  }
}

@media (max-width: 380px) {
  .pc-input-panel:not(.pc-input-panel--common) {
    grid-template-columns: 1fr;
  }
}
