/* Task queue panel — extends fleet panel patterns */

.tasks-panel {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tasks-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.tasks-body > .fleet-stats {
  margin-bottom: 16px;
}

.tasks-body > .fleet-hint {
  margin-bottom: 16px;
}

.fleet-stat-card--muted {
  opacity: 0.85;
}

.tasks-create-card {
  cursor: default;
  margin-bottom: 16px;
  gap: 14px;
  flex-shrink: 0;
}

.tasks-create-card:hover {
  border-color: var(--border);
}

.tasks-create-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.ops-maintenance-card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.ops-maintenance-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.ops-maintenance-card #ops-maintenance-meta {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
}

.tasks-create-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.tasks-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1 1 180px;
  max-width: 280px;
}

.tasks-field-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Account count needs far less room than the selects next to it. */
.tasks-field--narrow {
  min-width: 110px;
  flex: 0 0 120px;
  max-width: 120px;
}

.tasks-select {
  padding: 8px 36px 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
}

.tasks-input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
}

.tasks-select:focus,
.tasks-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--info) 50%, var(--border-strong));
}

.tasks-create-preview {
  flex-basis: 100%;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 1.2em;
}

.tasks-create-preview[data-tone="warn"] {
  color: var(--status-warn-fg, #fbbf24);
}

.tasks-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tasks-section-title {
  margin: 0;
  padding: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.tasks-filter-tabs {
  padding: 0;
  border-bottom: none;
  margin-left: auto;
  margin-bottom: -1px;
}

.tasks-filter-tabs .worker-tab {
  padding: 8px 12px;
  font-size: 11px;
}

/*
 * Antrian / Orphan heights are user-resizable (ns-resize handle below each
 * wrap), same UX as emulator Log operasi. Defaults match prior caps.
 */
.tasks-batch-wrap {
  flex: 0 0 auto;
  height: var(--tasks-batch-h, 280px);
  min-height: 120px;
  max-height: none;
  margin-bottom: 0;
  box-sizing: border-box;
}

.tasks-batch-wrap.is-resizing,
.tasks-orphan-wrap.is-resizing {
  overflow: hidden;
  user-select: none;
}

.tasks-panel-resize {
  flex-shrink: 0;
  height: 10px;
  margin: 2px 0 0;
  border-radius: 999px;
  cursor: ns-resize;
  touch-action: none;
  position: relative;
  background: transparent;
}

.tasks-panel-resize::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 3px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--border-strong, rgba(255, 255, 255, 0.18)) 85%, transparent);
}

.tasks-panel-resize:hover::after,
.tasks-panel-resize:focus-visible::after,
.tasks-panel-resize.is-resizing::after {
  background: color-mix(in srgb, var(--text-muted) 70%, transparent);
}

.tasks-body > .fleet-stats,
.tasks-body > .fleet-hint {
  flex-shrink: 0;
}

/*
 * The batch table deliberately adds nothing to `.tasks-table` beyond column widths.
 *
 * It used to bring a `min-width` that forced sideways scroll, and `vertical-align: middle` against
 * the base table's `top` — both left over from when batch rows were two lines tall. Rows are single
 * line now, so the individual command table below and this one render identically.
 */

.tasks-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* `.tasks-table th` is the more specific selector, so numeric headers stayed left-aligned while
   their values were right-aligned — every count appeared to hang under the next column over. */
.tasks-table th.tasks-num {
  text-align: right;
}

/*
 * A count of zero is context, not news. Keep it legible but let non-zero values carry the row.
 *
 * Dimming via `opacity` would fade the whole cell, background included, so a hovered row showed a
 * darker patch where this cell sat — only the text colour gives way. Both rules are scoped through
 * the table so they outrank `tbody tr:hover td`, which sets `color` and would otherwise wash a
 * failure count to plain white exactly when the operator is pointing at it.
 */
.tasks-batch-table td.tasks-count--zero {
  color: color-mix(in srgb, var(--text-muted) 70%, transparent);
}

.tasks-batch-table td.tasks-count--bad {
  color: var(--status-danger-fg, #f87171);
  font-weight: 600;
}

.tasks-batch-col-chevron {
  width: 28px;
  padding-right: 0 !important;
}

.tasks-batch-col-progress {
  width: 190px;
}

.tasks-batch-col-failed {
  width: 64px;
}

.tasks-batch-col-time {
  width: 92px;
  white-space: nowrap;
}

/* Pin the action column to its buttons. Left to share the table's slack, it grew a wide empty
   gap and stranded `Hapus` far from the row it belongs to. */
.tasks-batch-col-actions {
  width: 1%;
  white-space: nowrap;
}

.tasks-batch-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
}

.tasks-batch-chevron:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.tasks-batch-row.is-expanded .tasks-batch-chevron {
  transform: rotate(90deg);
  color: var(--text-primary);
}

