/* ==========================================================================
   Shared card primitives — used by ui/static (Saved Workstreams) and
   console/static (Saved Coordinators).  Single source of truth so the two
   surfaces don't drift on hover affordance, padding, or typography.
   ==========================================================================
   Class names match the original ui/static rules they replaced.  Delete-mode
   selectors live here too so console (Saved Coordinators) and ui/static
   (Saved Workstreams) share one card + delete affordance.
   ========================================================================== */

.dashboard-cards {
  display: grid;
  /* Denser default than the original 200px floor — cards carry a short
     title + one-line meta, so 160-180px fits 4 across at the 1140px
     content cap and keeps the row from looking padded-out. */
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

.dashboard-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    opacity 0.15s;
}
.dashboard-card.is-busy {
  opacity: 0.6;
  cursor: progress;
}
.dashboard-card:hover {
  border-color: var(--accent);
  background: var(--bg-highlight);
}
.dashboard-card:active {
  background: var(--bg-highlight);
  border-color: var(--accent);
}
.dashboard-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-card .card-title {
  font-size: 12px;
  color: var(--fg-bright);
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-card .card-meta {
  font-size: 10px;
  color: var(--fg-dim);
}

/* Subtle ws_id badge on each card — also used inline in card-meta. */
.card-wsid {
  font-size: 9px;
  color: var(--fg-dim);
  opacity: 0.45;
  margin-left: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  vertical-align: middle;
}

@media (max-width: 480px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Delete UX — section-level "Delete" toggle, per-card checkboxes, bottom
   toolbar, and confirmation modal.  Moved out of ui/static/style.css when
   the console grew the same multi-select delete on Saved Coordinators.
   ========================================================================== */

.ws-delete-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-dim);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.ws-delete-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

/* Delete mode */
.dashboard-card.ws-delete-mode {
  cursor: pointer;
}
.dashboard-card.ws-delete-mode:hover {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.04);
}
.dashboard-card.ws-delete-mode.ws-selected {
  cursor: default;
}
.dashboard-card.ws-delete-mode.ws-selected:hover {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.08);
}
[data-theme="light"] .dashboard-card.ws-delete-mode:hover {
  background: rgba(220, 38, 38, 0.04);
}
[data-theme="light"] .dashboard-card.ws-delete-mode.ws-selected:hover {
  background: rgba(220, 38, 38, 0.08);
}
.ws-card-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  cursor: pointer;
  z-index: 1;
  opacity: 0;
  animation: ws-check-fadein 0.2s ease-out forwards;
}
.ws-card-check:focus-visible {
  /* Card click-handler proxies space/enter to the checkbox, so focus
     usually rests on the card; if a screen reader / power user tabs
     directly onto the checkbox the UA outline can be killed by
     adjacent rules — this guarantees a visible affordance. */
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@keyframes ws-check-fadein {
  to {
    opacity: 1;
  }
}
.dashboard-card.ws-selected {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.08);
}
[data-theme="light"] .dashboard-card.ws-selected {
  background: rgba(220, 38, 38, 0.08);
}
.ws-delete-bar {
  display: none;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ws-delete-bar.visible {
  display: flex;
  animation: ws-bar-slide 0.2s ease-out;
}
@keyframes ws-bar-slide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ws-card-check {
    animation: none;
    opacity: 1;
  }
  .ws-delete-bar.visible {
    animation: none;
  }
}
/* Below ~700px the four-pill bar's preferred width (~480-520px) starts
   eating into hit-targets and risking horizontal overflow.  Wrap onto
   two rows: count + Cancel + Select All on the first, the destructive
   Delete Selected on its own full-width row underneath — also a better
   thumb-target separation than the desktop layout. */
@media (max-width: 700px) {
  .ws-delete-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .ws-delete-bar .ws-delete-bar-btn {
    margin-left: 0;
    flex: 1 1 100%;
    order: 99;
  }
}
.ws-delete-bar .ws-delete-count-label {
  font-size: 12px;
  color: var(--fg-dim);
}
.ws-delete-bar .ws-delete-bar-btn {
  margin-left: auto;
  /* Dark-theme --red (#f87171) on #fff is only 3.0:1 — below WCAG AA
     for normal text on a destructive button.  Use the deeper red
     (#dc2626 → 4.85:1) on the filled state so the button label clears
     AA in the default theme. Light theme already uses --red (#b91c1c,
     5.9:1) and stays put — the override below pins it. */
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
[data-theme="light"] .ws-delete-bar .ws-delete-bar-btn {
  background: var(--red);
}
.ws-delete-bar .ws-delete-bar-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}
.ws-delete-bar .ws-delete-bar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ws-delete-bar .ws-delete-cancel-btn {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.ws-delete-bar .ws-delete-cancel-btn:hover {
  color: var(--fg-bright);
  border-color: var(--border-strong);
  background: var(--bg-highlight);
}
.ws-delete-bar .ws-delete-selectall-btn {
  background: transparent;
  color: var(--fg-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.ws-delete-bar .ws-delete-selectall-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-highlight);
}

/* Delete modal — id-scoped so the surface that owns it controls visibility.
   Both ui/static (#ws-delete-overlay) and console/static
   (#coord-delete-overlay) share the same shape via the .ws-delete-modal
   class hooks below. */
.ws-delete-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.ws-delete-modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
}
.ws-delete-modal-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--fg-bright);
}
.ws-delete-modal-list {
  max-height: 200px;
  overflow-y: auto;
  margin: 12px 0;
}
.ws-delete-modal-list .ws-delete-item {
  padding: 6px 0;
  font-size: 13px;
  color: var(--fg-bright);
  border-bottom: 1px solid var(--border);
  /* Long aliases / raw ws_ids in the confirm + results list shouldn't
     punch out of the modal at narrow viewports. */
  word-break: break-word;
}
/* Modal alert region — only painted when the controller writes a
   message.  Both close paths clear it, so :not(:empty) keeps the box
   invisible at rest and avoids an empty-frame artefact. */
.ws-delete-modal-box [role="alert"]:not(:empty) {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}
[data-theme="light"] .ws-delete-modal-box [role="alert"]:not(:empty) {
  background: rgba(220, 38, 38, 0.06);
}
.ws-delete-modal-list .ws-delete-item:last-child {
  border-bottom: none;
}
.ws-delete-modal-list .ws-delete-item.ws-delete-error {
  color: var(--red);
}
.ws-delete-modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.ws-delete-modal-buttons button {
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-bright);
}
.ws-delete-modal-buttons button.ws-delete-confirm {
  /* Mirror .ws-delete-bar-btn's contrast bump — same destructive
     filled-button treatment, same dark-theme AA fix. */
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
[data-theme="light"] .ws-delete-modal-buttons button.ws-delete-confirm {
  background: var(--red);
  border-color: var(--red);
}
/* `.ws-delete-close` is a state-marker, not a colour rule — the
   controller drops `.ws-delete-confirm` when the modal transitions to
   the post-delete "Close" state, and the default
   `.ws-delete-modal-buttons button` rule above already provides the
   transparent / fg-bright / border styling.  The class itself is useful
   for DOM inspection and as a future hook. */
