/* V2 form designer (Pages/FormEditorV2.razor): full-height, resizable panes,
   stretchable columns and pointer-driven column drag (js/form-editor-v2.js). */

.fev2 {
    --fev2-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fev2__topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--rz-base-300);
    border-radius: var(--rz-border-radius, 4px);
    background: var(--rz-base-background-color, #fff);
}

.fev2__title {
    flex: 1 1 200px;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fev2__sep {
    width: 1px;
    align-self: stretch;
    background: var(--rz-base-300);
}

.fev2__splitter {
    height: var(--fev2-height);
    min-height: 420px;
    border: 1px solid var(--rz-base-300);
    border-radius: var(--rz-border-radius, 4px);
}

/* Panes must be allowed to shrink below their content width, or a wide form pushes the
   right pane out of view. */
.fev2__splitter > .rz-splitter-pane {
    min-width: 0;
    overflow: hidden;
}

.fev2 {
    min-width: 0;
    max-width: 100%;
}

.fev2__pane {
    height: 100%;
    overflow: auto;
    background: var(--rz-base-background-color, #fff);
}

/* The shared Outline/Toolbox components are sticky side panels in the classic editor.
   Inside a splitter pane they simply fill the pane. */
.fev2 .form-outline-wrap,
.fev2 .form-toolbox {
    position: static;
    max-height: none;
}

.fev2 .form-outline-wrap {
    height: 100%;
}

.fev2 .form-outline {
    width: 100%;
    border: none;
}

.fev2 .form-toolbox {
    border: none;
    flex: 1 1 auto;
}

/* Canvas: gray workspace with a centered, horizontally resizable "page". */
.fev2__canvas {
    height: 100%;
    overflow: auto;
    background: var(--rz-base-200);
    padding: 1.5rem 1rem 3rem;
}

.fev2__page {
    margin: 0 auto;
    min-width: 320px;
    max-width: 100%;
    resize: horizontal;
    overflow: auto;
    background: var(--rz-base-background-color, #fff);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.06);
    padding: 1rem 1.25rem 2rem;
}

.fev2__width-label {
    text-align: center;
    font-size: 0.72rem;
    color: var(--rz-text-tertiary-color);
    margin-bottom: 0.4rem;
}

/* Right-edge column resize handle. */
.fev2-col-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -4px;
    width: 8px;
    cursor: col-resize;
    z-index: 6;
}

.fev2-col-resize::after {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    left: 3px;
    width: 2px;
    border-radius: 1px;
    background: var(--rz-primary);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.dynamic-form__column:hover > .fev2-col-resize::after,
.dynamic-form__column.fd-outline-selected > .fev2-col-resize::after,
.fev2-resizing > .fev2-col-resize::after {
    opacity: 1;
}

.fev2-resizing {
    outline: 2px dashed var(--rz-primary);
    outline-offset: 1px;
}

.fev2-size-badge {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--rz-primary);
    color: var(--rz-on-primary, #fff);
    font-size: 0.75rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 20;
}

/* Column drag */
.fev2-col-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    border-radius: 4px;
    background: var(--rz-base-200);
    cursor: grab;
    touch-action: none;
}

.fev2-dragging {
    opacity: 0.45;
}

.fev2-drop-before {
    box-shadow: inset 4px 0 0 var(--rz-success);
}

.fev2-drop-after {
    box-shadow: inset -4px 0 0 var(--rz-success);
}

.fev2-drag-ghost {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    background: var(--rz-primary);
    color: var(--rz-on-primary, #fff);
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.fev2-busy,
body.fev2-busy * {
    user-select: none;
    cursor: grabbing !important;
}

/* Selection panel */
.fev2__props {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fev2__props-kind {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rz-text-tertiary-color);
}

.fev2__props-name {
    font-weight: 600;
    word-break: break-word;
}

.fev2__props-meta {
    font-size: 0.8rem;
    color: var(--rz-text-secondary-color);
}

.fev2__props-empty {
    font-size: 0.85rem;
    color: var(--rz-text-tertiary-color);
}

/* ---------- Row layout (FormLayoutMode.Rows) in the V2 designer ----------
   A 12-column grid laid out by the .NET RowLayoutEngine for the screen size being edited.
   Cards are .fd-ri; js/form-editor-v2.js (attachRows) drives move/resize. */
.fd-rows {
    --fd-gap: 12px;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--fd-gap);
    row-gap: var(--fd-gap);
    align-items: flex-start;
    min-height: 56px;
    padding: 2px 0;
}

/* Row break before an item that starts a new row (the gap it adds is taken back). */
.fd-rows__brk { flex-basis: 100%; height: 0; margin-top: calc(-1 * var(--fd-gap)); }
/* Fit content: give inputs a sensible natural width (checkboxes stay as small as their label). */
.fd-ri--fit .rz-textbox, .fd-ri--fit .rz-dropdown, .fd-ri--fit .rz-numeric, .fd-ri--fit .rz-datepicker { min-width: 170px; }
.fd-rows__preview-item { min-width: 0; }

.fd-rows__guides {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--fd-gap);
    pointer-events: none;
    z-index: 0;
    opacity: .35;
    transition: opacity .15s ease;
}

.fd-rows__guides i { background: var(--rz-base-200); border-radius: 6px; }
body.fev2-busy .fd-rows__guides { opacity: 1; }
.fd-rows .fd-rows .fd-rows__guides { opacity: .25; }
body.fev2-busy .fd-rows .fd-rows .fd-rows__guides { opacity: .7; }
.fd-rows--dropping { outline: 2px dashed var(--rz-primary); outline-offset: 4px; border-radius: 6px; }

.fd-rows__empty {
    flex: 1 1 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px dashed var(--rz-base-400);
    border-radius: 8px;
    color: var(--rz-text-secondary-color);
    font-size: 0.8rem;
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.fd-rows__hint {
    position: absolute;
    z-index: 0;
    pointer-events: none;
    min-height: 40px;
    border: 2px dashed var(--rz-primary);
    border-radius: 8px;
    background: rgba(var(--rz-primary-rgb, 25, 118, 210), 0.08);
}

.fd-ri {
    position: relative;
    z-index: 1;
    min-width: 0;
    border: 1px solid var(--rz-base-300);
    border-radius: 8px;
    background: var(--rz-base-background-color, #fff);
    padding: 6px 8px 8px;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.fd-ri--field { cursor: grab; touch-action: none; }
.fd-ri--field > .fd-ri__body { pointer-events: none; } /* design mode: no typing into inputs */
.fd-ri:hover { border-color: var(--rz-base-500); }
.fd-ri--sel { border-color: var(--rz-primary) !important; box-shadow: 0 0 0 3px rgba(var(--rz-primary-rgb, 25, 118, 210), 0.18); z-index: 3; }
.fd-ri--dragsrc { opacity: .4; }
.fd-ri--group { background: var(--rz-base-50, #f8f9fb); padding: 0 8px 8px; }

.fd-ri__grip {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 -8px 6px;
    padding: 3px 8px;
    font-size: 0.72rem;
    color: var(--rz-text-secondary-color);
    background: var(--rz-base-100);
    border-bottom: 1px solid var(--rz-base-300);
    border-radius: 8px 8px 0 0;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.fd-ri__grip .rzi { font-size: 16px; }

.fd-ri__badge {
    position: absolute;
    top: 4px;
    right: 6px;
    z-index: 2;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 10.5px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rz-base-200);
    color: var(--rz-text-secondary-color);
    opacity: 0;
    transition: opacity .12s ease;
    pointer-events: none;
}

.fd-ri__badge--base { background: rgba(var(--rz-primary-rgb, 25, 118, 210), 0.12); color: var(--rz-primary); }
.fd-ri__badge--set { background: #fcefe0; color: #c9731c; }
.fd-ri:hover > .fd-ri__badge, .fd-ri--sel > .fd-ri__badge { opacity: 1; }

.fd-ri__tip {
    position: absolute;
    top: -26px;
    right: 0;
    z-index: 12;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    background: var(--rz-text-color, #1b2231);
    color: var(--rz-base-background-color, #fff);
    padding: 2px 7px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
}

.fd-ri__handle { position: absolute; top: 8px; bottom: 8px; width: 10px; cursor: ew-resize; z-index: 4; touch-action: none; }
.fd-ri__handle--l { left: -5px; }
.fd-ri__handle--r { right: -5px; }
.fd-ri__handle::after { content: ""; position: absolute; top: 30%; bottom: 30%; left: 4px; width: 3px; border-radius: 2px; background: var(--rz-primary); opacity: 0; transition: opacity .12s ease; }
.fd-ri:hover > .fd-ri__handle::after { opacity: .7; }

.fd-ri__knob {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--rz-primary);
    color: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px var(--rz-base-background-color, #fff), 0 2px 8px rgba(0, 0, 0, .2);
    z-index: 5;
    cursor: ew-resize;
    touch-action: none;
}

.fd-ri__knob .rzi { font-size: 15px; pointer-events: none; }
.fd-ri__knob--l { left: -12px; }
.fd-ri__knob--r { right: -12px; }
.fd-ri--sel > .fd-ri__knob { display: inline-flex; }

.fd-ri__tools {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    z-index: 30;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--rz-base-background-color, #fff);
    border: 1px solid var(--rz-base-300);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .14);
}

.fd-ri__tools::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 8px; }
.fd-ri__tools button { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--rz-text-color); padding: 0; }
.fd-ri__tools button:hover { background: var(--rz-base-200); }
.fd-ri__tools .fd-ri__on { color: var(--rz-primary); background: rgba(var(--rz-primary-rgb, 25, 118, 210), 0.12); }
.fd-ri__tools .fd-ri__del:hover { color: var(--rz-danger); background: rgba(211, 47, 47, .1); }
.fd-ri__tools .rzi { font-size: 17px; }
.fd-ri__sep { width: 1px; margin: 4px 2px; background: var(--rz-base-300); }
@media (hover: hover) { .fd-ri:hover:not(:has(.fd-ri:hover)) > .fd-ri__tools { display: flex; } }
.fd-ri--sel > .fd-ri__tools { display: flex; }
body.fev2-busy .fd-ri__tools { display: none !important; }

@media (pointer: coarse) {
    .fd-ri__handle { width: 18px; }
    .fd-ri__handle--l { left: -9px; }
    .fd-ri__handle--r { right: -9px; }
    .fd-ri__knob { width: 34px; height: 34px; }
    .fd-ri__knob--l { left: -16px; }
    .fd-ri__knob--r { right: -16px; }
    .fd-ri__tools button { width: 36px; height: 36px; }
}

/* Selection panel: row layout widths */
.fev2__bp { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; padding: 8px; border: 1px solid var(--rz-base-300); border-radius: 8px; }
.fev2__bp--cur { border-color: var(--rz-primary); background: rgba(var(--rz-primary-rgb, 25, 118, 210), 0.06); }
.fev2__bp-name { font-weight: 600; font-size: 0.85rem; display: inline-flex; gap: 6px; align-items: center; }
.fev2__bp-row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.8rem; color: var(--rz-text-secondary-color); }
.fev2__classes { font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; background: var(--rz-base-100); border-radius: 6px; padding: 6px 8px; word-break: break-word; }
.fd-rows--preview { min-height: 0; }

/* The hovered/selected card (and its floating toolbar above it) must sit above neighbouring chrome
   such as a group's tab headers, or the toolbar can't be clicked on first-row items. */
.fd-ri:hover, .fd-ri--sel { z-index: 40; }
/* Radzen tab panels scroll (overflow: auto), which clips the floating toolbar of first-row items
   in a tabs group. The designer lets them overflow; the live form is unchanged. */
.fev2__page .rz-tabview-panels { overflow: visible; }

/* Multi-selection (Ctrl/Shift/⌘ + click) */
.fd-ri--multi { border-color: var(--rz-primary) !important; box-shadow: 0 0 0 3px rgba(var(--rz-primary-rgb, 25, 118, 210), 0.18); }
.fd-ri--multi::before { content: "✓"; position: absolute; top: -8px; left: -8px; z-index: 6; width: 18px; height: 18px; border-radius: 50%; background: var(--rz-primary); color: #fff; font-size: 11px; line-height: 18px; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.fd-ri { user-select: none; -webkit-user-select: none; }