.tasks-batch-row.is-expanded > td {
  border-bottom-color: transparent;
}

/* Plain cell, same weight as the kind column in the individual table. The bold label and the muted
   sub-line under it were the loudest part of the old batch row. */
.tasks-batch-kind {
  white-space: nowrap;
}

/* Clamp only. Colour and size come from the base cell, so this matches `<td class="mono">` in the
   individual table instead of being a size and shade of its own. */
.tasks-batch-worker {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tasks-batch-detail > td {
  padding: 0 12px 12px 40px !important;
  background: var(--bg-surface);
}

.tasks-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tasks-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--progress-track);
  overflow: hidden;
}

.tasks-progress-fill {
  display: block;
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  background: linear-gradient(90deg, var(--progress-fill) 0%, var(--progress-fill-end) 100%);
  box-shadow: 0 0 6px var(--progress-glow);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.tasks-progress-count {
  font-size: 11px;
  color: var(--text-secondary, var(--text-muted));
  min-width: 52px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tasks-batch-action {
  font-size: 11px;
  padding: 2px 8px;
}

/*
 * The detail reads as a continuation of the batch row, not a table parked inside one.
 *
 * It used to be a bordered, elevated box holding a full second table — complete with its own
 * uppercase sticky header whose columns lined up with nothing above them. A single rule down the
 * left says "this belongs to the row above" without competing with the outer table's chrome.
 */
.tasks-batch-body {
  overflow: auto;
  max-height: min(420px, 45vh);
  border: none;
  border-left: 2px solid var(--border-strong);
  border-radius: 0;
  background: transparent;
  padding-left: 10px;
}

.tasks-table-wrap {
  overflow: auto;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

/* Batch queue overrides the shared 280px cap — see `.tasks-batch-wrap` above. */
.tasks-table-wrap.tasks-batch-wrap {
  max-height: none;
}

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tasks-table th {
  position: sticky;
  top: 0;
  /* Above the nested detail header, which sticks inside its own scroll box. */
  z-index: 2;
  background: var(--bg-elevated);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.tasks-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tasks-table tr:last-child td {
  border-bottom: none;
}

.tasks-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px !important;
}

.tasks-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.tasks-status--pending {
  background: color-mix(in srgb, #fbbf24 18%, transparent);
  color: #fbbf24;
}

.tasks-status--running {
  background: color-mix(in srgb, #3b82f6 18%, transparent);
  color: #60a5fa;
}

/* Farming is a good outcome, so it wears the success colour rather than running's blue. It was
   listed under both rules, and only won green by virtue of coming second. */
.tasks-status--farming {
  background: color-mix(in srgb, var(--status-success-fg) 18%, transparent);
  color: var(--status-success-fg);
}

.tasks-status--done {
  background: color-mix(in srgb, var(--status-success-fg) 18%, transparent);
  color: var(--status-success-fg);
}

.tasks-status--failed {
  background: color-mix(in srgb, #ef4444 18%, transparent);
  color: #f87171;
}

.tasks-status--cancelled {
  background: color-mix(in srgb, var(--text-muted) 18%, transparent);
  color: var(--text-muted);
}

.tasks-result {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 11px;
}

.tasks-table--nested {
  font-size: 11px;
  border: none;
}

.tasks-table--nested th,
.tasks-table--nested td {
  padding: 5px 10px;
}

/* Plain labels instead of a second block of uppercase table chrome. Background stays opaque
   because this header sticks while the detail scrolls. */
.tasks-table--nested th {
  background: var(--bg-surface);
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
  font-weight: 500;
  z-index: 1;
}

.tasks-table--nested td {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.tasks-empty-inline {
  margin: 0;
  padding: 8px 0;
  text-align: left;
  color: var(--text-muted);
  font-size: 12px;
}

.tasks-incomplete-hint {
  margin: 0 0 8px;
  padding: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.tasks-orphan-more {
  text-align: center;
  padding: 10px 8px !important;
}

.tasks-orphan-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tasks-orphan-heading {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.tasks-orphan-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.tasks-orphan-wrap {
  flex: 0 0 auto;
  height: var(--tasks-orphan-h, 180px);
  min-height: 120px;
  max-height: none;
  box-sizing: border-box;
}

.tasks-cmd-actions {
  text-align: right;
  white-space: nowrap;
}

.tasks-cmd-cancel {
  font-size: 11px;
  padding: 2px 8px;
}

.tasks-worker-queue {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tasks-worker-queue li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.tasks-worker-queue li:last-child {
  border-bottom: none;
}

.worker-queue-heading {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.worker-queue-heading:first-child {
  margin-top: 0;
}

@media (max-width: 900px) {
  .tasks-section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .tasks-filter-tabs {
    margin-left: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tasks-field {
    max-width: none;
  }

  .tasks-field--narrow {
    flex: 1 1 auto;
    max-width: none;
  }
}
