/* ----- Send tabs: paired options + preview cards -------------------- */

.send-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--t-space-5);
  align-items: start;
}
.send-pair[hidden] { display: none !important; }
@media (min-width: 900px) {
  .send-pair {
    /* Spec ratio: preview column slightly wider than options so the
       portrait panel ratio doesn't get cramped. Both columns can
       shrink to zero for very narrow viewports. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  }
}
.send-pair-options { min-width: 0; }
.send-pair-preview {
  min-width: 0;
}
/* Cancel the global ``.dx-section-card + .dx-section-card``
   16px top margin inside this grid — the rule is meant for
   vertically stacked siblings on admin pages, but here the
   options + preview cards are side-by-side in a 2-col grid and
   the sibling selector still fires, pushing the preview down
   ~16px relative to the options card. Both card tops align
   again with this reset. */
.send-pair > .dx-section-card + .dx-section-card { margin-top: 0; }
.send-pair-preview .card-head { width: 100%; }
.send-pair-preview .preview-frame {
  /* Let the preview use the column's full width. The base
     ``.preview-frame`` caps at 720px (editor context); on the
     page-wide Send layout the column is comfortably wider than
     that, so we lift the cap to keep the preview from looking
     pinned in a much larger card. Aspect-ratio still locks the
     proportion. */
  margin: 0 auto;
  max-width: none;
}
.send-pair-preview .preview-dims {
  margin: 0;
  font-size: 12px;
  align-self: end;
}
.send-pair-preview .preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
}
/* Blurred backdrop for the "Center + blurred background" fit mode: a
   cover-cropped copy of the source sitting behind the contained image, so
   the live preview matches what the renderer pushes. Toggled by
   attachSendFitPreview; hidden for every other mode. */
.preview-frame > img.preview-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Overscale so the blur's soft edge doesn't reveal the frame border. */
  transform: scale(1.08);
  filter: blur(18px) saturate(1.15);
  z-index: 0;
}
.preview-frame > img.preview-bg[hidden] { display: none !important; }
.preview-frame > img.preview-image { z-index: 1; }
.preview-placeholder {
  display: grid;
  place-items: center;
  text-align: center;
  width: 100%;
  height: 100%;
  padding: var(--t-space-5);
  color: var(--t-muted);
  /* Subtle checkerboard so the preview canvas reads as a designer's
     transparent surface rather than a flat fill. The squares are
     tinted with the soft surface tokens so they barely register -
     they're texture, not pattern. */
  background:
    conic-gradient(from 90deg at 1px 1px,
      transparent 0 25%, color-mix(in oklab, var(--t-fg) 3%, transparent) 0 50%,
      transparent 0 75%, color-mix(in oklab, var(--t-fg) 3%, transparent) 0 100%);
  background-size: 16px 16px;
}
.preview-placeholder [class^="ph-duotone"] {
  font-size: 64px;
  color: var(--t-fg-soft);
  margin-bottom: var(--t-space-2);
  opacity: 0.55;
  animation: preview-breathe 4.5s var(--t-ease-snappy) infinite;
}
@keyframes preview-breathe {
  0%, 100% { transform: scale(1);    opacity: 0.5; }
  50%      { transform: scale(1.04); opacity: 0.7; }
}
@media (prefers-reduced-motion: reduce) {
  .preview-placeholder [class^="ph-duotone"] { animation: none; }
}
.preview-placeholder p {
  margin: 0;
  font-size: var(--t-size-sm);
  color: var(--t-fg-soft);
  letter-spacing: -0.005em;
}

/* ----- History ------------------------------------------------------ */

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--t-space-3);
}

.history-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: var(--t-space-4);
  align-items: center;
  padding: var(--t-space-3);
  border: 1px solid var(--t-border);
  border-radius: var(--t-radius-md);
  background: var(--t-surface);
  box-shadow: var(--t-shadow-xs);
  transition:
    border-color var(--t-trans),
    box-shadow var(--t-trans),
    transform var(--t-trans);
}
.history-row:hover {
  border-color: var(--t-border-strong);
  box-shadow: var(--t-shadow-sm);
  transform: translateY(-1px);
}

