/* ═══════════════════════════════════════════════════════════════
   2-PANEL LAYOUT v2 CSS
   Two variants:
     .wf-2panel--simple   = Settings LEFT, big upload(s) in CENTER
     .wf-2panel--preview  = Compact upload LEFT, preview grid CENTER

   Desktop (>720px):
     - simple : ~32% left | ~68% center
     - preview: ~30% left | ~70% center  (same as v1)

   Mobile (≤720px): Single column, settings stack below uploads.
   ═══════════════════════════════════════════════════════════════ */

/* ── Container ──────────────────────────────────────────────────── */
.wf-2panel {
    display: flex;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 180px);
}

/* ── Left Column (Settings) ─────────────────────────────────────── */
.wf-2panel-left {
    flex: 0 0 30%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wf-2panel--simple .wf-2panel-left {
    flex: 0 0 32%;
    max-width: 440px;
}

.wf-2panel-section-header {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,.85);
    letter-spacing: 0.02em;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-family: var(--font-sans);
}

.wf-2panel-options {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.wf-2panel-actions {
    margin-top: auto;
    padding-top: 16px;
}

/* ── Compact upload zone in left column (preview variant) ───────── */
.wf-2panel-upload-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Center Column (Workspace) ──────────────────────────────────── */
.wf-2panel-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* Empty/preview state container (preview variant) */
.wf-2panel-preview-area {
    flex: 1;
    background: rgba(255,255,255,.02);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;   /* stack empty-state + pose-grid vertically */
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

/* When the pose grid lives in the right panel, remove the centering/padding
   so the grid fills top-to-bottom and is scrollable from the very first card. */
.wf-2panel-preview-area:has(.wf-pose-fallback-list),
.wf-2panel-preview-area:has(.wf-pose-grid:not([style*="none"])) {
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
}

/* ── Workspace intro caption (per-tool empty-state copy) ────────── */
.wf-2panel-workspace-intro {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px 6px;
    margin: 0;
}

.wf-2panel-workspace-intro .wf-workspace-intro-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,.85);
    line-height: 1.4;
}

.wf-2panel-workspace-intro .wf-workspace-intro-hint {
    margin: 0;
    font-size: 12.5px;
    color: rgba(255,255,255,.5);
    line-height: 1.5;
    max-width: 720px;
}

/* Hide the intro caption once any upload zone in this workspace has a preview.
   Uses :has() for modern browsers; older browsers will simply keep the caption visible. */
.wf-2panel-center:has(.has-preview) .wf-2panel-workspace-intro {
    display: none;
}

/* ── Workspace upload(s) container (simple variant) ─────────────── */
.wf-2panel-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.wf-2panel-workspace--uploads {
    display: grid;
    gap: 16px;
    align-items: stretch;
}

/* 1 input → single big drop zone fills the workspace */
.wf-2panel-workspace--count-1 {
    grid-template-columns: 1fr;
}

/* 2 inputs → side-by-side (e.g. Swap: source + destination) */
.wf-2panel-workspace--count-2 {
    grid-template-columns: 1fr 1fr;
}

/* 3+ inputs → fluid grid */
.wf-2panel-workspace--count-3,
.wf-2panel-workspace--count-4,
.wf-2panel-workspace--count-5 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Make the image_input_panel fill its grid cell nicely.
   The panel has class .panel/.image-panel and contains .paste-box/[data-image-panel]. */
