/* anota form builder chrome (bld-*). Field visuals come from anota-forms.css (af-*). */

.bld-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #eef2f1;
    font-family: "Segoe UI", system-ui, sans-serif;
}

/* ---------- top bar ---------- */
.bld-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

.bld-back {
    font-size: 20px;
    text-decoration: none;
    color: #475569;
    padding: 2px 8px;
    border-radius: 6px;
}

.bld-back:hover { background: #f1f5f9; }

.bld-title {
    font-size: 16px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    min-width: 280px;
    background: transparent;
}

.bld-title:hover { border-color: #e2e8f0; }
.bld-title:focus { border-color: #21a884; outline: none; background: #fff; }

.bld-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bld-save-status { font-size: 12.5px; color: #64748b; min-width: 60px; text-align: right; }
.bld-save-error { color: #dc2626; }

.bld-conflict {
    background: #fef3c7;
    border-bottom: 1px solid #fcd34d;
    color: #92400e;
    padding: 8px 16px;
    font-size: 14px;
}

/* ---------- buttons ---------- */
.bld-btn, .bld-btn-primary, .bld-btn-danger, .bld-btn-small {
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    color: #334155;
}

.bld-btn:hover:not(:disabled) { background: #f1f5f9; }
.bld-btn:disabled { opacity: .4; cursor: default; }

.bld-btn-primary {
    background: linear-gradient(90deg, #1b9aaa, #66c14d);
    color: #fff;
    border: none;
    font-weight: 600;
    padding: 7px 18px;
}

.bld-btn-primary:hover { filter: brightness(1.05); }

.bld-btn-danger { color: #dc2626; border-color: #fecaca; }
.bld-btn-danger:hover { background: #fef2f2; }

.bld-btn-small { padding: 4px 10px; font-size: 13px; }

.bld-btn-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #94a3b8;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
}

.bld-btn-icon:hover { color: #dc2626; background: #fef2f2; }

/* ---------- panes ---------- */
.bld-panes {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    flex: 1;
    min-height: 0;
}

.bld-left, .bld-right {
    background: #fff;
    overflow-y: auto;
    border-right: 1px solid #e2e8f0;
}

.bld-right { border-right: none; border-left: 1px solid #e2e8f0; }

.bld-canvas-host {
    overflow-y: auto;
    padding: 24px;
}

/* ---------- palette ---------- */
.bld-palette { padding: 12px; }

.bld-palette-group { margin-bottom: 14px; }

.bld-palette-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    margin: 0 4px 6px;
}

.bld-palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 1px solid #eef2f6;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13.5px;
    color: #334155;
    cursor: grab;
    background: #fff;
    user-select: none;
}

.bld-palette-item:hover { border-color: #21a884; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.bld-palette-item:active { cursor: grabbing; }

.bld-palette-icon {
    width: 22px;
    text-align: center;
    color: #21a884;
    font-size: 14px;
}

/* ---------- canvas ---------- */
.bld-page {
    max-width: 760px;
    margin: 0 auto 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.bld-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    font-size: 12px;
    color: #94a3b8;
    border-bottom: 1px dashed #e2e8f0;
}

.bld-canvas {
    position: relative;
    padding: 20px;
    min-height: 120px;
}

.bld-canvas-empty {
    grid-column: span 12;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 36px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

.bld-field {
    position: relative;
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 6px;
    cursor: grab;
}

.bld-field:hover { border-color: #d8e5e0; }

.bld-field.bld-selected { border-color: #21a884; background: #f6fbf9; }

.bld-field.bld-dragging { opacity: .4; }

.bld-hidden-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 4px;
    padding: 1px 6px;
}

.bld-drop-indicator {
    position: absolute;
    left: 12px;
    right: 12px;
    height: 3px;
    background: #21a884;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
}

.bld-add-page {
    display: block;
    margin: 0 auto 32px;
    border: 1px dashed #94a3b8;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 13.5px;
}

.bld-add-page:hover { border-color: #21a884; color: #21a884; }

/* ---------- property panel ---------- */
.bld-props { padding: 14px; font-size: 13.5px; }

.bld-props-empty { color: #94a3b8; text-align: center; padding: 40px 10px; }

.bld-props-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bld-props-type {
    font-weight: 600;
    color: #0f172a;
    text-transform: capitalize;
}

.bld-prop { display: block; margin-bottom: 12px; }

.bld-prop > span {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.bld-prop input[type="text"], .bld-prop input:not([type]), .bld-prop input[type="number"],
.bld-prop select, .bld-prop textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 7px 9px;
    font-size: 13.5px;
    background: #fff;
}

.bld-prop input:focus, .bld-prop select:focus, .bld-prop textarea:focus {
    border-color: #21a884;
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 168, 132, .12);
}

.bld-prop-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bld-prop-inline > span { margin: 0; font-size: 13.5px; color: #334155; }

.bld-option-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}

.bld-prop-advanced summary {
    cursor: pointer;
    color: #64748b;
    font-size: 12.5px;
    margin: 10px 0;
}

.bld-loading { padding: 60px; text-align: center; color: #64748b; }

/* design-mode field wrapper interaction guard */
.af-design { pointer-events: none; }

/* ---------- live theme preview (canvas) ---------- */
/* The wrapper carries the FormTheme custom props so af- fields preview the real theme.
   .af-form already paints var(--af-bg); the page cards pick up var(--af-page). */
.bld-canvas-theme {
    background: transparent;
    min-height: 100%;
    padding: 8px;
    border-radius: 12px;
}

.bld-canvas-theme .bld-page { background: var(--af-page); }

/* ---------- theme panel ---------- */
.bld-theme-hint {
    font-size: 12px;
    color: #94a3b8;
    margin: 0 0 16px;
    line-height: 1.5;
}

.bld-color-row { display: flex; gap: 8px; align-items: center; }

.bld-color-swatch {
    width: 40px;
    height: 34px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    flex: none;
}

.bld-color-hex { flex: 1; }