.history-thumb {
  display: grid;
  place-items: center;
  width: 96px;
  height: 72px;
  background: var(--t-surface-sunk);
  border-radius: var(--t-radius-sm);
  border: 1px solid var(--t-border);
  overflow: hidden;
  text-decoration: none;
  transition: transform var(--t-trans), box-shadow var(--t-trans-fast);
}
.history-row:hover .history-thumb {
  transform: scale(1.02);
  box-shadow: var(--t-shadow-sm);
}
.history-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 280ms var(--t-ease-spring);
}
.history-thumb:hover img { transform: scale(1.04); }
.history-thumb-empty {
  font-size: 11px;
  color: var(--t-muted);
}

.history-meta {
  display: grid;
  gap: var(--t-space-1);
  min-width: 0;
  overflow: hidden;
}

.history-top {
  display: flex;
  align-items: center;
  gap: var(--t-space-2);
  flex-wrap: wrap;
}

.history-source {
  font-size: var(--t-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t-muted);
  font-weight: 700;
}

/* Source/trigger chip on history rows, at-a-glance "what triggered
   this push": Send page, scheduler, webhook, Home Assistant. The
   colour is a faint tint of the accent so the eye can group like-
   triggered rows on a busy History without the page becoming a
   parrot. Tone classes live alongside the base so adding a new
   trigger only needs a new ``--src-chip--<tone>`` block. */
.src-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: color-mix(in oklab, var(--t-fg) 6%, transparent);
  color: var(--t-fg);
  border: 1px solid color-mix(in oklab, var(--t-fg) 10%, transparent);
  white-space: nowrap;
  line-height: 1.3;
}
.src-chip .ph,
.src-chip .ph-fill {
  font-size: 13px;
  line-height: 1;
}
.src-chip--accent-teal {
  background: color-mix(in oklab, #178a7a 14%, var(--t-surface));
  color: color-mix(in oklab, #178a7a 75%, var(--t-fg));
  border-color: color-mix(in oklab, #178a7a 25%, transparent);
}
.src-chip--accent-ochre {
  background: color-mix(in oklab, #c08a18 14%, var(--t-surface));
  color: color-mix(in oklab, #c08a18 75%, var(--t-fg));
  border-color: color-mix(in oklab, #c08a18 25%, transparent);
}
.src-chip--accent-terracotta {
  background: color-mix(in oklab, #c95d2e 14%, var(--t-surface));
  color: color-mix(in oklab, #c95d2e 78%, var(--t-fg));
  border-color: color-mix(in oklab, #c95d2e 25%, transparent);
}
.src-chip--accent-slate {
  background: color-mix(in oklab, #5e7186 14%, var(--t-surface));
  color: color-mix(in oklab, #5e7186 80%, var(--t-fg));
  border-color: color-mix(in oklab, #5e7186 25%, transparent);
}
:root[data-theme="dark"] .src-chip--accent-teal { color: #6ed4be; border-color: color-mix(in oklab, #6ed4be 35%, transparent); }
:root[data-theme="dark"] .src-chip--accent-ochre { color: #e5b94d; border-color: color-mix(in oklab, #e5b94d 35%, transparent); }
:root[data-theme="dark"] .src-chip--accent-terracotta { color: #f29170; border-color: color-mix(in oklab, #f29170 35%, transparent); }
:root[data-theme="dark"] .src-chip--accent-slate { color: #a4b4c4; border-color: color-mix(in oklab, #a4b4c4 35%, transparent); }


.history-target {
  /* The dashboard / target name is the row's headline now (was a
     monospace slug chip), give it weight over the source tag. */
  font-size: var(--t-size-base);
  color: var(--t-fg);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.history-sub {
  font-size: var(--t-size-sm);
  color: var(--t-fg-soft);
  display: flex;
  gap: var(--t-space-2);
  align-items: center;
  flex-wrap: wrap;
}

.history-err {
  color: var(--t-danger);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--t-size-xs);
}

.history-renderers {
  display: flex;
  gap: var(--t-space-1);
  flex-wrap: wrap;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: var(--t-space-1);
}

button:disabled,
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

