/* Workflows ------------------------------------------------------- */

.wf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}
.wf-empty {
  padding: 48px;
  text-align: center;
  color: var(--ink-4);
  background: var(--bg-elev);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
}

.wf-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  box-shadow: var(--sh-1);
  position: relative;
  min-height: 200px;
}
.wf-card:hover { border-color: var(--line-3); box-shadow: var(--sh-2); }
.wf-card[data-on="false"] { background: var(--bg); opacity: .82; }
.wf-card[data-on="false"] .wf-icon {
  background: var(--bg-sunk);
  border-color: var(--line-2);
  color: var(--ink-4);
}

.wf-card-h { display: flex; align-items: flex-start; gap: 12px; }
.wf-card-meta { flex: 1; min-width: 0; }
.wf-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--ink);
  border: 1px solid var(--accent-soft);
  display: grid; place-items: center;
  flex: none;
}
.wf-icon-sm { width: 32px; height: 32px; }
.wf-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 600; color: var(--ink);
  letter-spacing: -.005em; line-height: 1.25;
}
.wf-badge {
  font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--ink);
}
.wf-meta { font-size: 11.5px; color: var(--ink-4); margin-top: 3px; }
.wf-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.wf-short {
  font-size: 13px; color: var(--ink-3);
  letter-spacing: -.005em; line-height: 1.5;
  margin: 0;
}
.wf-card-foot {
  display: flex; align-items: center; gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  margin-top: auto;
}
.wf-services { display: flex; gap: 4px; }
.wf-runs {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}

/* Switch toggle ---------------------------------------------------- */
.switch {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 0; padding: 0;
  cursor: pointer;
}
.switch-track {
  width: 34px; height: 20px;
  background: var(--line-2);
  border-radius: 999px;
  position: relative;
  transition: background .15s;
  display: inline-block;
  flex: none;
}
.switch-knob {
  position: absolute;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.switch[data-on="true"] .switch-track { background: var(--good); }
.switch[data-on="true"] .switch-knob  { left: 16px; }
.switch-label { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.switch[data-on="true"] .switch-label { color: var(--good); }

/* Brand mark ------------------------------------------------------- */
.brand-mark {
  border-radius: 12px;
  display: grid; place-items: center;
  flex: none;
  border: 1px solid rgba(0,0,0,.04);
}

/* Scrim + modal ---------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(20,19,15,.4);
  z-index: 80;
  animation: fadein .15s ease-out;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: var(--sh-3);
  z-index: 90;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  animation: modal-in .18s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}
.modal-h {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
/* Push the trailing close icon to the right edge of the header,
   regardless of how many text blocks sit before it. Without this the
   X clung to the title because the row had no flex grow gap. */
.modal-h > .iconbtn:last-child { margin-left: auto; }
.modal-title {
  font-size: 16px; font-weight: 600; color: var(--ink);
  letter-spacing: -.01em;
}
.modal-sub {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--ink-4);
  margin-top: 2px;
}
.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1; min-height: 0;
}
.modal-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.wf-section { margin-bottom: 22px; }
.wf-section:last-child { margin-bottom: 0; }

/* Accordion sections in the workflow drawer. The chevron rotates 90° when
   open; the body unfolds via x-show. No animated height — kept simple so
   the cancel/save inline edit form doesn't have to fight a CSS transition. */
.wf-acc {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  margin-bottom: 12px;
}
.wf-acc-head {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.wf-acc-title {
  flex: 1;
  font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
}
.wf-acc-chev { transition: transform .15s ease; color: var(--ink-3); display: inline-flex; }
.wf-acc-chev.is-open { transform: rotate(90deg); }
.wf-acc-body { padding: 0 14px 14px; }
.wf-acc-sub-h {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4);
  margin: 12px 0 8px;
}
.wf-acc-sub-h:first-child { margin-top: 0; }
.wf-section-h {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-4);
  margin-bottom: 10px;
}
.wf-long {
  font-size: 14px; line-height: 1.6;
  color: var(--ink-2); margin: 0;
  letter-spacing: -.003em;
}
/* Inline section empty-state — distinct from the full-page .wf-empty above
   which has dashed border + 48px padding. Inline reads as a quiet hint. */
