/* ============================================================
   dialog.css — Universal review-and-commit dialog (Phase 4 §8)
   ============================================================

   The dialog is a positioned <div> overlay (not <dialog>) so we
   get broader browser support + full CSS control. The backdrop
   captures click-outside-to-dismiss; the inner card holds the
   review-and-commit UI (option title, action checkboxes, apply
   button, etc — content lives in templates/_dialog.html).

   Lifecycle:
     HTMX hx-target="#dialog-mount" hx-swap="innerHTML" injects the
     <div class="dialog-backdrop"><div class="dialog">…</div></div>
     subtree into the mount node. dialog.js takes over from there:
     focus trap, ESC, click-outside, focus restore.

   Stacking: dialog uses z-index 9999 to clear the loading overlay
   (which sits at z-index 100 per existing agent.css). */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 14, 8, 0.45); /* ink-800 at ~45% */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
}

.dialog {
  background: #fff;
  border: 1px solid #e8e1cf; /* parch-200 */
  border-radius: 8px;
  box-shadow: 0 24px 48px -16px rgba(17, 14, 8, 0.28);
  width: 100%;
  max-width: 36rem;          /* ~576px — comfortable read width */
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  position: relative;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dialog-title {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.9375rem; /* 15px — the option name is the headline of the dialog */
  font-weight: 600;
  color: #110e08; /* ink-800 */
  letter-spacing: 0.005em;
  line-height: 1.3;
}

.dialog-sub {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  color: #7a7163; /* ink-400 */
  margin-top: 0.125rem;
}

.dialog-close {
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: #7a7163; /* ink-400 */
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  color: #1e1a12;
  background: #f3efe4; /* parch-100 */
  outline: none;
}

.dialog-body {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.875rem;
  color: #342e23; /* ink-600 */
  line-height: 1.55;
  margin: 0 0 1rem;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.action-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid #e8e1cf; /* parch-200 */
  border-radius: 6px;
  background: #faf8f3; /* parch-50 */
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.action-row:hover {
  background: #f3efe4; /* parch-100 */
  border-color: #d4c9b0; /* parch-300 */
}

.action-row input[type="checkbox"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.action-body {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.875rem;
  color: #342e23;
  line-height: 1.5;
}

.action-sub {
  display: block;
  font-size: 0.75rem;
  color: #7a7163;
  margin-top: 0.125rem;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e8e1cf;
}

.dialog-footer-count {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  color: #524b3e; /* ink-500 */
}

/* Confirm-modal nested variant (Phase 4 Task 4.5) — heavier visual weight
   for high-impact apply confirmations. Uses the same .dialog-backdrop but
   reduces padding and shows a tighter Cancel/Confirm pair. */
.dialog.dialog--confirm {
  max-width: 28rem;
  padding: 1.25rem 1.5rem 1.25rem;
}

.dialog--confirm .dialog-body {
  margin-bottom: 1.25rem;
}

/* ── Confirm button loading / disabled state ─────────────────────────────────
   HTMX 2 adds .htmx-request to the element while the apply request is in
   flight (hx-disabled-elt="this" disables it; .htmx-request drives visual
   feedback). A CSS-only spinner replaces the button label, keeping the button
   accessible and the layout stable.

   Palette: currentColor so it works on any .btn-primary background.
   Respects prefers-reduced-motion: no spin animation, just a static dimmed
   disabled appearance. */

.btn-label,
.btn-spinner {
  display: inline-block;
  vertical-align: middle;
}

.btn-spinner {
  display: none;             /* hidden until .htmx-request */
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0.75;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Anchor for the centered spinner overlay; keeps the button at its resting
   width while loading (label stays in flow via visibility:hidden). */
.dialog--confirm .btn-primary { position: relative; }

.btn-primary.htmx-request {
  opacity: 0.65;
  pointer-events: none;
  cursor: default;
}

.btn-primary.htmx-request .btn-label {
  visibility: hidden;       /* reserve the label's width, hide the text */
}

.btn-primary.htmx-request .btn-spinner {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary.htmx-request {
    opacity: 0.65;
    pointer-events: none;
  }
  .btn-spinner {
    animation: none;         /* static border arc – no spin */
  }
  /* Keep label visible so there's still readable text */
  .btn-primary.htmx-request .btn-label {
    visibility: visible;
  }
  .btn-primary.htmx-request .btn-spinner {
    display: none;           /* no spinner under reduced motion */
  }
}

@media (max-width: 480px) {
  .dialog {
    padding: 1.25rem 1rem 1rem;
    max-height: calc(100vh - 1.5rem);
  }
  .dialog-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============================================================
   Review-dialog redesign (2026-06-14)
   Summary lead + confidence pill in the header, a labelled
   Tradeoff section, and actions grouped into collapsible
   Keep / Move / Defer sections (the verb is the group header,
   not repeated per row).
   ============================================================ */

.dialog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.dialog-meta-text {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  color: #7a7163; /* ink-400 */
}

.conf-pill { flex-shrink: 0; }

.conf-pill {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.dialog-meta-count {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  color: #7a7163; /* ink-400 */
}

.dialog-summary {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.9375rem;
  color: #342e23; /* ink-600 */
  line-height: 1.55;
  margin: 0.9rem 0 0;
}

.section-label {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8c8475;
}

.section-label-hint {
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #a59c8a;
}

.dialog-tradeoff {
  margin: 1rem 0 0;
  padding-top: 0.875rem;
  border-top: 1px solid #ece7da; /* parch-150 */
}

.dialog-tradeoff p {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  color: #524b3e; /* ink-500 */
  line-height: 1.5;
  margin: 0.3rem 0 0;
}

.section-label--actions {
  display: block;
  margin: 1.25rem 0 0.625rem;
  padding-top: 0.875rem;
  border-top: 1px solid #ece7da;
}

.action-group {
  margin-bottom: 0.625rem;
}

.action-group-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.125rem 0.45rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.action-group-head::-webkit-details-marker { display: none; }

.action-verb {
  display: inline-block;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
  line-height: 1.5;
}

.action-group-count {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  color: #7a7163;
}

.action-group-chev {
  margin-left: auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid #b0a795;
  border-bottom: 1.5px solid #b0a795;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}
.action-group[open] .action-group-chev {
  transform: rotate(-135deg);
}

.action-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.action-id {
  font-weight: 600;
  color: #1e1a12;
}

.action-target {
  color: #342e23;
}

.action-issue-title {
  font-size: 0.78rem;
  color: #7a7163;
  margin-top: 0.1rem;
  line-height: 1.4;
}

/* ── Locked actions (freshness re-check, 2026-06-15) ─────────────────────────
   Actions that are already applied / already done in Linear / removed from the
   cycle are not appliable: no checkbox, greyed, with a status badge and the live
   current state on hover (the row's title attr). */
.action-row--locked {
  opacity: 0.62;
  cursor: default;
}
.action-lock-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.28rem;
  background: #b0a795;
}
.action-lock-dot--applied { background: #1e5220; }
.action-lock-dot--done    { background: #8c8475; }
.action-lock-dot--gone    { background: #a8472c; }

.action-lock-badge {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  white-space: nowrap;
}
.action-lock-badge--applied { background: #e7f0e8; color: #1e5220; }
.action-lock-badge--done    { background: #ece7da; color: #6a6253; }
.action-lock-badge--gone    { background: #f3e3df; color: #a8472c; }

/* Conflict: the issue changed since the replan ran (state/assignee delta vs the
   plan-time baseline). Amber warning, slightly less dimmed than done/removed so
   it reads as "look at this", and the delta is on the row's hover (title). */
.action-lock-dot--conflict   { background: #c08a1e; }
.action-lock-badge--conflict { background: #fbeccb; color: #8a5a08; }
.action-row--conflict {
  opacity: 0.85;
  background: #fdf6e8;
  border-color: #f0e2c0;
}

/* Locked rows are inert: neutralize the interactive hover the base .action-row
   carries (conflict keeps its own amber resting state). */
.action-row--locked:hover {
  background: #faf8f3;
  border-color: #e8e1cf;
}
.action-row--conflict:hover {
  background: #fdf6e8;
  border-color: #f0e2c0;
}

/* "No longer applicable" section — collects completed / removed / conflicting /
   already-actioned rows out of the verb groups so the verb counts stay honest. */
.action-unavail {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid #ece7da; /* parch-150 */
}
.action-unavail-head {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8c8475;
  margin-bottom: 0.55rem;
}
.action-unavail-count {
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #a59c8a;
}

/* Mini verb tag carried by each unavailable row so you still see what kind of
   action it was after it leaves its verb group. */
.action-verb--mini {
  font-size: 0.5625rem;
  padding: 0.1rem 0.36rem;
  margin-right: 0.15rem;
}
