/* ==========================================================================
   Forge Automations Hub — Frontend styles
   All colors are CSS variables set by the plugin from admin settings.
   ========================================================================== */

.fah-wrap {
    font-family: var(--fah-font, inherit);
    color: var(--fah-text);
    background: var(--fah-page-bg);
    padding: 24px;
    border-radius: var(--fah-radius, 12px);
    box-sizing: border-box;
    line-height: 1.55;
}

.fah-wrap *,
.fah-wrap *::before,
.fah-wrap *::after {
    box-sizing: border-box;
}

/* ---------- Toolbar ---------- */
.fah-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
    align-items: center;
    justify-content: space-between;
}

.fah-search {
    flex: 1 1 260px;
    min-width: 220px;
}

.fah-search-input,
.fah-filters select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--fah-section-border);
    border-radius: var(--fah-radius, 12px);
    background: var(--fah-section-bg);
    color: var(--fah-text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.fah-search-input:focus,
.fah-filters select:focus {
    border-color: var(--fah-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fah-accent) 18%, transparent);
}

.fah-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fah-filters select {
    width: auto;
    min-width: 150px;
}

/* ---------- Sections ---------- */
.fah-section {
    background: var(--fah-section-bg);
    border: 1px solid var(--fah-section-border);
    border-radius: var(--fah-radius, 12px);
    padding: 24px 28px;
    margin-bottom: 24px;
}

.fah-section-header {
    margin-bottom: 20px;
}

.fah-section-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--fah-heading);
    letter-spacing: -0.01em;
}

.fah-section-desc {
    margin: 0;
    color: var(--fah-muted);
    font-size: 14px;
}

.fah-empty {
    color: var(--fah-muted);
    font-style: italic;
    margin: 0;
    padding: 16px 0;
}

/* ---------- Timeline (vertical) ---------- */
.fah-timeline {
    list-style: none;
    margin: 0;
    padding: 8px 0 0 0;
    position: relative;
}

.fah-timeline-item {
    position: relative;
    padding-left: 44px;
    padding-bottom: 16px;
    /* Staggered fade-in */
    animation: fah-fade-in 0.35s ease both;
    animation-delay: calc(var(--fah-item-index, 0) * 40ms);
}

@keyframes fah-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* The vertical line */
.fah-timeline-item::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 8px;
    bottom: -8px;
    width: 2px;
    background: var(--fah-timeline-line);
}

.fah-timeline-item:last-child::before {
    bottom: 50%; /* don't extend line past last dot */
}

.fah-timeline-marker {
    position: absolute;
    left: 0;
    top: 14px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    z-index: 1;
}

.fah-timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--fah-timeline-dot);
    box-shadow: 0 0 0 4px var(--fah-section-bg),
                0 0 0 5px var(--fah-timeline-line);
    transition: transform 0.2s ease;
}

.fah-timeline-item:hover .fah-timeline-dot {
    transform: scale(1.15);
}

/* ---------- Card button ---------- */
/* Card — specificity boosted with .fah-wrap ancestor + !important on background
   and hover bg to defeat theme/plugin/Elementor overrides.
   See README — if these still don't take effect, your theme is using a rule
   with a higher specificity (like an ID selector or inline style) and you'll
   need to add custom CSS in the WP Customizer. */
.fah-wrap .fah-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    background: var(--fah-card-bg) !important;
    border: 1px solid var(--fah-card-border);
    border-radius: var(--fah-radius, 12px);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--fah-card-text);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.fah-wrap .fah-card:hover,
.fah-wrap .fah-card:focus-visible {
    background: var(--fah-card-hover-bg) !important;
    border-color: var(--fah-card-hover-border);
    color: var(--fah-card-hover-text);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    outline: none;
}

.fah-card:hover .fah-card-title,
.fah-card:focus-visible .fah-card-title {
    color: var(--fah-card-hover-title);
}

.fah-card:hover .fah-card-preview,
.fah-card:focus-visible .fah-card-preview {
    color: var(--fah-card-hover-text);
    opacity: 0.85;
}

.fah-card:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--fah-accent) 25%, transparent);
}

