/* ============================================================
   VISUAL FLOW — page-specific styles
   Self-contained, theme-aware (light default + dark override).
   ============================================================ */

.vf-app {
    /* Light theme tokens */
    --vf-bg: #f5f6f8;
    --vf-surface: #ffffff;
    --vf-surface-2: #f0f2f5;
    --vf-border: #e2e5ea;
    --vf-border-strong: #cfd4dc;
    --vf-text: #1c2430;
    --vf-text-soft: #59616e;
    --vf-text-muted: #8a92a0;
    --vf-accent: #4f6bed;
    --vf-accent-dark: #3a53c9;
    --vf-accent-soft: rgba(79, 107, 237, 0.10);
    --vf-danger: #d9534f;
    --vf-radius: 14px;
    --vf-radius-sm: 9px;
    --vf-shadow: 0 1px 3px rgba(20, 28, 44, 0.06), 0 6px 20px rgba(20, 28, 44, 0.05);

    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 20px 80px;
    color: var(--vf-text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

body.theme-dark .vf-app,
html.theme-dark .vf-app {
    --vf-bg: #12151b;
    --vf-surface: #1b1f27;
    --vf-surface-2: #232833;
    --vf-border: #2c323d;
    --vf-border-strong: #3a4150;
    --vf-text: #e8ebf0;
    --vf-text-soft: #aab2c0;
    --vf-text-muted: #79828f;
    --vf-accent: #6f89f5;
    --vf-accent-dark: #536ee0;
    --vf-accent-soft: rgba(111, 137, 245, 0.14);
    --vf-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ── Intro ── */
.vf-intro { text-align: center; margin-bottom: 22px; }
.vf-title { font-size: 30px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; }
.vf-tagline { font-size: 15px; color: var(--vf-text-soft); margin: 0; }

/* ── Stage toggling ── */
.vf-stage { display: none; }
.vf-stage.active { display: block; animation: vfFade 0.25s ease; }
@keyframes vfFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Cards ── */
.vf-card {
    background: var(--vf-surface);
    border: 1px solid var(--vf-border);
    border-radius: var(--vf-radius);
    box-shadow: var(--vf-shadow);
    padding: 22px;
}
.vf-card-heading { font-size: 19px; font-weight: 700; margin: 0 0 6px; }
.vf-card-sub { font-size: 14px; color: var(--vf-text-soft); margin: 0 0 18px; line-height: 1.5; }
.vf-card-eyebrow {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--vf-text-muted); margin-bottom: 12px;
}

/* ── Dropzone ── */
.vf-dropzone {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 34px 20px; text-align: center; cursor: pointer;
    border: 2px dashed var(--vf-border-strong); border-radius: var(--vf-radius);
    background: var(--vf-surface-2); color: var(--vf-text-soft);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.vf-dropzone:hover, .vf-dropzone:focus-visible, .vf-dropzone.dragover {
    border-color: var(--vf-accent); background: var(--vf-accent-soft); color: var(--vf-accent-dark);
    outline: none;
}
.vf-dropzone-icon { color: var(--vf-accent); }
.vf-dropzone-primary { font-size: 15px; font-weight: 600; }
.vf-dropzone-hint { font-size: 12.5px; color: var(--vf-text-muted); }

/* ── Selected file chip ── */
.vf-file-chip {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    padding: 10px 14px; border-radius: var(--vf-radius-sm);
    background: var(--vf-surface-2); border: 1px solid var(--vf-border); color: var(--vf-text);
}
.vf-file-chip svg { color: var(--vf-accent); flex-shrink: 0; }
.vf-file-chip-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-file-chip-size { font-size: 12.5px; color: var(--vf-text-muted); margin-left: auto; white-space: nowrap; }
.vf-file-chip-remove {
    border: none; background: none; color: var(--vf-danger); font-size: 13px; font-weight: 600;
    cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.vf-file-chip-remove:hover { background: color-mix(in srgb, var(--vf-danger) 12%, transparent); }

/* ── Options ── */
.vf-options { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.vf-option { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.vf-option-label { font-size: 13px; font-weight: 600; color: var(--vf-text-soft); min-width: 100px; }

.vf-seg { display: inline-flex; border: 1px solid var(--vf-border-strong); border-radius: 999px; overflow: hidden; }
.vf-seg-btn {
    border: none; background: var(--vf-surface); color: var(--vf-text-soft);
    padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.vf-seg-btn + .vf-seg-btn { border-left: 1px solid var(--vf-border); }
.vf-seg-btn.active { background: var(--vf-accent); color: #fff; }

.vf-select {
    border: 1px solid var(--vf-border-strong); border-radius: var(--vf-radius-sm);
    background: var(--vf-surface); color: var(--vf-text);
    padding: 7px 12px; font-size: 13px; font-family: inherit; cursor: pointer;
}

.vf-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--vf-text); cursor: pointer; }
.vf-check input { width: 16px; height: 16px; accent-color: var(--vf-accent); cursor: pointer; }

/* ── Buttons ── */
.vf-actions { margin-top: 22px; display: flex; justify-content: flex-end; }
.vf-btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    border: 1px solid transparent; border-radius: var(--vf-radius-sm);
    padding: 9px 18px; font-size: 14px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.vf-btn-primary { background: var(--vf-accent); color: #fff; }
.vf-btn-primary:hover:not(:disabled) { background: var(--vf-accent-dark); }
.vf-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.vf-btn-ghost { background: transparent; color: var(--vf-text-soft); border-color: var(--vf-border-strong); }
.vf-btn-ghost:hover { background: var(--vf-surface-2); color: var(--vf-text); }
.vf-btn-lg { padding: 12px 26px; font-size: 15px; }

/* ── Loading ── */
.vf-loading { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--vf-text-soft); font-size: 14px; }
.vf-spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2.5px solid var(--vf-border-strong); border-top-color: var(--vf-accent);
    animation: vfSpin 0.7s linear infinite;
}
@keyframes vfSpin { to { transform: rotate(360deg); } }

/* ── Outline head ── */
.vf-outline-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.vf-truncated-note {
    background: color-mix(in srgb, #e8a13a 16%, var(--vf-surface));
    border: 1px solid color-mix(in srgb, #e8a13a 40%, var(--vf-border));
    color: var(--vf-text); border-radius: var(--vf-radius-sm);
    padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}

/* ── Settings row (theme + footer) ── */
.vf-settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 720px) { .vf-settings-row { grid-template-columns: 1fr; } }

.vf-theme-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; min-height: 30px; }
.vf-swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12); position: relative; }
.vf-swatch-empty { color: var(--vf-text-muted); font-size: 12.5px; align-self: center; }
.vf-theme-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.vf-theme-style-label { color: var(--vf-text-muted); font-weight: 600; }
.vf-theme-style-value { color: var(--vf-text); font-weight: 600; text-transform: capitalize; }
.vf-theme-summary { font-size: 12.5px; color: var(--vf-text-soft); margin: 10px 0 0; line-height: 1.45; }

/* ── Fields ── */
.vf-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.vf-field > span { font-size: 12.5px; font-weight: 600; color: var(--vf-text-soft); }
.vf-field input, .vf-field textarea {
    border: 1px solid var(--vf-border-strong); border-radius: var(--vf-radius-sm);
    background: var(--vf-surface); color: var(--vf-text);
    padding: 8px 11px; font-size: 13.5px; font-family: inherit; width: 100%; box-sizing: border-box;
}
.vf-field input:focus, .vf-field textarea:focus { outline: none; border-color: var(--vf-accent); box-shadow: 0 0 0 3px var(--vf-accent-soft); }
.vf-field textarea { resize: none; overflow: hidden; min-height: 62px; line-height: 1.5; }
.vf-footer-card .vf-check { margin-top: 6px; }
.vf-flow-title-field { max-width: 520px; }

/* ── Art direction ── */
.vf-art-field { margin-bottom: 12px; }
.vf-art-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.vf-art-label { font-size: 12.5px; font-weight: 600; color: var(--vf-text-soft); }
.vf-art-textarea {
    width: 100%; box-sizing: border-box; border: 1px solid var(--vf-border-strong);
    border-radius: var(--vf-radius-sm); background: var(--vf-surface); color: var(--vf-text);
    padding: 8px 11px; font-size: 13.5px; font-family: inherit; resize: vertical; min-height: 48px; line-height: 1.45;
}
.vf-art-textarea:focus { outline: none; border-color: var(--vf-accent); box-shadow: 0 0 0 3px var(--vf-accent-soft); }
.vf-art-hint { display: block; font-size: 11.5px; color: var(--vf-text-muted); margin-top: 4px; }
.vf-art-detected summary {
    font-size: 11.5px; font-weight: 600; color: var(--vf-accent-dark); cursor: pointer; list-style: none;
}
.vf-art-detected summary::-webkit-details-marker { display: none; }
.vf-art-detected summary::before { content: "▸ "; }
.vf-art-detected[open] summary::before { content: "▾ "; }
.vf-art-detected-text {
    font-size: 12px; color: var(--vf-text-soft); line-height: 1.5; margin: 8px 0 0;
    padding: 10px 12px; background: var(--vf-surface-2); border: 1px solid var(--vf-border); border-radius: var(--vf-radius-sm);
    max-height: 200px; overflow: auto; white-space: pre-wrap;
}

/* ── Sections ── */
.vf-sections-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 12px; }
.vf-sections-label { font-size: 15px; font-weight: 700; }
.vf-sections-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
    padding: 0 6px; border-radius: 999px; background: var(--vf-accent-soft); color: var(--vf-accent-dark);
    font-size: 12px; font-weight: 700; margin-left: 4px;
}
.vf-add-btn { padding: 7px 14px; }

.vf-section-list { display: flex; flex-direction: column; gap: 12px; }

.vf-section-card {
    background: var(--vf-surface); border: 1px solid var(--vf-border); border-radius: var(--vf-radius);
    box-shadow: var(--vf-shadow); padding: 14px 16px 16px;
    display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start;
}
.vf-section-card.dragging { opacity: 0.5; }
.vf-section-card.drag-over { border-color: var(--vf-accent); box-shadow: 0 0 0 2px var(--vf-accent-soft); }

.vf-section-rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 2px; }
.vf-section-num {
    width: 26px; height: 26px; border-radius: 50%; background: var(--vf-accent-soft); color: var(--vf-accent-dark);
    font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.vf-drag-handle {
    cursor: grab; color: var(--vf-text-muted); background: none; border: none; padding: 2px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
}
.vf-drag-handle:hover { color: var(--vf-text); background: var(--vf-surface-2); }
.vf-drag-handle:active { cursor: grabbing; }
.vf-move-btn { border: none; background: none; color: var(--vf-text-muted); cursor: pointer; padding: 1px; line-height: 0; border-radius: 4px; }
.vf-move-btn:hover:not(:disabled) { color: var(--vf-accent); }
.vf-move-btn:disabled { opacity: 0.3; cursor: default; }

.vf-section-body { min-width: 0; }
.vf-section-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.vf-section-title-row input { flex: 1; font-weight: 600; }
.vf-section-delete {
    border: none; background: none; color: var(--vf-text-muted); cursor: pointer; padding: 4px; border-radius: 6px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.vf-section-delete:hover { color: var(--vf-danger); background: color-mix(in srgb, var(--vf-danger) 12%, transparent); }
.vf-section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
@media (max-width: 620px) { .vf-section-grid { grid-template-columns: 1fr; } }
.vf-section-footer-field { margin-top: 10px; margin-bottom: 0; }

/* ── Outline footer ── */
.vf-outline-footer { margin-top: 24px; display: flex; justify-content: flex-end; }

/* ── Result stage (generation) ── */
.vf-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.vf-progress-track {
    flex: 1; height: 8px; border-radius: 999px; background: var(--vf-surface-2);
    border: 1px solid var(--vf-border); overflow: hidden;
}
.vf-progress-fill {
    height: 100%; width: 0%; border-radius: 999px;
    background: var(--vf-accent); transition: width 0.4s ease;
}
.vf-progress-label { font-size: 13px; font-weight: 600; color: var(--vf-text-soft); white-space: nowrap; min-width: 60px; text-align: right; }

.vf-panel-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.vf-panel-card {
    background: var(--vf-surface); border: 1px solid var(--vf-border); border-radius: var(--vf-radius);
    box-shadow: var(--vf-shadow); overflow: hidden; position: relative;
    animation: vfFade 0.3s ease;
}
.vf-panel-card img { display: block; width: 100%; height: auto; }
.vf-panel-index {
    position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%;
    background: rgba(20, 28, 44, 0.72); color: #fff; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; z-index: 2;
}
.vf-panel-card.dragging { opacity: 0.45; }
.vf-panel-card.drag-over { outline: 2px solid var(--vf-accent); outline-offset: -2px; }

/* Per-panel hover toolbar (management, post-generation) */
.vf-panel-toolbar {
    position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; z-index: 2;
    opacity: 0; transition: opacity 0.15s;
}
.vf-panel-card:hover .vf-panel-toolbar, .vf-panel-card:focus-within .vf-panel-toolbar { opacity: 1; }
.vf-panel-tool {
    width: 28px; height: 28px; border: none; border-radius: 7px; cursor: pointer;
    background: rgba(20, 28, 44, 0.72); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.vf-panel-tool:hover { background: rgba(20, 28, 44, 0.92); }
.vf-panel-tool.vf-panel-tool-danger:hover { background: var(--vf-danger); }
.vf-panel-tool.vf-panel-drag { cursor: grab; }
.vf-panel-tool.vf-panel-drag:active { cursor: grabbing; }

/* Management bar */
.vf-result-manage {
    margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.vf-result-manage-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.vf-share-linkrow { margin-top: 12px; display: flex; gap: 8px; }
.vf-share-linkrow input {
    flex: 1; border: 1px solid var(--vf-border-strong); border-radius: var(--vf-radius-sm);
    background: var(--vf-surface-2); color: var(--vf-text); padding: 8px 11px; font-size: 13px;
}

/* ── Modal (regenerate / add panel) ── */
.vf-modal-overlay {
    position: fixed; inset: 0; background: rgba(10, 14, 22, 0.55); z-index: 2500;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.vf-modal {
    background: var(--vf-surface); border: 1px solid var(--vf-border); border-radius: var(--vf-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35); width: min(520px, 96vw); max-height: 92vh; overflow: auto;
    position: relative;
}
.vf-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--vf-border);
}
.vf-modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--vf-text); }
.vf-modal-close { border: none; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--vf-text-muted); }
.vf-modal-close:hover { color: var(--vf-text); }
.vf-modal-body { padding: 18px 20px; }
.vf-modal-body .vf-seg { margin-bottom: 12px; }
.vf-modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--vf-border); }
.vf-modal-loading {
    position: absolute; inset: 0; background: color-mix(in srgb, var(--vf-surface) 82%, transparent);
    display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--vf-text-soft);
    font-size: 14px; border-radius: var(--vf-radius);
}
/* Field-group visibility driven by a mode class on the modal */
.vf-modal-regen-only { display: none; }
.vf-modal.vf-modal-mode-regen .vf-modal-regen-only { display: block; }
.vf-modal.vf-modal-mode-regen .vf-modal-add-only { display: none; }
.vf-modal.vf-modal-mode-add .vf-modal-add-only { display: flex; }
.vf-modal.vf-modal-mode-add .vf-modal-regen-only { display: none; }

