/* Pipelines (/workflows): workflows_screen.dart and its widgets.
 * Flutter logical px; Material 3 type scale as the app's theme sets it
 * (titleSmall 14/20 .1, bodySmall 12/16 .4, labelMedium 12/16 .5). Desktop
 * density is compact, so icon buttons are 32 and the primary button 32 high. */

:root { --wfl-primary: var(--primary); --wfl-success: var(--success); --wfl-warning: var(--warning); --wfl-secondary: var(--secondary); --wfl-purple: #9C27B0; --wfl-elev: 0 3px 5px -1px rgba(0,0,0,.2), 0 6px 10px rgba(0,0,0,.14), 0 1px 18px rgba(0,0,0,.12); }

.page.wfl-host { padding: 24px; }
.wfl { container-type: inline-size; }
/* Flex columns, so a card's 4px margin adds to the section spacing instead
   of collapsing into it (Flutter has no margin collapsing). */
.wfl > div, #wfl-lists, .wfl-running, #wfl-mine { display: flex; flex-direction: column; }
.wfl > div[x-cloak] { display: none; }
.wfl-flex { flex: 1; }
.wfl-gap { width: 6px; }

/* ── Top bar actions ──────────────────────────────────────────────── */
.wfl-actions { display: flex; align-items: center; gap: 12px; }
.wfl-toggle { display: flex; background: var(--surface-light); border: 1px solid var(--border); border-radius: 8px; }
.wfl-toggle button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; color: var(--text-2); border: 1px solid transparent; }
.wfl-toggle button.is-on { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: 0 1px 2px var(--shadow); }
.wfl-hist { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-light); color: var(--text-2); }
.wfl-hist.is-on { background: var(--selected); color: var(--text); }
.wfl-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 24px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 14px; font-weight: 500; letter-spacing: .1px; white-space: nowrap; }
.wfl-btn:hover { background: color-mix(in srgb, var(--primary) 92%, #fff); }
.wfl-new { position: relative; }

/* Menus: the New Workflow MenuAnchor and each card's PopupMenuButton */
.wfl-menu { position: absolute; z-index: 50; background: var(--card); border-radius: 12px; padding: 8px 0; box-shadow: var(--menu-shadow); }
.wfl-newmenu { right: 0; top: calc(100% + 8px); }
.wfl-mt { display: flex; align-items: center; gap: 12px; width: 280px; padding: 10px 12px; text-align: left; }
.wfl-mt:hover, .wfl-mi:hover { background: var(--hover); }
.wfl-mt b { display: block; font-size: 14px; font-weight: 500; line-height: 20px; color: var(--text); }
.wfl-mt small { display: block; font-size: 11px; line-height: 16px; letter-spacing: .4px; color: var(--text-2); }
.wfl-ibox { --c: var(--primary); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); flex: none; }
.wfl-ibox.is-muted, .wfl-tbox.is-muted { --c: var(--text-2); }
.wfl-menu-div { height: 1px; background: var(--border); margin: 8px 12px; }
.wfl-menu-div.is-tight { margin: 8px 0; }
.wfl-menu-head { padding: 4px 16px 8px; font-size: 10px; font-weight: 600; letter-spacing: .5px; line-height: 1.45; color: var(--muted); }
.wfl-popup { right: 0; top: 0; min-width: 160px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.wfl-mi { display: flex; align-items: center; gap: 8px; width: 100%; height: 48px; padding: 0 12px; font-size: 14px; color: var(--text); white-space: nowrap; }
.wfl-mi .ic { color: var(--text-2); }
.wfl-mi.is-danger, .wfl-mi.is-danger .ic { color: var(--error); }

/* ── Section labels ───────────────────────────────────────────────── */
.wfl-label { font-size: 12px; font-weight: 600; letter-spacing: .5px; line-height: 16px; color: var(--text-2); margin: 0 0 16px; }
#wfl-lists + .wfl-label { margin: 24px 0 12px; }
.wfl-label.is-live { display: flex; align-items: center; gap: 8px; color: var(--success); margin-bottom: 12px; }
.wfl-label.is-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.wfl-label.is-inline { margin: 0 6px 0 0; }

/* Cards share AppCard: white, 1px border, 12 radius, a hover overlay, and a
   link stretched over them so the menu buttons stay buttons. */
.wfl-card, .wfl-rcard, .wfl-tcard, .wfl-list, .wfl-empty, .wfl-runs-empty { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.wfl-card, .wfl-rcard, .wfl-lrow { position: relative; }
/* Flutter's Card: a 4px margin on every side, and the border drawn over
   the padding rather than outside it (hence 15 + 1). */
.wfl-card, .wfl-rcard, .wfl-tcard, .wfl-list, .wfl-empty { margin: 4px; }
.wfl-card:hover, .wfl-rcard:hover, .wfl-tcard:hover, .wfl-lrow:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
.wfl-stretch { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.wfl-more, .wfl-stop { position: relative; z-index: 2; }

/* ── RUNNING NOW ──────────────────────────────────────────────────── */
.wfl-running:not(:empty) { margin-bottom: 32px; }
.wfl-rcard { display: flex; align-items: center; padding: 15px; margin-bottom: 16px; }
.wfl-play { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); flex: none; }
.wfl-play .ic { animation: wflpulse 1.5s var(--ease-in-out) infinite alternate; }
@keyframes wflpulse { from { transform: scale(.7); } to { transform: scale(1); } }
.wfl-rtext { flex: 1; min-width: 0; margin-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.wfl-rtext b, .wfl-cname, .wfl-ltext b, .wfl-ttext b { font-size: 14px; font-weight: 600; line-height: 20px; letter-spacing: .1px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfl-rtext small, .wfl-cnodes, .wfl-ltext small, .wfl-ttext small { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--text-2); }
.wfl-prog { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wfl-prog b { font-size: 14px; font-weight: 600; line-height: 20px; letter-spacing: .1px; color: var(--success); }
.wfl-prog i { display: block; width: 100px; height: 6px; border-radius: 4px; background: var(--surface-light); overflow: hidden; }
.wfl-prog s { display: block; height: 100%; background: var(--success); transition: width 400ms var(--ease-out); }
.wfl-stop { display: grid; place-items: center; width: 32px; height: 32px; margin-left: 8px; border-radius: 50%; color: var(--error); }
.wfl-stop:hover { background: color-mix(in srgb, var(--error) 8%, transparent); }

/* ── MY WORKFLOWS: the grid (3 / 2 / 1 columns past 900 / 600) ─────── */
.wfl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.wfl-tgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@container (max-width: 900px) { .wfl-grid, .wfl-tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 600px) { .wfl-grid, .wfl-tgrid { grid-template-columns: minmax(0, 1fr); } }

.wfl-card { padding: 15px; }
.wfl-chead { display: flex; align-items: center; gap: 4px; height: 40px; margin-bottom: 16px; }
.wfl-cbox { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.wfl-sched-chip { display: grid; place-items: center; width: 26px; height: 20px; border-radius: 4px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.wfl-badge { --c: var(--text-2); display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 4px; font-size: 10px; font-weight: 500; letter-spacing: .25px; color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.wfl-badge.is-ok { --c: var(--success); }
.wfl-badge.is-fail { --c: var(--error); }
.wfl-dots { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--text-2); }
.wfl-dots:hover { background: var(--hover); }
.wfl-cnodes { margin-top: 4px; }
.wfl-clast { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--text-2); }
.wfl-clast.is-ok .ic { color: var(--success); }
.wfl-clast.is-fail .ic { color: var(--error); }
.wfl-clast.is-never { color: var(--muted); }

/* The list view */
.wfl-list { overflow: hidden; }
.wfl-lrow { display: flex; align-items: center; padding: 12px 16px; }
.wfl-lrow + .wfl-lrow { border-top: 1px solid rgba(255, 255, 255, .05); }
.wfl-lbox { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); flex: none; }
.wfl-ltext { flex: 1; min-width: 0; margin-left: 12px; display: flex; flex-direction: column; gap: 2px; }
.wfl-lsched { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; margin-right: 12px; border-radius: 4px; font-size: 10px; font-weight: 500; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.wfl-lstatus { margin-right: 12px; color: var(--text-2); }
.wfl-lstatus.is-ok { color: var(--success); }
.wfl-lstatus.is-fail { color: var(--error); }

.wfl-empty { display: flex; flex-direction: column; align-items: center; padding: 48px 16px; }
.wfl-empty-ic { padding: 16px; border-radius: 16px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.wfl-empty b { margin-top: 16px; font-size: 14px; font-weight: 600; }
.wfl-empty small { margin-top: 8px; font-size: 12px; color: var(--text-2); }

/* ── TEMPLATES ───────────────────────────────────────────────────── */
.wfl-tcard { display: flex; align-items: center; gap: 12px; min-height: 104px; padding: 15px; text-align: left; }
.wfl-tbox { --c: var(--primary); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); flex: none; }
.wfl-ttext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wfl-ttext small { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfl-ttext i { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-style: normal; font-size: 10px; line-height: 13px; letter-spacing: .4px; color: var(--muted); }
.wfl-chev { color: var(--text-2); }

/* ── Run history (OrgRunsPanel) ──────────────────────────────────── */
.wfl-runs-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.wfl-chip { padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border); font-size: 10px; line-height: 1.43; color: var(--muted); }
.wfl-chip.is-on { font-weight: 600; color: var(--text); background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .25); }
.wfl-chip:hover { background-color: var(--hover); }
.wfl-refresh { display: grid; place-items: center; width: 28px; height: 28px; margin-left: -2px; border-radius: 50%; color: var(--muted); }
.wfl-refresh:hover { background: var(--hover); }
.wfl-refresh[disabled] { opacity: .38; }
.wfl-rlist, .wfl-runs-sk { margin: 0; background: var(--surface); }
.wfl-runs-sk { padding: 0; }
.wfl-sk-row { display: flex; align-items: center; gap: 10px; padding: 14px 12px; }
.wfl-sk-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.wfl-sk-row b { flex: 1; height: 10px; border-radius: 4px; background: var(--border); }
.wfl-run { display: block; padding: 10px 12px; border-radius: 8px; }
.wfl-run:hover { background: var(--hover); }
.wfl-run + .wfl-run { border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); border-radius: 0; }
.wfl-run-top { display: flex; align-items: center; gap: 8px; }
.wfl-run-top b { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfl-run-top small { font-size: 10px; color: var(--muted); }
.wfl-run-top small + small { margin-left: 2px; }
.wfl-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.wfl-dot.is-ok { background: var(--success); }
.wfl-dot.is-fail { background: var(--error); }
.wfl-dot.is-warn { background: var(--warning); }
.wfl-run-sub { display: block; margin: 3px 0 0 16px; font-size: 11px; }
.wfl-run-sub em { font-style: normal; font-weight: 500; color: var(--muted); }
.wfl-run-sub em.is-ok { color: var(--success); }
.wfl-run-sub em.is-fail { color: var(--error); }
.wfl-run-sub em.is-warn { color: var(--warning); }
.wfl-run-sub small { font-size: 11px; color: var(--muted); }
.wfl-run-err { display: block; margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: color-mix(in srgb, var(--error) 8%, transparent); border: 1px solid color-mix(in srgb, var(--error) 25%, transparent); }
.wfl-run-err b { display: block; margin-bottom: 3px; font-size: 10px; font-weight: 600; color: var(--error); }
.wfl-run-err span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.35; color: var(--text-2); }
.wfl-runs-empty { padding: 24px; text-align: center; font-size: 12px; color: var(--muted); background: var(--surface); }
.wfl-runs-fail { padding: 16px 14px; border-radius: 12px; background: color-mix(in srgb, var(--error) 8%, transparent); border: 1px solid color-mix(in srgb, var(--error) 25%, transparent); }
.wfl-runs-fail b { display: block; font-size: 12px; font-weight: 600; color: var(--error); }
.wfl-runs-fail span { display: block; margin-top: 4px; font-size: 11px; color: var(--text-2); }

/* ── Dialogs (AlertDialog, the schedule Dialog, the range picker) ── */
.wfl-dlg-layer { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; }
.wfl-barrier { position: absolute; inset: 0; background: rgba(0, 0, 0, .54); }
.wfl-dlg { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--wfl-elev); min-width: 280px; max-width: calc(100% - 80px); animation: wfldlg 150ms var(--ease-out) both; }
@keyframes wfldlg { from { opacity: 0; transform: scale(.96); } }
.wfl-alert { padding: 24px; width: 100%; }
.wfl-dlg.is-create, .wfl-dlg.is-rename, .wfl-dlg.is-range { width: 400px; }
.wfl-alert h2 { margin: 0 0 16px; font-size: 16px; font-weight: 500; line-height: 1.5; }
.wfl-alert p { margin: 0; font-size: 14px; line-height: 20px; color: var(--text-2); }
.wfl-alert-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.wfl-tbtn { height: 32px; padding: 0 16px; border-radius: 16px; font-size: 14px; font-weight: 500; letter-spacing: .1px; color: var(--primary); }
.wfl-tbtn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.wfl-tbtn.is-danger { color: var(--error); }
.wfl-tbtn.is-danger:hover { background: color-mix(in srgb, var(--error) 8%, transparent); }
.wfl-tbtn[disabled] { opacity: .38; pointer-events: none; }
.wfl-field { position: relative; display: block; }
.wfl-field span { position: absolute; left: 12px; top: -7px; padding: 0 4px; font-size: 12px; line-height: 14px; color: var(--text-2); background: linear-gradient(var(--surface) 50%, var(--surface-light) 50%); }
.wfl-field input { width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-light); font-size: 16px; outline: none; }
:root[data-theme="dark"] .wfl-field input { background: var(--surface); }
:root[data-theme="dark"] .wfl-field span { background: var(--surface); }
.wfl-field input:focus { border-color: var(--primary); border-width: 2px; padding-left: 15px; }
.wfl-field input:focus + span, .wfl-field:focus-within span { color: var(--primary); }
.wfl-dates { display: flex; gap: 12px; padding-top: 6px; }
.wfl-dates .wfl-field { flex: 1; }

.wfl-sched { width: 480px; max-width: calc(100vw - 32px); max-height: 640px; display: flex; flex-direction: column; font-size: 14px; color: var(--text); }
.wfl-sched header { display: flex; align-items: center; gap: 12px; padding: 20px 12px 8px 20px; border-bottom: 1px solid var(--border); }
.wfl-sched header b { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfl-x { display: grid; place-items: center; width: 24px; height: 24px; color: var(--text-2); }
.wfl-sched-body { overflow: auto; padding: 16px 20px; }
.wfl-sched-on { display: flex; align-items: center; }
.wfl-sched-on span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.wfl-sched-on b { font-size: 14px; font-weight: 500; }
.wfl-sched-on small { font-size: 12px; color: var(--text-2); }
.wfl-switch { position: relative; width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--border); background: color-mix(in srgb, var(--muted) 25%, transparent); transition: background-color 120ms linear; }
:root[data-theme="dark"] .wfl-switch { background: var(--surface-light); }
.wfl-switch i { position: absolute; left: 6px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: left 160ms var(--ease-out-cubic), width 160ms, height 160ms, top 160ms; }
.wfl-switch[aria-checked="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 45%, transparent); }
.wfl-switch[aria-checked="true"] i { left: 22px; top: 2px; width: 24px; height: 24px; background: var(--primary); }
.wfl-sched-div { height: 1px; background: var(--border); margin: 16px 0; }
.wfl-sched-label { margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: .4px; color: var(--text-2); }
.wfl-radio { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 0; text-align: left; color: var(--text); }
.wfl-radio i { display: grid; place-items: center; width: 32px; height: 32px; }
.wfl-radio i::before { content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box; }
.wfl-radio.is-on i::before { border-color: var(--primary); background: radial-gradient(var(--primary) 0 4.5px, transparent 5px); }
.wfl-radio[disabled] { color: var(--text-2); cursor: default; }
.wfl-radio[disabled] i::before { opacity: .38; }
.wfl-cron { display: block; margin-top: 12px; }
.wfl-cron span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.wfl-cron input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-light); font-family: monospace; font-size: 14px; outline: none; }
.wfl-cron input:focus { border-color: var(--primary); }
.wfl-cron small { display: block; margin: 4px 12px 0; font-size: 12px; color: var(--text-2); }
.wfl-sched footer { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.wfl-sched footer .wfl-btn { height: 32px; }

/* ── Snackbar (fixed, full width at the bottom) ───────────────────── */
.wfl-toasts { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-toast); pointer-events: none; }
.wfl-snack { pointer-events: auto; display: flex; align-items: center; min-height: 48px; padding: 14px 16px; font-size: 14px; background: var(--surface); color: var(--text); box-shadow: var(--wfl-elev); animation: wflsnack 250ms var(--ease-out-cubic) both; }
.wfl-snack.is-ok { background: var(--success); }
.wfl-snack.is-error { background: var(--error); }
.wfl-snack.is-out { animation: wflsnackout 200ms linear both; }
@keyframes wflsnack { from { transform: translateY(100%); } }
@keyframes wflsnackout { to { opacity: 0; } }

.wfl-back { display: inline-block; margin-top: 12px; color: var(--primary); }
.wfl-more.is-open { z-index: 30; }

/* Where the data comes from (live mode), as Plan de demanda's .pl-source. */
.wfl-source { color: var(--success); font-weight: 500; }
.wfl-source.is-error { color: var(--warning); }
.wfl-source-note { margin: 0 4px 8px; font-size: 12px; }