.fah-card-icon-wrap {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: calc(var(--fah-radius, 12px) * 0.7);
    background: var(--fah-card-icon-bg);
    color: var(--fah-card-icon-color);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.fah-card-title {
    font-weight: 600;
    color: var(--fah-card-title);
    font-size: 15px;
    line-height: 1.3;
    transition: color 0.15s ease;
}

.fah-card-preview {
    color: var(--fah-card-muted);
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s ease;
}

.fah-card-icon-wrap svg {
    display: block;
}

.fah-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fah-card-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fah-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.fah-card-chevron {
    flex: 0 0 auto;
    color: var(--fah-muted);
    display: grid;
    place-items: center;
    transition: transform 0.15s ease, color 0.15s ease;
}

.fah-card:hover .fah-card-chevron {
    color: var(--fah-accent);
    transform: translateX(2px);
}

/* ---------- Badges / chips ---------- */
.fah-badge,
.fah-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}

.fah-chip {
    background: color-mix(in srgb, var(--fah-heading) 6%, transparent);
    color: var(--fah-text);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    font-size: 12px;
}

.fah-badge-status {
    color: #fff;
}

.fah-status-active { background: var(--fah-status-active); }
.fah-status-paused { background: var(--fah-status-paused); }
.fah-status-draft  { background: var(--fah-status-draft); }

.fah-badge-type {
    background: color-mix(in srgb, var(--fah-accent) 15%, transparent);
    color: var(--fah-accent);
}

.fah-badge-steps {
    background: color-mix(in srgb, var(--fah-heading) 8%, transparent);
    color: var(--fah-text);
}

/* ---------- Modal ---------- */
.fah-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.fah-modal.is-open {
    display: flex;
    animation: fah-modal-in 0.2s ease;
}

@keyframes fah-modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.fah-modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--fah-modal-overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.fah-modal-panel {
    position: relative;
    background: var(--fah-modal-bg);
    color: var(--fah-text);
    width: min(720px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border-radius: calc(var(--fah-radius, 12px) + 4px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    padding: 32px;
    animation: fah-panel-in 0.2s ease;
    font-family: var(--fah-font, inherit);
}

@keyframes fah-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fah-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--fah-section-border);
    background: var(--fah-modal-bg);
    color: var(--fah-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fah-modal-close svg {
    display: block;
}

.fah-modal-close:hover,
.fah-modal-close:focus-visible {
    background: color-mix(in srgb, var(--fah-heading) 8%, transparent);
    color: var(--fah-heading);
    border-color: var(--fah-heading);
    outline: none;
}

/* ---------- Detail layout ---------- */
.fah-detail-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-right: 40px; /* leave room for close button */
}

.fah-detail-icon-wrap {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: calc(var(--fah-radius, 12px) * 0.8);
    background: color-mix(in srgb, var(--fah-accent) 12%, transparent);
    color: var(--fah-accent);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.fah-detail-icon-wrap svg {
    display: block;
}

.fah-detail-titlebar { flex: 1; min-width: 0; }

.fah-detail-title {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 700;
    color: var(--fah-heading);
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.fah-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fah-detail-description {
    color: var(--fah-text);
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--fah-section-border);
}

.fah-detail-description p:first-child { margin-top: 0; }
.fah-detail-description p:last-child  { margin-bottom: 0; }

.fah-detail-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .fah-detail-columns { grid-template-columns: 1fr; }
    .fah-modal-panel { padding: 24px 20px; }
    .fah-detail-title { font-size: 20px; }
}

.fah-detail-col h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--fah-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.fah-detail-list {
    margin: 0;
    padding: 0 0 0 20px;
    color: var(--fah-text);
}

.fah-detail-list li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.fah-detail-list-ol { list-style: decimal; }

.fah-muted {
    color: var(--fah-muted);
    font-style: italic;
    margin: 0;
}

/* ---------- Related chips ---------- */
.fah-detail-related {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--fah-section-border);
}

.fah-detail-related h3 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--fah-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.fah-related-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fah-related-chip {
    border: 1px solid var(--fah-card-border);
    background: var(--fah-card-bg);
    color: var(--fah-text);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fah-related-chip:hover,
.fah-related-chip:focus-visible {
    background: var(--fah-accent);
    color: var(--fah-accent-text);
    border-color: var(--fah-accent);
    outline: none;
}

/* Templates used as data stores are inert by default, but this is explicit */
.fah-wrap template.fah-detail-data {
    display: none !important;
}

/* ---------- Item filtering ---------- */
.fah-timeline-item.is-hidden {
    display: none;
}

/* Body scroll lock when modal open */
body.fah-modal-open {
    overflow: hidden;
}

/* ==========================================================================
   v1.1 additions — nested sections, branching action tree, branch chip
   ========================================================================== */

/* ---------- Nested sections ---------- */
.fah-subsections {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--fah-section-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fah-subsections .fah-section {
    /* Child sections are visually lighter and tucked inside the parent */
    background: color-mix(in srgb, var(--fah-section-bg) 70%, var(--fah-page-bg) 30%);
    padding: 18px 20px;
    margin-bottom: 0;
}

.fah-section-depth-1 .fah-section-title { font-size: 18px; }
.fah-section-depth-2 .fah-section-title { font-size: 16px; }
.fah-section-depth-3 .fah-section-title { font-size: 15px; }

/* ---------- Branching chip on card ---------- */
.fah-chip-branch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: color-mix(in srgb, var(--fah-accent) 12%, transparent);
    color: var(--fah-accent);
    font-weight: 600;
}

.fah-chip-branch svg {
    display: block;
}

/* ---------- Related chip with icon ---------- */
.fah-related-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fah-related-chip svg {
    display: block;
    flex-shrink: 0;
}

/* ---------- Branching actions tree ---------- */
.fah-actions-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: fah-step;
}

