/* ============================================================
   OpenFinClaw Compute — Agents List Page
   Horizontal agent cards with status filtering
   ============================================================ */

/* --- Page header subtitle --------------------------------- */
.dash-header-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Filter Tabs (pill buttons) --------------------------- */
.agents-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.agents-filter {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 100px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.agents-filter:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

.agents-filter.active {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
  border-color: rgba(0, 212, 170, 0.2);
}

/* --- Agent List (vertical stack of horizontal cards) ------- */
.agents-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Agent Row Card (horizontal layout) ------------------- */
.agent-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-normal), transform var(--transition-normal), box-shadow var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.agent-row:hover {
  border-color: rgba(0, 212, 170, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.agent-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background var(--transition-fast);
}

.agent-row:hover::before {
  background: var(--accent);
}

/* Identity: icon + name */
.agent-row-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 200px;
  flex-shrink: 0;
}

.agent-row-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(0, 212, 170, 0.08);
  border: 1px solid rgba(0, 212, 170, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.agent-row-icon svg {
  width: 20px;
  height: 20px;
}

.agent-row-identity-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-row-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Endpoint URL row */
.agent-row-endpoint {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.agent-row-endpoint-url {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
  max-width: 220px;
}

.agent-row-endpoint-url:hover {
  color: var(--accent);
  opacity: 1;
}

.agent-row-endpoint-copy,
.agent-row-endpoint-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
  padding: 0;
}

.agent-row-endpoint-copy:hover {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
}

.agent-row-endpoint-open:hover {
  color: var(--accent);
  background: rgba(0, 212, 170, 0.08);
  opacity: 1;
}

/* Status badge */
.agent-row-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.agent-row-status .status-dot {
  width: 7px;
  height: 7px;
}

.agent-row-status.status-running {
  background: rgba(0, 212, 170, 0.08);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.15);
}

.agent-row-status.status-sleeping {
  background: rgba(234, 179, 8, 0.08);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.15);
}

.agent-row-status.status-stopped {
  background: rgba(244, 63, 94, 0.08);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.15);
}

.agent-row-status.status-creating,
.agent-row-status.status-waking {
  background: rgba(251, 146, 60, 0.08);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.15);
}

.agent-row-status.status-creating .status-dot,
.agent-row-status.status-waking .status-dot {
  background: #fb923c;
  box-shadow: 0 0 10px rgba(251, 146, 60, 0.6);
  animation: pulse-glow-orange 1.4s ease-in-out infinite;
}

/* Creating/waking row: animated left bar */
.agent-row[data-status="creating"]::before,
.agent-row[data-status="waking"]::before {
  background: #fb923c;
  animation: breathing-bar 1.4s ease-in-out infinite;
}

@keyframes pulse-glow-orange {
  0%, 100% { box-shadow: 0 0 4px rgba(251, 146, 60, 0.3); transform: scale(1); }
  50% { box-shadow: 0 0 20px rgba(251, 146, 60, 1); transform: scale(1.3); }
}

@keyframes breathing-bar {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Plan badge */
.agent-row-plan {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Exchanges */
.agent-row-exchanges {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.agent-row-exchange {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* CPU usage bar (inline) */
.agent-row-cpu {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
  flex-shrink: 0;
}

.agent-row-cpu-label {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 32px;
}

.agent-row-cpu-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
  min-width: 60px;
}

.agent-row-cpu-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}

/* PnL */
.agent-row-pnl {
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
  flex-shrink: 0;
}

.agent-row-pnl.pnl-positive {
  color: var(--accent);
}

.agent-row-pnl.pnl-negative {
  color: #f43f5e;
}

.agent-row-pnl.pnl-zero {
  color: var(--text-muted);
}

/* Region + uptime info */
.agent-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 100px;
  text-align: right;
  flex-shrink: 0;
  margin-left: auto;
}

/* --- Action buttons -------------------------------------- */
.agent-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.agent-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.agent-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--text-muted);
}

.agent-action-btn.agent-action-wake:hover {
  color: var(--accent);
  border-color: rgba(0, 212, 170, 0.3);
  background: rgba(0, 212, 170, 0.08);
}

.agent-action-btn.agent-action-restart:hover {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.08);
}

.agent-action-btn.agent-action-sleep:hover {
  color: #eab308;
  border-color: rgba(234, 179, 8, 0.3);
  background: rgba(234, 179, 8, 0.08);
}

.agent-action-btn.agent-action-delete:hover {
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.3);
  background: rgba(244, 63, 94, 0.08);
}

.agent-row-loading {
  opacity: 0.5;
  pointer-events: none;
}

/* --- Delete confirmation modal --------------------------- */
.delete-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.delete-modal-overlay.visible {
  display: flex;
}

.delete-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  margin: 20px;
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.delete-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f43f5e;
  margin-bottom: 8px;
}

.delete-modal-agent-info {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  word-break: break-all;
}

.delete-modal-warning {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.delete-modal-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.delete-modal-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-body);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.delete-modal-input:focus {
  border-color: #f43f5e;
}

.delete-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.btn-ghost {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #f43f5e;
  border: 1px solid #f43f5e;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Empty state ------------------------------------------ */
.agents-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px;
  border: 2px dashed var(--border-card);
  border-radius: var(--radius-lg);
  background: rgba(26, 26, 46, 0.3);
}

.agents-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: rgba(0, 212, 170, 0.06);
  border: 1px solid rgba(0, 212, 170, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.agents-empty-icon svg {
  width: 36px;
  height: 36px;
  color: var(--accent);
}

.agents-empty h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.agents-empty p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* --- Plan quota footer ------------------------------------ */
.agents-quota {
  margin-top: 32px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.agents-quota:empty {
  display: none;
}

.agents-quota-highlight {
  color: var(--accent);
  font-weight: 700;
}

.agents-quota-bar {
  flex: 1;
  max-width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
}

.agents-quota-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.6s ease;
}

.agents-quota-fill.agents-quota-over {
  background: #f43f5e;
}

.agents-quota-warning {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f43f5e;
  margin-left: auto;
}

/* --- Skeleton loading ------------------------------------- */
.agents-skeleton-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  min-height: 72px;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 1200px) {
  .agent-row-exchanges,
  .agent-row-meta {
    display: none;
  }
}

@media (max-width: 1024px) {
  .agent-row-cpu {
    display: none;
  }
}

@media (max-width: 768px) {
  .agent-row {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
  }

  .agent-row-identity {
    min-width: 0;
    flex: 1;
  }

  .agent-row-pnl {
    min-width: 0;
  }

  .agents-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .agents-filter {
    flex-shrink: 0;
  }
}
