/* Panel Kerja: sheet dari bawah berisi pekerjaan yang dijalankan backend app (ctx.tasks), plus lencana di
   tombol melayang. Logika ada di js/shell/work.js.
   Lapisan: di atas app overlay (960), di bawah dialog dan sheet (2000) supaya konfirmasi Batalkan tampil di atasnya. */

#work {
  --glass-blur: 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: transparent;
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  animation: glass-in 0.2s ease-out;
}

.work-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  min-height: 160px;
  max-height: 78%;
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: cos-rise 0.18s ease-out;
}

.work-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.work-heading {
  flex: 1;
  min-width: 0;
}

.work-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.work-summary {
  min-height: 1.3em;
  margin: 2px 0 0;
  font-size: var(--fs-sm);
}

.work-clear {
  flex: none;
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--fs-sm);
}

.work-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.work-empty {
  margin: var(--space-5) 0;
  line-height: 1.5;
  text-align: center;
}

.work-item {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.work-open {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.work-icon {
  display: block;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.work-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.work-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-sub {
  overflow: hidden;
  font-size: var(--fs-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-status {
  flex: none;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.work-item.is-done .work-status {
  color: var(--success);
}

.work-item.is-failed .work-status {
  color: var(--danger);
}

.work-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--border);
}

.work-item.is-failed .work-bar,
.work-item.is-cancelled .work-bar {
  display: none;
}

.work-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.4s ease;
}

.work-item.is-done .work-fill {
  background: var(--success);
}

.work-bar.is-indeterminate .work-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 40% !important;
  transition: none;
  animation: work-slide 1.3s ease-in-out infinite;
}

@keyframes work-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

.work-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
}

.work-actions:empty {
  display: none;
}

.work-act {
  min-height: 40px;
  padding: 0 var(--space-3);
}

.work-cancel {
  color: var(--danger);
}

/* Gambar, teks beberapa baris, dan warna penekanan dari backend (image, body, tone). */
.work-image {
  display: block;
  width: 100%;
  max-height: 160px;
  border-radius: var(--radius-sm);
  background: var(--border);
  object-fit: cover;
}

.work-image[hidden],
.work-body[hidden],
.work-status[hidden] {
  display: none;
}

.work-body {
  font-size: var(--fs-sm);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.work-item.tone-accent {
  border-left: 3px solid var(--accent);
}

.work-item.tone-success {
  border-left: 3px solid var(--success);
}

.work-item.tone-danger {
  border-left: 3px solid var(--danger);
}

/* Notifikasi (ctx.tasks.notify): tanpa bilah progres dan tanpa lencana status. */
.work-item.is-notice .work-bar {
  display: none;
}

/* Gaya tombol dari app: style 'primary' dan 'danger'. */
.work-act.is-primary {
  color: var(--accent);
  font-weight: 600;
}

.work-act.is-danger {
  color: var(--danger);
}

a.work-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

a.work-act[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

/* Lencana jumlah pekerjaan aktif: di tombol melayang dan di tombol Panel Kerja pada menunya. */
#work-btn {
  position: relative;
}

.fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
  color: var(--accent-contrast);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

#fab-main .fab-badge {
  top: -4px;
  right: -4px;
}

@media (hover: hover) {
  .work-open:hover .work-name {
    text-decoration: underline;
  }
}

@media (prefers-reduced-motion: reduce) {
  #work,
  .work-sheet {
    animation: none;
  }

  .work-fill {
    transition: none;
  }

  .work-bar.is-indeterminate .work-fill {
    left: 30%;
    animation: none;
  }
}