/* Counter-based numbering lives in the v1.4 collapsible rules below
   (see .fah-actions-view--linear). The old depth-0 ::before block
   that lived here was removed in v1.6 because it caused doubled numbers. */

.fah-action-label {
    color: var(--fah-text);
    line-height: 1.5;
}

/* "If X →" branch label */
.fah-action-branch {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 4px;
}

.fah-action-branch-word {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fah-muted);
    font-size: 11px;
}

.fah-action-branch-cond {
    background: color-mix(in srgb, var(--fah-accent) 10%, transparent);
    color: var(--fah-accent);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.fah-action-branch-arrow {
    color: var(--fah-muted);
    font-weight: 700;
}

/* ==========================================================================
   v1.2 additions — Branch chips and badges
   ========================================================================== */

/* Branch chip on cards — stronger visual weight than other chips since it's the primary identifier */
.fah-chip-branch-code {
    background: color-mix(in srgb, var(--fah-accent) 14%, transparent);
    color: var(--fah-accent);
    font-family: Menlo, Consolas, "Roboto Mono", monospace;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
    padding: 3px 9px;
    border: 1px solid color-mix(in srgb, var(--fah-accent) 30%, transparent);
}

.fah-chip-branch-all {
    background: var(--fah-accent);
    color: var(--fah-accent-text);
    border-color: var(--fah-accent);
}

/* Branch badges in the modal header */
.fah-badge-branch {
    background: color-mix(in srgb, var(--fah-accent) 14%, transparent);
    color: var(--fah-accent);
    font-family: Menlo, Consolas, "Roboto Mono", monospace;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid color-mix(in srgb, var(--fah-accent) 30%, transparent);
}

.fah-badge-branch-all {
    background: var(--fah-accent);
    color: var(--fah-accent-text);
    border-color: var(--fah-accent);
}

/* ==========================================================================
   v1.3 — Linear view cleanup + Flow chart + View toggle
   ========================================================================== */

/* --- View toggle tabs --- */
.fah-actions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.fah-actions-header h3 {
    margin: 0;
}

.fah-view-toggle {
    display: inline-flex;
    background: color-mix(in srgb, var(--fah-heading) 6%, transparent);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.fah-view-toggle-btn {
    background: transparent;
    border: 0;
    color: var(--fah-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.fah-view-toggle-btn:hover {
    color: var(--fah-heading);
}

.fah-view-toggle-btn.is-active {
    background: var(--fah-modal-bg);
    color: var(--fah-heading);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* --- View containers --- */
.fah-actions-view {
    display: none;
}

.fah-actions-view.is-active {
    display: block;
}

/* --- Linear view — cleaner than v1.2 --- */
/* Nested ols get no decorator on sequential-step children — they inherit
   the numbered container from the top-level. Conditional branches get
   the pill + arrow treatment. */

.fah-actions-tree .fah-actions-tree {
    margin-top: 6px;
    margin-left: 8px;
    padding-left: 16px;
    /* Dashed vertical connector only shown when there are conditional branches inside */
    border-left: none;
}

/* If ANY child item in a sublist is a branch, show the dashed connector */
.fah-actions-tree:has(> .fah-action-item--branch) {
    border-left: 2px dashed color-mix(in srgb, var(--fah-accent) 35%, transparent);
}

/* Fallback for browsers without :has() — always show faint connector on nested lists */
@supports not (selector(:has(*))) {
    .fah-actions-tree .fah-actions-tree {
        border-left: 1px solid color-mix(in srgb, var(--fah-heading) 8%, transparent);
    }
}

.fah-actions-tree .fah-actions-tree > .fah-action-item--step {
    /* Sequential sub-step: minimal decoration — just indented */
    padding-left: 4px;
    margin-bottom: 10px;
}

.fah-actions-tree .fah-actions-tree > .fah-action-item--branch {
    padding-left: 4px;
    margin-bottom: 12px;
}

/* --- Flow chart --- */
.fah-actions-view--flow {
    overflow-x: auto;
    padding: 8px 0;
    margin: 0 -4px;
}

.fah-flow-svg {
    display: block;
    /* Keep some minimum so tiny charts aren't squashed */
    min-height: 80px;
}

.fah-flow-node-rect {
    fill: var(--fah-card-bg);
    stroke: var(--fah-card-border);
    stroke-width: 1.5;
}

.fah-flow-node--branch .fah-flow-node-rect {
    fill: color-mix(in srgb, var(--fah-accent) 8%, var(--fah-card-bg));
    stroke: var(--fah-accent);
    stroke-width: 1.5;
}

.fah-flow-node-text {
    fill: var(--fah-heading);
    font-family: var(--fah-font, inherit);
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
}

.fah-flow-edge {
    stroke: color-mix(in srgb, var(--fah-heading) 25%, transparent);
    stroke-width: 1.5;
}

.fah-flow-edge-label-bg {
    fill: var(--fah-accent);
}

.fah-flow-edge-label-text {
    fill: var(--fah-accent-text);
    font-family: var(--fah-font, inherit);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

/* ==========================================================================
   v1.4 — Collapsible linear view + Flow chart fullscreen
   ========================================================================== */

/* --- Linear view rewrite (replaces prior v1.3 attempt) --- */
.fah-actions-view--linear .fah-actions-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: fah-step;
}

/* Depth-0 items keep numbered indicators */
.fah-actions-view--linear .fah-actions-depth-0 > .fah-action-item {
    counter-increment: fah-step;
    margin-bottom: 12px;
}

.fah-actions-view--linear .fah-action-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
}

/* Toggle chevron */
.fah-action-toggle {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--fah-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    margin-top: 1px;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.fah-action-toggle:hover,
.fah-action-toggle:focus-visible {
    background: color-mix(in srgb, var(--fah-heading) 8%, transparent);
    color: var(--fah-heading);
    outline: none;
}

.fah-action-toggle svg {
    display: block;
    transition: transform 0.2s ease;
}

/* Expanded: chevron points down */
.fah-action-item:not(.is-collapsed) > .fah-action-row > .fah-action-toggle svg {
    transform: rotate(90deg);
}

.fah-action-toggle-spacer {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin-top: 1px;
}

.fah-action-content {
    flex: 1;
    min-width: 0;
}

/* Depth-0 step number badge, rendered via counter */
.fah-actions-view--linear .fah-actions-depth-0 > .fah-action-item > .fah-action-row::before {
    content: counter(fah-step);
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--fah-accent) 15%, transparent);
    color: var(--fah-accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    margin-top: 1px;
    order: -1;
}

.fah-actions-view--linear .fah-action-label {
    color: var(--fah-text);
    line-height: 1.5;
    font-size: 14px;
}

.fah-actions-view--linear .fah-action-summary {
    color: var(--fah-muted);
    font-size: 12px;
    font-style: italic;
    margin-top: 4px;
}

/* Children wrapper */
.fah-actions-view--linear .fah-action-children-wrap {
    margin-top: 6px;
    margin-left: 32px; /* aligns children under toggle + content, clear of step number */
    overflow: hidden;
    max-height: 5000px;
    transition: max-height 0.3s ease;
}

.fah-actions-view--linear .fah-action-item.is-collapsed > .fah-action-children-wrap {
    max-height: 0;
}

/* When a subtree has conditional branches, show the dashed vertical connector */
.fah-actions-view--linear .fah-action-children-wrap > .fah-actions-tree:has(> .fah-action-item--branch) {
    border-left: 2px dashed color-mix(in srgb, var(--fah-accent) 30%, transparent);
    padding-left: 14px;
}

@supports not (selector(:has(*))) {
    .fah-actions-view--linear .fah-action-children-wrap > .fah-actions-tree {
        padding-left: 14px;
    }
}

.fah-actions-view--linear .fah-action-item--branch {
    margin-bottom: 10px;
}

.fah-actions-view--linear .fah-action-item--step {
    margin-bottom: 8px;
}

/* Prior v1.3 rules tidied: ensure no duplicate step numbering in nested ols */
.fah-actions-view--linear .fah-actions-tree .fah-actions-tree {
    counter-reset: none;
    border-left: none;
    padding-left: 0;
    margin-left: 0;
}

.fah-actions-view--linear .fah-actions-tree .fah-actions-tree > .fah-action-item > .fah-action-row::before {
    content: none;
}

/* --- Flow chart preview toolbar + hint --- */
.fah-flow-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.fah-flow-expand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: color-mix(in srgb, var(--fah-heading) 6%, transparent);
    color: var(--fah-text);
    border: 1px solid var(--fah-section-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.fah-flow-expand:hover,
.fah-flow-expand:focus-visible {
    background: color-mix(in srgb, var(--fah-accent) 10%, transparent);
    border-color: var(--fah-accent);
    color: var(--fah-accent);
    outline: none;
}

.fah-flow-canvas {
    overflow-x: auto;
    overflow-y: hidden;
    cursor: zoom-in;
    border-radius: 6px;
    background: color-mix(in srgb, var(--fah-heading) 3%, transparent);
    padding: 8px;
}

.fah-flow-canvas:hover {
    outline: 2px solid color-mix(in srgb, var(--fah-accent) 40%, transparent);
}

.fah-flow-hint {
    margin: 6px 0 0;
    color: var(--fah-muted);
    font-size: 11px;
    font-style: italic;
    text-align: right;
}

/* --- Flow chart fullscreen overlay --- */
.fah-flow-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 100001; /* above the main modal */
    display: none;
    flex-direction: column;
    background: var(--fah-page-bg);
    font-family: var(--fah-font, inherit);
}

.fah-flow-fullscreen.is-open {
    display: flex;
}

body.fah-flow-fullscreen-open {
    overflow: hidden;
}

.fah-flow-fullscreen-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--fah-section-bg);
    border-bottom: 1px solid var(--fah-section-border);
    gap: 12px;
    flex-wrap: wrap;
}

.fah-flow-fullscreen-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--fah-heading);
}

