/* ── VG-OS Workers Tab ── */

/* Worker Cards Grid */
.vg-worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.vg-worker-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}

.vg-worker-card:hover {
  border-color: var(--accent);
}

.vg-worker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.vg-worker-icon {
  font-size: 18px;
}

.vg-worker-name {
  font-weight: 600;
  font-size: 15px;
  text-transform: capitalize;
  color: var(--text);
}

/* Status dots */
.worker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.worker-dot.running {
  background: var(--green, #22c55e);
  box-shadow: 0 0 6px var(--green, #22c55e);
}

.worker-dot.stale {
  background: var(--yellow, #eab308);
  box-shadow: 0 0 6px var(--yellow, #eab308);
  animation: pulse-dot 2s infinite;
}

.worker-dot.halted {
  background: var(--red, #ef4444);
  box-shadow: 0 0 6px var(--red, #ef4444);
}

.worker-dot.idle {
  background: var(--text-muted, #64748b);
}

.worker-dot.stopped {
  background: var(--text-muted, #64748b);
  opacity: 0.5;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.vg-worker-details {
  margin-bottom: 12px;
}

.vg-worker-stat {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.vg-worker-errors.has-errors {
  color: var(--red, #ef4444);
  font-weight: 600;
}

.vg-worker-actions {
  display: flex;
  gap: 8px;
}

/* Worker control buttons */
.vg-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.vg-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.vg-btn-halt:hover {
  color: var(--red, #ef4444);
  border-color: var(--red, #ef4444);
}

.vg-btn-resume:hover {
  color: var(--green, #22c55e);
  border-color: var(--green, #22c55e);
}

/* KPI Row */
.vg-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.vg-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.vg-kpi-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.vg-kpi-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.vg-kpi-warn {
  color: var(--red, #ef4444) !important;
}

/* Goals list */
.vg-goal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.06));
  font-size: 13px;
}

.vg-goal-item:last-child {
  border-bottom: none;
}

.goal-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
  min-width: 72px;
  text-align: center;
}

.goal-completed {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green, #22c55e);
}

.goal-failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red, #ef4444);
}

.goal-dispatched {
  background: rgba(59, 130, 246, 0.15);
  color: var(--blue, #3b82f6);
}

.goal-pending {
  background: rgba(234, 179, 8, 0.15);
  color: var(--yellow, #eab308);
}

.vg-goal-title {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vg-goal-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.vg-goal-worker {
  font-size: 11px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 8px;
  color: var(--text-muted);
}

.vg-goal-source {
  font-size: 11px;
  color: var(--text-muted);
}

.vg-goal-time {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 48px;
  text-align: right;
}

.vg-goal-priority {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

/* Events feed */
.vg-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.06));
  font-size: 13px;
}

.vg-event-item:last-child {
  border-bottom: none;
}

.vg-event-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.vg-event-type {
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vg-event-actor {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 80px;
}

.vg-event-time {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 48px;
  text-align: right;
}

/* Global controls */
.vg-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.vg-btn-global {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.vg-btn-global:hover {
  border-color: var(--accent);
}

.vg-btn-halt-all {
  color: var(--red, #ef4444);
  border-color: rgba(239, 68, 68, 0.3);
}

.vg-btn-halt-all:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red, #ef4444);
}

.vg-btn-resume-all {
  color: var(--green, #22c55e);
  border-color: rgba(34, 197, 94, 0.3);
}

.vg-btn-resume-all:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--green, #22c55e);
}

/* Goal submission form */
.vg-goal-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.vg-goal-form .field {
  flex: 1;
  min-width: 140px;
}

.vg-goal-form label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.vg-goal-form input,
.vg-goal-form select {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--input, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.vg-goal-form input:focus,
.vg-goal-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.vg-goal-form button[type="submit"] {
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  align-self: flex-end;
}

.vg-goal-form button[type="submit"]:hover {
  opacity: 0.85;
}

/* Unavailable state */
.vg-unavailable {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-style: italic;
}

/* Toasts */
.vg-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vg-toast {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  animation: toast-in 0.3s ease;
}

.vg-toast-info {
  background: var(--accent, #3b82f6);
}

.vg-toast-error {
  background: var(--red, #ef4444);
}

.vg-toast-fade {
  opacity: 0;
  transition: opacity 0.3s;
}

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Tab badge for workers count */
.vg-badge-warn {
  background: var(--red, #ef4444) !important;
}

/* Section headers inside workers tab */
.vg-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.vg-section-header h2 {
  margin: 0;
}

/* Filter selects in panels */
.vg-filter {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--input, var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

/* Responsive */
@media (max-width: 900px) {
  .vg-worker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .vg-kpi-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .vg-goal-form {
    flex-direction: column;
  }
}

@media (max-width: 500px) {
  .vg-worker-grid {
    grid-template-columns: 1fr;
  }
  .vg-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
