/* Form Fields admin page — Bookwell brand */
.bw-form-fields-page {
    --bw-ff-brand: #5700b4;
    --bw-ff-brand-soft: #f6f0ff;
    --bw-ff-border: #e8e4f0;
    --bw-ff-text: #1f2937;
    --bw-ff-muted: #6b7280;
    padding: 32px 24px 24px;
}

.bw-form-fields-page .bw-header-title-section-simple {
    padding: 0 0 8px;
    margin-bottom: 4px;
}

.bw-form-fields-page .bw-ff-page-head {
    margin-bottom: 8px;
}

.bw-form-fields-page .bw-ff-page-head-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.bw-ff-settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.bw-ff-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.bw-ff-layout .bw-ff-fields-wrap {
    flex: 1;
    min-width: 0;
}

.bw-form-fields-page .bw-ff-save-btn.el-button--primary {
    --el-button-bg-color: var(--bw-ff-brand);
    --el-button-border-color: var(--bw-ff-brand);
    --el-button-text-color: #ffffff;
    --el-button-hover-bg-color: #440093;
    --el-button-hover-border-color: #440093;
    --el-button-hover-text-color: #ffffff;
    background-color: var(--bw-ff-brand) !important;
    border-color: var(--bw-ff-brand) !important;
    color: #ffffff !important;
    min-width: 150px;
}

.bw-form-fields-page .bw-ff-save-btn.el-button--primary:hover,
.bw-form-fields-page .bw-ff-save-btn.el-button--primary:focus {
    background-color: #440093 !important;
    border-color: #440093 !important;
    color: #ffffff !important;
}

.bw-ff-fields-wrap {
    margin-top: 8px;
}

.bw-ff-fields-container {
    background: #fff;
    border: 1px solid var(--bw-ff-border);
    border-radius: 8px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.04);
}

.bw-ff-fields-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.bw-ff-field-card {
    background: #fff;
    border: 1px solid var(--bw-ff-border);
    border-radius: 8px;
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.04);
}

.bw-ff-field-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px dashed var(--bw-ff-border);
    background: #fcfbfe;
}

.bw-ff-field-toolbar-left,
.bw-ff-field-toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bw-ff-field-width-wrap {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
    padding-right: 4px;
}

.bw-ff-width-select {
    width: 132px;
}

.bw-ff-width-select .el-select__wrapper {
    min-height: 30px;
}

.bw-ff-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: grab;
    padding: 4px;
}

.bw-ff-drag-handle:active {
    cursor: grabbing;
}

.bw-ff-field-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--bw-ff-muted);
    text-transform: capitalize;
}

.bw-ff-required-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.bw-ff-required-label {
    font-size: 13px;
    color: var(--bw-ff-muted);
    font-weight: 500;
}

.bw-ff-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--bw-ff-border);
    border-radius: 6px;
    background: #fff;
    color: var(--bw-ff-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.bw-ff-settings-btn:hover,
.bw-ff-settings-btn:focus {
    color: var(--bw-ff-brand);
    border-color: rgba(87, 0, 180, 0.25);
    background: var(--bw-ff-brand-soft);
}

.bw-ff-field-preview {
    padding: 18px 20px 20px;
}

.bw-ff-preview-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--bw-ff-text);
}

.bw-ff-field-preview .el-input.is-disabled .el-input__wrapper,
.bw-ff-field-preview .el-textarea.is-disabled .el-textarea__inner {
    background: #faf9fc;
}

.bw-ff-settings-panel .el-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    align-items: start;
}

.bw-ff-settings-panel .el-form-item {
    margin-bottom: 14px;
    width: 100%;
    min-width: 0;
}

.bw-ff-settings-panel .el-form-item__label {
    font-weight: 600;
    color: var(--bw-ff-text);
}

/* Full-width rows: editors, toggles, notes, multi-control blocks */
.bw-ff-settings-panel .el-form-item:has(.bw-ff-pro-options-editor),
.bw-ff-settings-panel .el-form-item:has(.bw-ff-hide-toggle),
.bw-ff-settings-panel .el-form-item:has(textarea),
.bw-ff-settings-panel .bw-ff-pro-visibility-rules,
.bw-ff-settings-panel .bw-ff-terms-note {
    grid-column: 1 / -1;
}

.bw-ff-hide-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    font-size: 13px;
    color: var(--bw-ff-text);
    font-weight: 500;
}

.bw-ff-terms-note {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--bw-ff-muted);
    line-height: 1.45;
}

.bw-ff-settings-popper.el-popper {
    width: 560px !important;
    max-width: min(560px, calc(100vw - 24px));
    border-radius: 8px;
    border-color: var(--bw-ff-border);
    box-shadow: 0 12px 40px rgba(31, 41, 55, 0.12);
    --el-color-primary: #5700b4;
    z-index: 100200 !important;
    overflow: visible !important;
}

.bw-ff-settings-popper .el-popover__content,
.bw-ff-settings-popper .bw-ff-settings-panel {
    width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
}

/* Dropdowns opened from field settings must sit above the settings popover */
.bw-ff-settings-select-popper,
.el-popper.bw-ff-settings-select-popper,
.el-select__popper.bw-ff-settings-select-popper {
    z-index: 100250 !important;
}

.bw-ff-settings-popper .bw-ff-settings-actions .el-button--primary {
    --el-button-bg-color: #5700b4;
    --el-button-border-color: #5700b4;
    --el-button-text-color: #ffffff;
    --el-button-hover-bg-color: #440093;
    --el-button-hover-border-color: #440093;
    --el-button-hover-text-color: #ffffff;
    background-color: #5700b4 !important;
    border-color: #5700b4 !important;
    color: #ffffff !important;
}

.bw-ff-settings-popper .bw-ff-settings-actions .el-button--primary:hover,
.bw-ff-settings-popper .bw-ff-settings-actions .el-button--primary:focus {
    background-color: #440093 !important;
    border-color: #440093 !important;
    color: #ffffff !important;
}

.bw-form-fields-page .el-switch.is-checked .el-switch__core {
    background-color: var(--bw-ff-brand);
    border-color: var(--bw-ff-brand);
}

@media (max-width: 768px) {
    .bw-form-fields-page {
        padding: 24px 16px 20px;
    }

    .bw-ff-layout {
        flex-direction: column;
    }

    .bw-ff-fields-container {
        padding: 16px;
    }

    .bw-form-fields-page .bw-ff-page-head-actions {
        justify-content: flex-start;
        margin-top: 12px;
    }

    .bw-ff-field-toolbar {
        flex-wrap: wrap;
    }

    .bw-ff-settings-popper.el-popper {
        width: min(560px, calc(100vw - 24px)) !important;
    }

    .bw-ff-settings-panel .el-form {
        grid-template-columns: 1fr;
    }
}