.wf-2panel-workspace .panel,
.wf-2panel-workspace .image-panel {
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wf-2panel-workspace [data-image-panel] {
    flex: 1;
    min-height: 360px;
    display: flex;
    flex-direction: column;
}

/* Single-input simple variant: make the drop zone really big */
.wf-2panel-workspace--count-1 [data-image-panel] {
    min-height: 480px;
}

/* Allow uploaded preview image to use the bigger workspace area */
.wf-2panel-workspace .preview-image {
    max-width: 100%;
    max-height: min(70vh, 640px);
    width: auto;
    height: auto;
}

.wf-2panel-workspace .canvas-wrap {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Centre the desktop dropzone content vertically in the bigger panel */
.wf-2panel-workspace .wf-dz-idle.desktop-dropzone {
    margin: auto;
    text-align: center;
    padding: 28px 18px;
}

/* ── Preview-variant: compact upload panel size ─────────────────── */
.wf-2panel-upload-compact [data-image-panel] {
    min-height: 220px;
}

.wf-2panel-upload-compact .preview-image {
    max-height: 240px;
}

/* ── Universe-Pose Preview Widget ───────────────────────────────── */
.wf-universe-pose-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Toggle Switch Widget ───────────────────────────────────────── */
.wf-toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.wf-toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wf-toggle-slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,.15);
    border-radius: 24px;
    transition: background .2s;
    flex-shrink: 0;
}

.wf-toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
}

.wf-toggle-switch input:checked + .wf-toggle-slider {
    background: #a78bfa;
}

.wf-toggle-switch input:checked + .wf-toggle-slider::before {
    transform: translateX(20px);
}

.wf-toggle-switch:hover .wf-toggle-slider {
    background: rgba(255,255,255,.22);
}

.wf-toggle-switch input:checked:hover + .wf-toggle-slider {
    background: #b794ff;
}

.wf-toggle-label {
    font-size: 13px;
    color: rgba(255,255,255,.7);
    line-height: 1.4;
}

.wf-toggle-switch input:checked ~ .wf-toggle-label {
    color: rgba(255,255,255,.95);
}

/* ── Preview trigger buttons ────────────────────────────────────── */
.wf-up-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(242,139,60,.85), rgba(242,139,60,.75));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(242,139,60,.25);
}

.wf-up-preview-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(242,139,60,.35);
}

.wf-up-preview-btn:active:not(:disabled) {
    transform: translateY(0);
}

.wf-up-preview-btn:disabled {
    opacity: .4;
    cursor: default;
    transform: none;
}

.wf-up-preview-btn svg {
    flex-shrink: 0;
}

/* ── Status hint line ───────────────────────────────────────────── */
.wf-up-preview-status {
    font-size: 11px;
    color: rgba(255,255,255,.45);
    display: block;
    line-height: 1.4;
    margin-top: -4px;
}

/* ── Loading dots animation ─────────────────────────────────────── */
.wf-loading-dots::after {
    content: '...';
    display: inline-block;
    animation: wf-dots-pulse 1.4s infinite;
}

@keyframes wf-dots-pulse {
    0%, 20%  { content: '.'; }
    40%      { content: '..'; }
    60%, 100%{ content: '...'; }
}

/* ── Preview grid (universe / era widgets) ──────────────────────── */
.wf-up-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
    max-width: 1000px;
}

.wf-up-grid-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.03);
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .2s;
    overflow: hidden;
}

.wf-up-grid-cell:hover {
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.28);
    transform: translateY(-2px);
}

.wf-up-grid-cell.is-active {
    border-color: #a78bfa;
    background: rgba(167,139,250,.15);
    box-shadow: 0 0 0 1px #a78bfa inset, 0 4px 16px rgba(167,139,250,.3);
}

.wf-up-grid-cell img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.wf-up-grid-cell-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,.65);
    line-height: 1.3;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.wf-up-grid-cell.is-active .wf-up-grid-cell-label {
    color: #c4b5fd;
    font-weight: 600;
}

/* ── Skeleton cells (loading state) ─────────────────────────────── */
.wf-up-grid-cell--skeleton {
    aspect-ratio: 3/4;
    cursor: default;
    border-color: rgba(255,255,255,.08);
    background: linear-gradient(90deg,
        rgba(255,255,255,.04) 0%,
        rgba(255,255,255,.08) 50%,
        rgba(255,255,255,.04) 100%);
    background-size: 200% 100%;
    animation: wf-up-skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes wf-up-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Empty state ────────────────────────────────────────────────── */
.wf-up-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    color: rgba(255,255,255,.55);
    padding: 60px 40px;
}

