/* ============================================================================
   Tasks — a two-pane "scheduling console".
   ----------------------------------------------------------------------------
   Compose (left) flows into a live Queue (right): ONE surface, one border, an
   internal divider — so the action of scheduling and its result read as a
   single connected tool instead of two stacked cards. On brand: cv- tokens,
   near-square geometry, tabular mono times, one accent.

   The Quick Schedule form is rendered by agent.js into the compose pane and is
   shared with the Hybrid-AI modal — its markup is NOT touched; the legacy
   .form-* fields are only restyled here, scoped to .cvt-form.
   ============================================================================ */

.cvt-console {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  border: 1px solid var(--cv-border);
  border-radius: var(--cv-radius-lg);
  background: var(--cv-bg-surface);
  overflow: hidden;
  height: calc(100vh - 132px);
  min-height: 520px;
}
.cvt-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* Compose sits a step up (raised) from the queue surface, so the eye reads the
   left as "input" and the right as "output" without a heavy divider. */
.cvt-compose { background: var(--cv-bg-raised); border-right: 1px solid var(--cv-border); }

.cvt-pane-head {
  display: flex; align-items: center; gap: var(--cv-space-2); flex: none;
  min-height: var(--cv-row-comfy);
  padding: var(--cv-space-2) var(--cv-space-3);
  border-bottom: 1px solid var(--cv-border-subtle);
}
.cvt-pane-title {
  display: flex; align-items: center; gap: var(--cv-space-2);
  font-size: var(--cv-text-sm); font-weight: var(--cv-weight-semibold);
}
.cvt-pane-title .cv-i { width: 15px; height: 15px; color: var(--cv-accent); }

.cvt-compose-body, .cvt-queue-body { flex: 1; overflow-y: auto; min-height: 0; }
.cvt-compose-body { padding: var(--cv-space-3); }
.cvt-queue-body { padding: var(--cv-space-2) var(--cv-space-3) var(--cv-space-3); }

/* Live server clock in the queue header — seconds + milliseconds, in the
   server's timezone. The pulsing dot signals the queue is live (self-refreshes
   every 10s); the mono/tabular time + fixed min-width keeps it from jittering. */
.cvt-clock { display: inline-flex; align-items: baseline; gap: 5px; }
.cvt-dot-live {
  align-self: center; width: 6px; height: 6px; flex: none;
  border-radius: var(--cv-radius-full); background: var(--cv-success);
  animation: cv-pulse 1.6s var(--cv-ease) infinite;
}
.cvt-clock-lbl {
  font-size: 9px; text-transform: uppercase; letter-spacing: var(--cv-tracking-caps);
  color: var(--cv-text-disabled);
}
.cvt-clock-time {
  font-family: var(--cv-font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--cv-text-xs); color: var(--cv-text-secondary);
  min-width: 15ch; text-align: right;
}
@media (prefers-reduced-motion: reduce) { .cvt-dot-live { animation: none; } }

/* Stack on narrow viewports. */
@media (max-width: 900px) {
  .cvt-console { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .cvt-compose { border-right: none; border-bottom: 1px solid var(--cv-border); }
  .cvt-compose-body { max-height: 58vh; }
  .cvt-queue-body { max-height: 60vh; }
}

/* =============================================== Quick Schedule form (scoped) */
.cvt-form .form-label {
  display: block; margin-bottom: var(--cv-space-1);
  font-size: var(--cv-text-xs); font-weight: var(--cv-weight-medium); color: var(--cv-text-secondary);
}
.cvt-form .form-input,
.cvt-form .form-textarea,
.cvt-form .form-select,
.cvt-form textarea {
  width: 100%; padding: 6px var(--cv-space-2);
  background: var(--cv-bg-inset); color: var(--cv-text);
  border: 1px solid var(--cv-border); border-radius: var(--cv-radius-sm);
  font: inherit; font-size: var(--cv-text-sm);
}
.cvt-form .form-input:focus,
.cvt-form .form-textarea:focus,
.cvt-form .form-select:focus,
.cvt-form textarea:focus {
  outline: none; border-color: var(--cv-accent); box-shadow: 0 0 0 3px var(--cv-accent-wash);
}
/* Compose tabs (agent.js .qs-tabs/.media-tab) — tighten padding so all four
   ("WhatsApp / OBS Action / Profile Switch / Transfer") sit on one line in the
   400px pane instead of wrapping. */
.cvt-form .qs-tabs { flex-wrap: nowrap; overflow-x: auto; }
.cvt-form .qs-tabs .media-tab { padding-left: 8px; padding-right: 8px; font-size: var(--cv-text-xs); white-space: nowrap; }

/* ================================================================ queue rows */
.cvt-sec {
  display: flex; align-items: center; gap: var(--cv-space-2);
  margin: var(--cv-space-3) 0 var(--cv-space-1);
}
.cvt-sec:first-child { margin-top: 0; }
.cvt-sec-title {
  font-size: var(--cv-text-2xs); font-weight: var(--cv-weight-semibold);
  letter-spacing: var(--cv-tracking-caps); text-transform: uppercase; color: var(--cv-text-muted);
}
.cvt-tasks { display: grid; gap: var(--cv-space-1); }
/* The soonest pending task gets an accent rail — "next up" reads at a glance. */
.cvt-tasks[data-group="pending"] .cvt-task:first-child { box-shadow: inset 3px 0 0 var(--cv-accent); }

.cvt-task {
  display: flex; align-items: center; gap: var(--cv-space-2);
  padding: var(--cv-space-2);
  border: 1px solid var(--cv-border); border-radius: var(--cv-radius);
  background: var(--cv-bg-surface);
  transition: border-color var(--cv-dur-fast) var(--cv-ease);
}
.cvt-task:hover { border-color: var(--cv-border-strong); }
.cvt-task[data-status="cancelled"] { opacity: 0.55; }

.cvt-task-icon {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--cv-radius-sm);
  background: var(--cv-bg-inset); color: var(--cv-text-muted);
}
.cvt-task-icon .cv-i { width: 16px; height: 16px; }
.cvt-task[data-status="pending"] .cvt-task-icon { color: var(--cv-warning); background: var(--cv-warning-wash); }
.cvt-task[data-status="completed"] .cvt-task-icon { color: var(--cv-success); background: var(--cv-success-wash); }

.cvt-task-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.cvt-task-head { display: flex; align-items: baseline; gap: var(--cv-space-2); min-width: 0; }
.cvt-task-type { font-size: var(--cv-text-xs); font-weight: var(--cv-weight-semibold); color: var(--cv-text); flex: none; }
.cvt-task-target { font-size: var(--cv-text-xs); color: var(--cv-text-secondary); }
.cvt-task-detail { font-size: var(--cv-text-2xs); color: var(--cv-text-muted); }

/* When: relative time (prominent, accent for upcoming) over the absolute time. */
.cvt-task-when { flex: none; display: grid; justify-items: end; gap: 0; text-align: right; }
.cvt-task-rel {
  font-size: var(--cv-text-xs); font-weight: var(--cv-weight-semibold);
  font-family: var(--cv-font-mono); color: var(--cv-text-secondary);
}
.cvt-task[data-status="pending"] .cvt-task-rel { color: var(--cv-accent); }
.cvt-task-abs {
  font-size: 9px; color: var(--cv-text-disabled);
  font-family: var(--cv-font-mono); font-variant-numeric: tabular-nums;
}
.cvt-task-badge { flex: none; }