.fah-flow-fullscreen-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fah-flow-fullscreen-controls button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--fah-section-border);
    background: var(--fah-modal-bg);
    color: var(--fah-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fah-flow-fullscreen-controls button:hover,
.fah-flow-fullscreen-controls button:focus-visible {
    background: color-mix(in srgb, var(--fah-accent) 10%, transparent);
    border-color: var(--fah-accent);
    color: var(--fah-accent);
    outline: none;
}

.fah-flow-fullscreen-close {
    margin-left: 4px;
}

.fah-flow-fullscreen-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background:
        radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--fah-heading) 8%, transparent) 1px, transparent 0);
    background-size: 24px 24px;
}

.fah-flow-fullscreen-stage.is-panning {
    cursor: grabbing;
}

.fah-flow-fullscreen-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none; /* so drag events go to stage, not the SVG */
}

.fah-flow-fullscreen-canvas svg {
    display: block;
    pointer-events: auto; /* but individual SVG bits can still interact if we add that later */
}

.fah-flow-fullscreen-hint {
    flex: 0 0 auto;
    padding: 8px 20px;
    background: var(--fah-section-bg);
    border-top: 1px solid var(--fah-section-border);
    color: var(--fah-muted);
    font-size: 11px;
    text-align: center;
}

/* Bigger text in the flow chart nodes so small previews are still readable */
.fah-flow-node-text {
    font-size: 13px;
}

/* ==========================================================================
   v1.6 — Frontend criteria list with AND/OR pills
   ========================================================================== */

.fah-criteria-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fah-criteria-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--fah-text);
    line-height: 1.45;
    font-size: 14px;
}

.fah-criteria-item::before {
    content: "•";
    color: var(--fah-muted);
    font-weight: 700;
    line-height: 1.45;
}

/* When the item starts with an AND/OR pill, hide the bullet */
.fah-criteria-item:has(.fah-criteria-op)::before {
    content: none;
}

.fah-criteria-op {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 4px;
    line-height: 1.4;
    margin-top: 2px;
    min-width: 38px;
    justify-content: center;
}

.fah-criteria-op-and {
    background: color-mix(in srgb, var(--fah-accent) 15%, transparent);
    color: var(--fah-accent);
}

.fah-criteria-op-or {
    background: color-mix(in srgb, var(--fah-accent-2, var(--fah-accent)) 15%, transparent);
    color: var(--fah-accent-2, var(--fah-accent));
}

.fah-criteria-text {
    flex: 1;
    min-width: 0;
}

/* Fallback for browsers without :has() — keep the bullet on all items */
@supports not (selector(:has(*))) {
    .fah-criteria-item::before {
        content: "•";
    }
}