.wf-up-empty-state svg {
    opacity: .55;
}

.wf-up-empty-state p {
    margin: 0;
    line-height: 1.5;
    max-width: 420px;
}

.wf-up-empty-state .wf-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: rgba(255,255,255,.85);
}

.wf-up-empty-state .wf-empty-hint {
    font-size: 13px;
    color: rgba(255,255,255,.45);
}

/* ── Fallback text list (shown before preview) ──────────────────── */
.wf-up-fallback-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wf-up-fallback-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 6px;
    color: rgba(255,255,255,.7);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}

.wf-up-fallback-item:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.24);
    color: rgba(255,255,255,.95);
}

.wf-up-fallback-item.is-active {
    border-color: #a78bfa;
    background: rgba(167,139,250,.12);
    color: #c4b5fd;
}

/* ─────────────────────────────────────────────────────────────────
   MOBILE STYLES (≤720px)
   ───────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .wf-2panel {
        flex-direction: column;
        padding: 12px;
        gap: 16px;
    }

    .wf-2panel-left {
        flex: none;
        max-width: none;
        width: 100%;
    }

    .wf-2panel--simple .wf-2panel-left {
        max-width: none;
    }

    .wf-2panel-center {
        width: 100%;
    }

    /* On mobile, simple variant: workspace (uploads) goes ABOVE settings. */
    .wf-2panel--simple {
        flex-direction: column-reverse;
    }

    .wf-2panel-preview-area {
        min-height: 320px;
        padding: 16px;
    }

    .wf-2panel-workspace {
        min-height: 0;
    }

    .wf-2panel-workspace [data-image-panel] {
        min-height: 280px;
    }

    .wf-2panel-workspace--count-1 [data-image-panel] {
        min-height: 320px;
    }

    /* Always single column on mobile, regardless of input count */
    .wf-2panel-workspace--uploads {
        grid-template-columns: 1fr !important;
    }

    .wf-up-preview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .wf-up-grid-cell {
        padding: 6px;
    }

    .wf-up-grid-cell-label {
        font-size: 10px;
    }

    .wf-up-empty-state {
        padding: 40px 20px;
    }

    .wf-up-empty-state .wf-empty-title {
        font-size: 14px;
    }

    .wf-up-empty-state .wf-empty-hint {
        font-size: 12px;
    }

    .wf-up-preview-btn {
        width: 100%;
        justify-content: center;
    }

    .wf-2panel-options {
        gap: 12px;
    }
}

/* ─────────────────────────────────────────────────────────────────
   TABLET STYLES (721px - 1024px)
   ───────────────────────────────────────────────────────────────── */
@media (min-width: 721px) and (max-width: 1024px) {
    .wf-2panel {
        gap: 16px;
        padding: 16px;
    }

    .wf-2panel-left {
        flex: 0 0 35%;
        max-width: 360px;
    }

    .wf-2panel--simple .wf-2panel-left {
        flex: 0 0 38%;
        max-width: 380px;
    }

    .wf-up-preview-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    /* On narrower screens, stack 2-input workspaces vertically */
    .wf-2panel-workspace--count-2 {
        grid-template-columns: 1fr;
    }
}

/* ─────────────────────────────────────────────────────────────────
   LARGE DESKTOP (>1400px)
   ───────────────────────────────────────────────────────────────── */
@media (min-width: 1400px) {
    .wf-up-preview-grid {
        gap: 20px;
    }

    .wf-up-grid-cell {
        padding: 10px;
    }

    .wf-2panel-preview-area {
        min-height: 600px;
    }

    .wf-2panel-workspace {
        min-height: 600px;
    }

    .wf-2panel-workspace--count-1 [data-image-panel] {
        min-height: 560px;
    }
}