.wf-section .wf-empty {
  padding: 14px 16px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  font-size: 13px;
  color: var(--ink-3);
}
.wf-params {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.wf-param {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.wf-param:last-child { border-bottom: 0; }
.wf-param:hover { background: var(--bg-sunk); }
.wf-param-k { flex: 1; color: var(--ink-3); letter-spacing: -.003em; }
.wf-param-v {
  color: var(--ink); font-weight: 500;
  font-family: var(--font-mono); font-size: 12.5px;
}
.wf-param-edit { height: 26px; padding: 0 8px; }
.wf-param-edit-row { background: var(--bg-sunk); }
.wf-param-input {
  flex: 1;
  height: 28px; padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--font-mono); font-size: 12.5px;
  outline: none;
  min-width: 0;
}
.wf-param-input:focus { border-color: var(--ink-3); }

/* Friendly-named global row: title + raw key + help stack on the left,
   value + edit action stay on the right. Edit form uses the same meta
   block but the input area below spans the full row. */
.wf-param.wf-global { display: grid; grid-template-columns: 1fr auto auto; gap: 10px 12px; align-items: start; }
.wf-global-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wf-global-label { font-weight: 600; color: var(--ink); font-size: 13px; }
.wf-global-key { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); }
.wf-global-help { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; }
.wf-global-value {
  align-self: center;
  max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf-param.wf-global.wf-param-edit-row {
  grid-template-columns: 1fr;
  gap: 8px;
}
.wf-global-input { display: flex; flex-direction: column; gap: 6px; }
.wf-global-actions { display: flex; gap: 6px; justify-content: flex-end; }
.wf-param-select { font-family: inherit; font-size: 13px; }
.wf-checks { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.wf-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--ink-2);
  cursor: pointer;
}
.wf-check input[type="checkbox"] { width: 14px; height: 14px; }

.wf-services-row { display: flex; flex-direction: column; gap: 6px; }
.wf-svc-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px; color: var(--ink-2);
}
.wf-svc-status { margin-left: auto; }
.wf-svc-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

.wf-recent {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.wf-recent-row {
  display: flex; gap: 12px;
  padding: 10px 14px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
}
.wf-recent-row:last-child { border-bottom: 0; }
.wf-recent-date {
  font-family: var(--font-mono);
  color: var(--ink-4);
  white-space: nowrap;
  font-size: 11.5px;
}
.wf-recent-what { color: var(--ink-2); letter-spacing: -.003em; }

/* Workflow templates modal --------------------------------------- */
.wf-tmpl-overlay {
  position: fixed; inset: 0;
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.wf-tmpl-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(2px);
}
.wf-tmpl-modal {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 64px);
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.wf-tmpl-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.wf-tmpl-title-wrap { flex: 1; }
.wf-tmpl-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.wf-tmpl-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-4); }
.wf-tmpl-close {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  background: transparent; border: 0;
  border-radius: 8px; cursor: pointer; color: var(--ink-3);
}
.wf-tmpl-close:hover { background: var(--bg-sunk); color: var(--ink); }

.wf-tmpl-filters {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.wf-tmpl-search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  height: 34px;
  width: 280px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
}
.wf-tmpl-search > svg { color: var(--ink-4); }
.wf-tmpl-search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 13px; color: var(--ink); }
.wf-tmpl-cats { display: flex; gap: 6px; flex-wrap: wrap; }
.wf-tmpl-cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px; color: var(--ink-3);
  cursor: pointer;
}
.wf-tmpl-cat:hover { background: var(--bg-sunk); color: var(--ink); }
.wf-tmpl-cat.is-active {
  background: var(--accent-wash); color: var(--ink);
  border-color: var(--accent);
}
.wf-tmpl-cat-count {
  font-size: 10.5px; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.wf-tmpl-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px 22px 22px;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}