/* Expand / maximise button (always visible, bottom-right of a panel) */
.vf-panel-expand {
    position: absolute; bottom: 8px; right: 8px; width: 30px; height: 30px; z-index: 2;
    border: none; border-radius: 8px; cursor: pointer;
    background: rgba(20, 28, 44, 0.6); color: #fff;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.85; transition: opacity 0.15s, background 0.15s;
}
.vf-panel-expand:hover { opacity: 1; background: rgba(20, 28, 44, 0.92); }

/* Lightbox */
.vf-lightbox {
    position: fixed; inset: 0; z-index: 3100; background: rgba(8, 10, 16, 0.9);
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.vf-lightbox img {
    max-width: 94vw; max-height: 92vh; border-radius: 10px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5); background: #fff;
}
.vf-lightbox-close {
    position: absolute; top: 18px; right: 22px; width: 42px; height: 42px; border: none; border-radius: 50%;
    background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.vf-lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }

/* Read-only shared view */
body.vf-shared .vf-result-manage,
body.vf-shared #vfResultBackBtn,
body.vf-shared .vf-progress { display: none !important; }

/* ── Toasts ── */
.vf-toast-container {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px; z-index: 3000; pointer-events: none;
}
.vf-toast {
    background: #1c2430; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25); opacity: 1; transition: opacity 0.3s, transform 0.3s;
    max-width: 90vw;
}
.vf-toast.out { opacity: 0; transform: translateY(8px); }

/* Utility */
.hidden { display: none !important; }
