/* Editor de formulários (partials/form.html). Tudo prefixado com .fb- */

.fb {
    --fb-accent: #3c8dbc;
    --fb-accent-soft: #eaf4fa;
    --fb-border: #e1e6ed;
    --fb-text: #1f2d3d;
    --fb-muted: #8492a6;
    --fb-danger: #dd4b39;
    --fb-warning: #f39c12;
    --fb-canvas: #f6f8fb;
    --fb-radius: 10px;
}

.fb-box {
    border-radius: var(--fb-radius);
    border-top-width: 3px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.fb-box-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fb-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eef1f5;
    color: #5b6b7f;
}

.fb-status-E { background: #fff4e0; color: #b26a00; }
.fb-status-EA { background: #e8f1fb; color: #1f6aa5; }
.fb-status-A { background: #e3f6ec; color: #0a7a43; }
.fb-status-I { background: #f1f1f1; color: #777; }

.fb-version {
    font-size: 12px;
    color: var(--fb-muted);
}

.fb-segmented .btn.active {
    background: var(--fb-accent);
    border-color: var(--fb-accent);
    color: #fff;
    box-shadow: none;
}

.fb-checkbox {
    margin-top: 4px;
}

.fb-audit {
    color: var(--fb-muted);
    font-size: 12px;
    padding-top: 24px;
    text-align: right;
}

.fb-muted { color: var(--fb-muted); }
.fb-help { font-size: 12px; margin: 6px 0 0; }
.fb-placeholder { color: #a7b1bf; font-style: italic; }

/* --- Layout de três colunas --- */

.fb-builder {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}

.fb-builder.fb-readonly {
    grid-template-columns: minmax(0, 1fr) 360px;
}

.fb-palette,
.fb-props {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--fb-border);
    border-radius: var(--fb-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.fb-palette-inner,
.fb-props-inner {
    padding: 14px;
}

.fb-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--fb-muted);
    margin-bottom: 4px;
}

.fb-title-spaced { margin-top: 18px; }

.fb-palette p.fb-muted {
    font-size: 12px;
    margin-bottom: 10px;
}

.fb-adding-to {
    font-size: 12px;
    background: var(--fb-accent-soft);
    color: #2a6f97;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Itens do menu lateral --- */

.fb-type {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 6px;
    border: 1px solid var(--fb-border);
    border-radius: 8px;
    background: #fff;
    cursor: grab;
    user-select: none;
    transition: border-color .12s, box-shadow .12s, transform .12s;
}

.fb-type:hover {
    border-color: var(--fb-accent);
    box-shadow: 0 2px 6px rgba(60, 141, 188, .18);
    transform: translateY(-1px);
}

.fb-type:active { cursor: grabbing; }

.fb-type-new-section {
    border-style: dashed;
}

.fb-type-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef1f5;
    color: #51627a;
    font-size: 15px;
}

.fb-type-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.fb-type-name {
    font-weight: 600;
    color: var(--fb-text);
    font-size: 13px;
}

.fb-type-hint {
    font-size: 11px;
    color: var(--fb-muted);
    line-height: 1.3;
}

.fb-type-S { background: #e7f2fa; color: #2f7fb0; }
.fb-type-M { background: #eeedf8; color: #5551a0; }
.fb-type-Y { background: #e3f6ec; color: #0a8a4c; }
.fb-type-C { background: #fff3df; color: #c47b00; }
.fb-type-L { background: #fbe6ef; color: #c2185b; }
.fb-type-V { background: #e2f7fc; color: #0094b8; }
.fb-type-N { background: #e3f7f6; color: #1f9e9e; }
.fb-type-D { background: #fff0e4; color: #d9670f; }
.fb-type-T { background: #eef0f3; color: #59636f; }

/* --- Área do formulário --- */

.fb-canvas {
    min-height: 420px;
    padding: 14px;
    background: var(--fb-canvas);
    border: 1px solid var(--fb-border);
    border-radius: var(--fb-radius);
}

.fb-canvas.fb-drop-active { outline: 2px dashed rgba(60, 141, 188, .35); outline-offset: -6px; }

.fb-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: #fff7e6;
    color: #8a5a00;
    border: 1px solid #ffe2a8;
    font-size: 13px;
}

.fb-pending a { margin-left: auto; font-weight: 600; }

.fb-empty-form {
    text-align: center;
    color: var(--fb-muted);
    padding: 50px 0 20px;
}

.fb-empty-form .fa { font-size: 40px; margin-bottom: 10px; }

/* Seção = quadro onde as questões são soltas */
.fb-section {
    position: relative;
    background: #fff;
    border: 1px solid var(--fb-border);
    border-radius: var(--fb-radius);
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color .12s, box-shadow .12s;
}

.fb-section.fb-active { border-color: #b9d7ea; }
.fb-section.fb-selected { border-color: var(--fb-accent); box-shadow: 0 0 0 3px rgba(60, 141, 188, .15); }
.fb-section.fb-invalid { border-left: 4px solid var(--fb-danger); }
.fb-section.fb-drop-active { border-color: var(--fb-accent); border-style: dashed; background: #fbfdff; }
.fb-section.fb-dragging { opacity: .4; }

.fb-section.fb-drop-before::before,
.fb-section.fb-drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 2px;
    background: var(--fb-accent);
}

.fb-section.fb-drop-before::before { top: -10px; }
.fb-section.fb-drop-after::after { bottom: -10px; }

.fb-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f5;
    border-radius: var(--fb-radius) var(--fb-radius) 0 0;
    background: linear-gradient(180deg, #fbfcfe, #f5f7fa);
    cursor: pointer;
}

.fb-section-head[draggable="true"] { cursor: grab; }

.fb-section-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.fb-kicker {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--fb-muted);
}

.fb-section-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--fb-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fb-count {
    font-size: 12px;
    color: var(--fb-muted);
    white-space: nowrap;
}

.fb-section-desc {
    padding: 8px 14px 0;
    color: #5b6b7f;
    font-size: 13px;
}

.fb-questions {
    padding: 10px 12px 12px;
    min-height: 60px;
}

.fb-section-empty {
    border: 2px dashed #d6dde6;
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    color: var(--fb-muted);
    font-size: 13px;
}

.fb-section-empty .fa { margin-right: 6px; }
.fb-section.fb-drop-active .fb-section-empty { border-color: var(--fb-accent); color: var(--fb-accent); background: var(--fb-accent-soft); }

/* Cartão de questão */
.fb-question {
    position: relative;
    border: 1px solid var(--fb-border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s;
}

.fb-question[draggable="true"] { cursor: grab; }
.fb-question:hover { border-color: #b9c6d6; }
.fb-question.fb-selected { border-color: var(--fb-accent); box-shadow: 0 0 0 3px rgba(60, 141, 188, .15); }
.fb-question.fb-invalid { border-left: 4px solid var(--fb-danger); }
.fb-question.fb-dragging { opacity: .35; }

.fb-question.fb-drop-before::before,
.fb-question.fb-drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 2px;
    background: var(--fb-accent);
}

.fb-question.fb-drop-before::before { top: -6px; }
.fb-question.fb-drop-after::after { bottom: -6px; }

.fb-q-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.fb-grip {
    color: #b3bdca;
    padding-top: 3px;
}

.fb-q-number {
    flex: 0 0 auto;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    background: #eef1f5;
    color: #51627a;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.fb-q-body {
    flex: 1 1 auto;
    min-width: 0;
}

.fb-q-text {
    font-weight: 600;
    color: var(--fb-text);
    word-break: break-word;
}

.fb-q-desc {
    font-size: 12px;
    color: var(--fb-muted);
    margin-top: 2px;
}

.fb-q-type {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.fb-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity .12s;
}

.fb-question:hover .fb-actions,
.fb-question.fb-selected .fb-actions,
.fb-section-head:hover .fb-actions,
.fb-section.fb-selected > .fb-section-head .fb-actions { opacity: 1; }

.fb-icon-btn {
    border: 0;
    background: transparent;
    color: #6b7a8f;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.fb-icon-btn:hover:not([disabled]) { background: #eef1f5; color: var(--fb-text); }
.fb-icon-btn[disabled] { opacity: .35; cursor: default; }
.fb-icon-btn.fb-danger:hover:not([disabled]) { background: #fdecea; color: var(--fb-danger); }
.fb-icon-btn.fb-on { background: var(--fb-accent-soft); color: var(--fb-accent); }

/* Pré-visualização da resposta dentro do cartão */
.fb-q-preview {
    margin: 8px 0 0 58px;
    font-size: 13px;
    color: #4a5a6e;
}

.fb-preview-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.fb-mark-radio,
.fb-mark-check {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border: 2px solid #b3bdca;
    background: #fff;
}

.fb-mark-radio { border-radius: 50%; }
.fb-mark-check { border-radius: 3px; }

.fb-value-chip {
    font-size: 11px;
    font-weight: 600;
    color: #51627a;
    background: #eef1f5;
    border-radius: 4px;
    padding: 0 6px;
    margin-left: auto;
}

.fb-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fb-pill {
    border: 1px solid var(--fb-border);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    background: #fafbfc;
}

.fb-mock-input {
    display: inline-block;
    min-width: 160px;
    border: 1px solid var(--fb-border);
    border-radius: 6px;
    padding: 4px 10px;
    color: #a7b1bf;
    background: #fafbfc;
}

.fb-mock-input b { color: #51627a; margin-left: 4px; }

.fb-mock-textarea {
    display: block;
    min-height: 44px;
}

.fb-mock-counter {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--fb-border);
    border-radius: 6px;
    padding: 4px 12px;
    background: #fafbfc;
    color: #8492a6;
}

.fb-mock-counter b { color: #51627a; }

.fb-add-section {
    display: block;
    width: 100%;
    border: 2px dashed #ccd5e0;
    background: transparent;
    border-radius: var(--fb-radius);
    padding: 12px;
    color: #5b6b7f;
    font-weight: 600;
}

.fb-add-section:hover { border-color: var(--fb-accent); color: var(--fb-accent); background: #fff; }

/* --- Painel de propriedades --- */

.fb-props-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid #eef1f5;
}

.fb-props-heading {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.fb-props-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--fb-text);
}

.fb-props fieldset { min-width: 0; }
.fb-props label { font-weight: 600; font-size: 12px; color: #4a5a6e; }

.fb-issues {
    list-style: none;
    padding: 8px 10px;
    margin: 0 0 12px;
    border-radius: 8px;
    background: #fdecea;
    color: #a63526;
    font-size: 12px;
}

.fb-issues li + li { margin-top: 3px; }

.fb-options {
    border: 1px solid var(--fb-border);
    border-radius: 8px;
    padding: 6px;
    background: #fafbfc;
}

.fb-options.fb-drop-active { border-color: var(--fb-accent); }

.fb-option-header,
.fb-option-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) 64px 48px;
    gap: 6px;
    align-items: center;
}

.fb-option-header {
    font-size: 11px;
    color: var(--fb-muted);
    padding: 0 2px 4px;
}

.fb-option-row {
    position: relative;
    padding: 4px 2px;
    border-radius: 6px;
}

.fb-option-row[draggable="true"] .fb-grip { cursor: grab; }
.fb-option-row.fb-dragging { opacity: .35; }

.fb-option-row.fb-drop-before::before,
.fb-option-row.fb-drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--fb-accent);
}

.fb-option-row.fb-drop-before::before { top: -1px; }
.fb-option-row.fb-drop-after::after { bottom: -1px; }

.fb-option-row .fb-grip { padding-top: 0; }
.fb-option-value { padding-left: 6px; padding-right: 4px; }

.fb-option-tools {
    display: flex;
    gap: 0;
}

.fb-option-tools .fb-icon-btn { width: 22px; }

.fb-add-option { margin-top: 6px; }

.fb-fixed-list {
    border: 1px solid var(--fb-border);
    border-radius: 8px;
    background: #fafbfc;
    padding: 4px 10px;
}

.fb-fixed-list > div {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.fb-fixed-list > div + div { border-top: 1px solid #eef1f5; }

.fb-props-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 12px;
    margin-top: 6px;
    border-top: 1px solid #eef1f5;
}

.fb-props-actions .fb-danger { margin-left: auto; color: var(--fb-danger); }

.fb-props-empty {
    text-align: center;
    color: var(--fb-muted);
    padding: 40px 10px;
}

.fb-props-empty .fa { font-size: 34px; margin-bottom: 10px; }

.fb-footer { position: sticky; bottom: 0; z-index: 5; margin-bottom: 0; }
.fb-footer-hint { margin-left: 12px; font-size: 12px; }

/* --- Telas menores --- */

@media (max-width: 1400px) {
    .fb-builder { grid-template-columns: 200px minmax(0, 1fr) 320px; }
    .fb-builder.fb-readonly { grid-template-columns: minmax(0, 1fr) 320px; }
    .fb-type-hint { display: none; }
}

@media (max-width: 991px) {
    .fb-builder,
    .fb-builder.fb-readonly { grid-template-columns: minmax(0, 1fr); }

    .fb-palette,
    .fb-props { position: static; max-height: none; }

    .fb-palette-inner { display: flex; flex-wrap: wrap; gap: 6px; }
    .fb-palette-inner > .fb-title,
    .fb-palette-inner > p,
    .fb-palette-inner > .fb-adding-to { flex-basis: 100%; }
    .fb-type { margin-bottom: 0; }

    .fb-q-preview { margin-left: 0; }
}