.wf-tmpl-card {
  display: flex; flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.wf-tmpl-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
}
.wf-tmpl-card-head { display: flex; gap: 10px; align-items: flex-start; }
.wf-tmpl-card-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: inline-grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-deep);
  font-weight: 800; font-size: 14px;
  flex: none;
}
.wf-tmpl-card-meta { flex: 1; min-width: 0; }
.wf-tmpl-card-name {
  margin: 0;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  letter-spacing: -.005em;
  line-height: 1.25;
}
.wf-tmpl-card-freq {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-4);
}
.wf-tmpl-card-ints { display: flex; gap: 4px; flex-wrap: wrap; }
.wf-tmpl-card-int {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10.5px;
  color: var(--ink-3);
  background: var(--bg-sunk);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.wf-tmpl-card-benefits {
  margin: 0; padding-left: 18px;
  font-size: 12px; color: var(--ink-2);
  line-height: 1.45;
}
.wf-tmpl-card-benefits li { margin-bottom: 2px; }
.wf-tmpl-card-actions { margin-top: auto; }
.wf-tmpl-card-form { margin: 0; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Templates page (stand-alone, not modal) */
.wf-tmpl-wrap {
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px var(--pad-x) 32px;
}
.wf-tmpl-wrap .wf-tmpl-filters {
  padding: 12px 0;
  border: 0;
}
.wf-tmpl-wrap .wf-tmpl-list {
  padding: 0;
  overflow: visible;
}
.wf-tmpl-card.is-clickable { cursor: pointer; }
.wf-tmpl-card-icon-sm {
  width: 28px; height: 28px;
  border-radius: 7px;
  font-size: 12px;
}

/* Back link in view header */
.back-link {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; color: var(--ink-4);
  text-decoration: none;
  margin-bottom: 4px;
}
.back-link > svg {
  transform: rotate(180deg);
}
.back-link:hover { color: var(--ink); }

/* Drawer reuse — extras for template details */
.wf-tmpl-drawer-freq {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.wf-tmpl-drawer-sec { margin-top: 18px; }
.wf-tmpl-drawer-sec-title {
  margin: 0 0 8px;
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.wf-tmpl-drawer-benefits {
  margin: 0; padding-left: 18px;
  font-size: 13px; color: var(--ink-2);
  line-height: 1.5;
}
.wf-tmpl-drawer-benefits li { margin-bottom: 6px; }

.wf-tmpl-required { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.wf-tmpl-required-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.wf-tmpl-required-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wf-tmpl-required-label { font-weight: 600; color: var(--ink); font-size: 13px; }
.wf-tmpl-required-key { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); }
.wf-tmpl-required-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; }

/* drawer footer pinned to the bottom of the panel for the primary action */
.drawer-footer {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  background: var(--bg-elev);
}

/* Workflow drawer footer — danger-bias row with the Delete action.
   Pinned to the bottom of the drawer body via the parent flex column. */
.wf-drawer-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
}
.wf-drawer-foot .btn { display: inline-flex; align-items: center; gap: 6px; }
.wf-foot-hint {
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.4;
}

/* Soft danger button — same shape as .btn but in the destructive
   palette, used as a "Delete" affordance without screaming red. */
.btn-danger-soft {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bad);
}
.btn-danger-soft:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--bad);
}
.btn-danger-soft:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Default Delete button inside the confirm modal — fully red. */
.btn-danger {
  background: var(--bad);
  border: 1px solid var(--bad);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.95); }

/* Template details drawer — sidebar style (no scrim, page underneath
   remains usable so the user can click another card to swap details). */
.wf-tmpl-drawer-root .drawer.drawer-side {
  position: fixed;
  top: 56px; right: 0; bottom: 0;
  width: 460px; max-width: calc(100vw - 80px);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 22px rgba(0, 0, 0, .06);
  z-index: 60;
  display: flex; flex-direction: column;
  animation: drawer-in .18s ease-out;
}

/* Push the templates grid so the drawer doesn't cover the cards. Uses
   :has so the page only re-flows when the drawer is actually mounted. */
body:has(.wf-tmpl-drawer-root .drawer-side) .wf-tmpl-wrap {
  padding-right: 476px;
}
@media (max-width: 1100px) {
  body:has(.wf-tmpl-drawer-root .drawer-side) .wf-tmpl-wrap {
    padding-right: 0;
  }
}

/* Workflow instance drawer — same sidebar style as templates drawer */
.workflow-drawer-root .drawer.drawer-side {
  position: fixed;
  top: 56px; right: 0; bottom: 0;
  width: 480px; max-width: calc(100vw - 80px);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 22px rgba(0, 0, 0, .06);
  z-index: 60;
  display: flex; flex-direction: column;
  animation: drawer-in .18s ease-out;
}

/* Push main content over so the drawer doesn't overlap. Mirrors the
   template-drawer rule above; transition keeps the squeeze smooth. */
main.view {
  transition: padding-right .18s ease-out;
}
body:has(.workflow-drawer-root .drawer-side) main.view {
  padding-right: 496px;
}
@media (max-width: 1100px) {
  body:has(.workflow-drawer-root .drawer-side) main.view {
    padding-right: 0;
  }
}

/* Workflow templates "Nie znalazłeś czego szukasz?" banner.
   Wcześniej inline style używał var(--accent-wash) → var(--bg-elev)
   gradientu, ale whitelabel wl-vars nadpisuje --accent-wash JASNYM
   kolorem zawsze (whitelabel jest theme-agnostic), więc w dark mode
   gradient zostawał jasny i zalewał czytelność tekstu. Reguły z klasą
   .wf-tmpl-cta zastępują to gradientem z --bg-tinted / --bg-elev
   (oba tokeny mają proper dark mode override w tokens.css i NIE są
   nadpisywane przez whitelabel). */
.wf-tmpl-cta {
  margin: 24px 0;
  padding: 24px 28px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--bg-tinted) 0%, var(--bg-elev) 70%);
  display: flex; gap: 20px; align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.wf-tmpl-cta-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
[data-theme="dark"] .wf-tmpl-cta-icon { color: #14130F; }
.wf-tmpl-cta-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.wf-tmpl-cta-h { font-weight: 600; font-size: 15px; color: var(--ink); }
.wf-tmpl-cta-sub { color: var(--ink-3); font-size: 13px; line-height: 1.5; max-width: 560px; }
.wf-tmpl-cta-btn {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; flex-shrink: 0;
}
