/* ═══════════════════════════════════════════════════════════════════════════
   Unified Workflow Framework — layout + shared components
   ─────────────────────────────────────────────────────────────────────────
   DESIGN SYSTEM (Rony Scarfati):
   Single shared stylesheet for every workflow.  No per-workflow CSS.
   New workflows are composed entirely from JSON — this file + the
   partials (_wf_image_drop, _wf_radio_group, etc.) handle all rendering.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════════════
   DESIGN RULES (Rony Scarfati):
   - Every component type has ONE fixed size — content adapts inside.
   - Drop zone = drop zone, gallery = gallery, button = button.
   - Never vary dimensions based on content count or workflow type.
   - Single column flow — same on desktop and mobile.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Single-column flow — centered, max-width 700px ──────────────────── */
.wf-flow {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    max-width: 700px;
    margin: 0 auto;
    padding: 1rem;
}

/* ── DROP ZONE: compact empty state, grows when image loaded ──────────── */
.wf-flow .image-panel,
.wf-flow .paste-box {
    min-height: 120px;
    overflow: hidden;
    transition: min-height .2s ease;
}
.wf-flow .image-panel.has-preview {
    min-height: auto;
}
.wf-flow .image-panel.has-preview .canvas-wrap {
    display: flex;
    justify-content: center;
    padding: .5rem;
}
.wf-flow .image-panel.has-preview .preview-image {
    max-height: 220px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 6px;
}
/* Action links below the preview */
.wf-preview-actions {
    display: none;
    justify-content: center;
    gap: 1.25rem;
    padding: .35rem 0 .25rem;
}
.has-preview .wf-preview-actions { display: flex; }
.wf-preview-action {
    background: none;
    border: none;
    color: var(--muted, #777);
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    padding: 2px 4px;
    transition: color .15s;
}
.wf-preview-action:hover { color: var(--text, #eee); }
.wf-preview-action--remove:hover { color: #e55; }

/* ── RECIPE STRIP — collects choices inside the product panel ────────── */
.wf-recipe-strip {
    display: none;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .5rem;
    padding: .5rem 0 .25rem;
    border-top: 1px solid rgba(255,255,255,.06);
    margin-top: .25rem;
}
.wf-recipe-strip.has-items { display: flex; }

.wf-recipe-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    animation: recipeIn .25s ease;
}
@keyframes recipeIn {
    from { opacity: 0; transform: scale(.85) translateY(4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.wf-recipe-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 1.5px solid var(--border, rgba(255,255,255,.15));
}
.wf-recipe-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.2);
    flex-shrink: 0;
}
.wf-recipe-pill {
    padding: .2rem .5rem;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border, rgba(255,255,255,.12));
    border-radius: 4px;
    font-size: .7rem;
    color: var(--text, #ddd);
    white-space: nowrap;
}
.wf-recipe-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted, #666);
    max-width: 64px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wf-recipe-plus {
    color: var(--muted, #555);
    font-size: 1rem;
    line-height: 56px;
    padding: 0 .15rem;
}

/* ── Drop zone (shared: multi-image + video) ──────────────────────────── */
.wf-dropzone {
    display: block;
    cursor: pointer;
    border: 2px dashed var(--border, rgba(255,255,255,.15));
    border-radius: 12px;
    padding: 28px 16px;
    text-align: center;
    transition: border-color .2s, background .2s;
    margin-top: .75rem;
}
.wf-dropzone:hover,
.wf-dropzone.is-dragover {
    border-color: var(--accent, #f28b3c);
    background: rgba(242,139,60,.04);
}
.wf-dropzone.wf-has-file { border-style: solid; border-color: var(--accent, #f28b3c); }
.wf-dropzone-icon { font-size: 2rem; color: var(--accent, #f28b3c); margin-bottom: 4px; }
.wf-dropzone-label { font-size: .92rem; font-weight: 600; margin: 0; }
.wf-dropzone-hint { font-size: .78rem; margin: 4px 0 0; }
.wf-file-hidden { display: none; }

/* ── Video preview ────────────────────────────────────────────────────── */
.wf-video-dropzone { min-height: 200px; overflow: hidden; }
.wf-video-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .75rem;
    gap: .5rem;
}
.wf-video-el {
    width: 100%;
    max-height: 240px;
    object-fit: contain;
    border-radius: 6px;
    background: #000;
}
.wf-file-name { font-size: 11px; word-break: break-all; }

/* ── Thumb strip (multi-image) ────────────────────────────────────────── */
.wf-thumbstrip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
    margin-top: .5rem;
}
.wf-thumb-card {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
.wf-thumb-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wf-thumb-num {
    position: absolute;
    bottom: 3px; left: 3px;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}
.wf-thumb-remove {
    position: absolute;
    top: 2px; right: 2px;
    background: rgba(0,0,0,.65);
    color: #fff;
    border: none; border-radius: 50%;
    width: 18px; height: 18px;
    font-size: .75rem; line-height: 18px;
    text-align: center; cursor: pointer;
    padding: 0; opacity: 0;
    transition: opacity .15s;
}
.wf-thumb-card:hover .wf-thumb-remove { opacity: 1; }

/* ── OPTIONS TOOLBAR — horizontal row ────────────────────────────────── */
.wf-options-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border: 1.5px solid var(--border, rgba(255,255,255,.12));
    border-radius: 10px;
    background: rgba(255,255,255,.02);
}
.wf-options-toolbar .eyebrow {
    margin-right: .25rem;
    font-size: 10px;
}
.wf-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border, rgba(255,255,255,.15));
    margin: 0 .25rem;
}
.wf-option-group { margin: 0; }
.wf-option-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .03em;
    margin-bottom: .2rem;
}
.wf-option-hint { font-size: .72rem; margin: 0 0 .2rem; }

/* Radio pills (inline for toolbar) */
.wf-radio-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.wf-radio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .7rem;
    border: 1.5px solid var(--border, rgba(255,255,255,.12));
    border-radius: 6px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: .78rem;
    white-space: nowrap;
}
.wf-radio-card input[type="radio"] { display: none; }
.wf-radio-card:hover { border-color: rgba(255,255,255,.25); }
.wf-radio-card:has(input:checked) {
    border-color: var(--accent, #f28b3c);
    background: rgba(242,139,60,.08);
}
.wf-radio-thumb {
    width: 100%;
    max-height: 60px;
    object-fit: cover;
    border-radius: 4px;
}
.wf-radio-card strong { font-size: .78rem; }
.wf-radio-card small { font-size: .68rem; color: var(--muted, #888); }

/* Select dropdown */
.wf-select {
    padding: .35rem .6rem;
    background: var(--input-bg, #1a1a24);
    border: 1.5px solid var(--border, #333);
    border-radius: 6px;
    color: var(--text, #eee);
    font-size: .82rem;
    font-family: inherit;
}
.wf-select:focus { outline: none; border-color: var(--accent, #f28b3c); }

/* Color picker */
.wf-color-row { display: flex; align-items: center; gap: .5rem; }
.wf-color-input { width: 28px; height: 28px; border: none; border-radius: 4px; cursor: pointer; background: none; padding: 0; }
.wf-color-swatch { display: inline-block; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); }
.wf-color-hex { font-size: .72rem; font-family: monospace; }

/* Textarea */
.wf-textarea-wrap { position: relative; margin-top: .25rem; }
.wf-textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--input-bg, #1a1a24);
    border: 1.5px solid var(--border, #333);
    border-radius: 8px;
    color: var(--text, #eee);
    font-size: .92rem;
    line-height: 1.5;
    padding: .75rem .875rem 1.5rem;
    resize: vertical;
    transition: border-color .15s;
    font-family: inherit;
}
.wf-textarea:focus { outline: none; border-color: var(--accent, #f28b3c); }
.wf-char-count {
    position: absolute;
    bottom: .4rem; right: .6rem;
    font-size: 10px;
    color: var(--muted, #666);
    pointer-events: none;
}

/* Example chips */
.wf-examples { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.wf-examples-label { font-size: 10px; font-weight: 600; letter-spacing: .04em; }
.wf-example-chip {
    background: var(--input-bg, #1a1a24);
    border: 1px solid var(--border, #333);
    border-radius: 20px;
    color: var(--muted, #999);
    font-size: 11px;
    padding: .2rem .6rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    font-family: inherit;
}
.wf-example-chip:hover { border-color: var(--accent, #f28b3c); color: var(--text, #eee); }

/* Optional badge */
.badge-optional {
    background: var(--border, #333);
    color: var(--muted, #888);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: middle;
    margin-left: 4px;
}

/* ── GALLERY: wrapping thumbnail grid with user-adjustable size ───────── */
.wf-gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .35rem;
}
.wf-gallery-toolbar .panel-eyebrow { margin: 0; }
.wf-gallery-size-control {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.wf-gallery-size-icon {
    font-size: 10px;
    color: var(--muted, #666);
    line-height: 1;
}
.wf-gallery-size-icon--lg { font-size: 14px; }
.wf-gallery-size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 72px;
    height: 4px;
    background: var(--border, rgba(255,255,255,.15));
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.wf-gallery-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent, #f28b3c);
    cursor: pointer;
}
.wf-gallery-size-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent, #f28b3c);
    border: none;
    cursor: pointer;
}
.wf-gallery-strip {
    --gallery-thumb-size: 88px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}
.wf-gallery-item {
    flex-shrink: 0;
    width: var(--gallery-thumb-size);
    height: var(--gallery-thumb-size);
    padding: 2px;
    border: 2px solid var(--border, rgba(255,255,255,.12));
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .1s;
    color: var(--text, #ccc);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}
.wf-gallery-item:hover {
    border-color: rgba(255,255,255,.3);
    transform: scale(1.08);
}
.wf-gallery-item.is-selected {
    border-color: var(--accent, #f28b3c);
    box-shadow: 0 0 0 1px var(--accent, #f28b3c);
}
.wf-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}
.wf-gallery-hint {
    font-size: 11px;
    color: var(--muted, #666);
    margin-top: 4px;
}

/* Upload tile — last item in the gallery strip */
.wf-gallery-upload-tile {
    flex-shrink: 0;
    width: var(--gallery-thumb-size, 88px);
    height: var(--gallery-thumb-size, 88px);
    border: 2px dashed var(--border, rgba(255,255,255,.2));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    color: var(--muted, #666);
    font-size: 1.2rem;
    background: transparent;
}
.wf-gallery-upload-tile:hover {
    border-color: var(--accent, #f28b3c);
    color: var(--accent, #f28b3c);
    background: rgba(242,139,60,.04);
}

/* ── Gallery preview popover ─────────────────────────────────────────── */
.wf-gallery-popover-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 9000;
    display: none;
}
.wf-gallery-popover-backdrop.is-open { display: block; }

.wf-gallery-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9001;
    width: min(520px, 85vw);
    background: var(--card-bg, #1a1c2e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    display: none;
    overflow: hidden;
}
.wf-gallery-popover.is-open { display: block; }

.wf-popover-image {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    display: block;
    background: #0d0e18;
}
.wf-popover-body {
    padding: .5rem .75rem .65rem;
}
.wf-popover-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text, #eee);
    margin: 0 0 .5rem;
}
.wf-popover-actions {
    display: flex;
    gap: .5rem;
}
.wf-popover-use {
    flex: 1;
    padding: .45rem .75rem;
    background: var(--accent, #f28b3c);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s;
}
.wf-popover-use:hover { opacity: .85; }
.wf-popover-browse {
    flex: 1;
    padding: .45rem .75rem;
    background: transparent;
    color: var(--text, #ccc);
    border: 1.5px dashed var(--border, rgba(255,255,255,.2));
    border-radius: 6px;
    font-size: .82rem;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s, color .15s;
}
.wf-popover-browse:hover {
    border-color: var(--accent, #f28b3c);
    color: var(--accent, #f28b3c);
}
.wf-popover-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: .4rem;
}
.wf-popover-arrow {
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border, rgba(255,255,255,.12));
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text, #ccc);
    font-size: .9rem;
    transition: background .15s;
}
.wf-popover-arrow:hover { background: rgba(255,255,255,.15); }
.wf-popover-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.5);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.wf-popover-close:hover { background: rgba(0,0,0,.7); }

/* ── Generate toolbar — seed + button in one row ─────────────────────── */
.wf-generate-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border: 1.5px solid var(--border, rgba(255,255,255,.12));
    border-radius: 10px;
    background: rgba(255,255,255,.02);
}
.wf-seed-compact {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-shrink: 0;
}
.wf-seed-compact label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted, #999);
}
.wf-seed-compact input {
    width: 60px;
    padding: .3rem .5rem;
    background: var(--input-bg, #1a1a24);
    border: 1px solid var(--border, #333);
    border-radius: 5px;
    color: var(--text, #eee);
    font-size: .82rem;
    font-family: inherit;
}
.wf-generate-info {
    flex: 1;
    min-width: 0;
}
.wf-generate-info h3 {
    font-size: .9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wf-generate-info p {
    font-size: .72rem;
    color: var(--muted, #888);
    margin: 2px 0 0;
}
.wf-generate-btn {
    flex-shrink: 0;
    padding: .5rem 1.25rem;
    background: var(--accent, #f28b3c);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s;
}
.wf-generate-btn:hover { opacity: .85; }
.wf-generate-btn:disabled { opacity: .4; cursor: not-allowed; }
.wf-generate-link {
    font-size: .78rem;
    color: var(--accent, #f28b3c);
    text-decoration: none;
}
.wf-generate-link:hover { text-decoration: underline; }

/* ── INSPIRATION SIDEBAR — right-side preview of what this workflow creates ── */
.wf-inspiration-sidebar {
    position: absolute;
    top: 50px;
    left: calc(50% + 370px);
    width: 220px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
}
.wf-inspiration-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted, #555);
    margin: 0 0 .5rem;
}
.wf-inspiration-strip {
    display: flex;
    gap: 8px;
    padding: 2px 0;
}
.wf-inspiration-item {
    flex-shrink: 0;
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    opacity: .75;
    transition: opacity .2s;
    cursor: default;
}
.wf-inspiration-item:hover { opacity: 1; }
.wf-inspiration-item img,
.wf-inspiration-item video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: 6px;
}
.wf-inspiration-hint {
    font-size: 10px;
    color: rgba(255,255,255,.35);
    margin-top: 8px;
    line-height: 1.4;
}
@media (max-width: 1100px) {
    .wf-inspiration-sidebar { display: none; }
}

/* Conditional visibility (JS-driven) */
.wf-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile — phone breakpoint
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    .wf-flow {
        max-width: 100%;
        padding: .75rem;
        box-sizing: border-box;
    }

    .wf-options-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: .5rem .75rem;
    }
    .wf-toolbar-divider { display: none; }
    .wf-option-group { width: 100%; }

    .wf-generate-bar {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
        padding: .75rem;
    }
    .wf-generate-btn { width: 100%; }
    .wf-seed-compact { order: 1; }
    .wf-generate-info { order: 0; }

    .wf-gallery-strip { --gallery-thumb-size: 68px; }
    .wf-gallery-popover { width: min(360px, 92vw); }

    .wf-dropzone { padding: 20px 12px; }
    .wf-video-dropzone { min-height: 160px; }

    .wf-radio-grid { gap: .25rem; }
    .wf-radio-card { padding: .3rem .5rem; font-size: .72rem; }

    .wf-textarea { font-size: .85rem; padding: .6rem .75rem 1.2rem; }

    .wf-recipe-strip { gap: .35rem; }
    .wf-recipe-thumb { width: 44px; height: 44px; }
    .wf-recipe-plus { line-height: 44px; }

    .wf-thumb-card { width: 64px; height: 64px; }
}
