// BlockManager admin SPA — Composer view
// Three-pane layout: left = element picker, centre = canvas, right = settings (Phase 5)

.bm-admin {
    display: grid;
    // Canvas claims a hard minimum so it doesn't collapse when the legacy
    // admin chrome constrains the SPA viewport; picker and rail are flexible
    // within sane bounds.
    grid-template-columns: minmax(200px, 240px) minmax(360px, 1fr) minmax(260px, 300px);
    gap: 1rem;
    padding: 1rem;
    min-height: calc(100vh - 60px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;

    &__pane {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        padding: 1rem;
        overflow-y: auto;
    }

    &__title {
        margin: 0 0 0.75rem;
        font-size: 0.875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }

    &__toolbar {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
    }
}

.bm-picker {
    &__hint {
        margin: 0 0 0.75rem;
        font-size: 0.7rem;
        color: #9ca3af;
        font-style: italic;
    }
    &__group { margin-bottom: 1rem; }
    &__group-label {
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #9ca3af;
        margin: 0 0 0.5rem;
    }
    &__tile {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.25rem;
        background: #f3f4f6;
        border: 1px solid transparent;
        border-radius: 4px;
        cursor: grab;
        font-size: 0.875rem;
        text-align: left;

        &:hover { background: #e5e7eb; }
        &:active { cursor: grabbing; }
        &.is-dragging { opacity: 0.5; }
    }
}

// "← All blocks" composer back button.
.bm-back-button {
    padding: 0.4rem 0.6rem;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #374151;

    &:hover { background: #eef4fe; border-color: #cfe0fa; color: #0f55c4; }
}

// Blocks landing list (cards).
.bm-block-list {
    padding: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;

    &__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
    }
    &__title {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 600;
    }
    &__status {
        padding: 1rem;
        color: #6b7280;
        font-size: 0.875rem;
        &--error { color: #b91c1c; }
    }
    &__empty {
        padding: 2.5rem 1rem;
        text-align: center;
        color: #6b7280;
        background: #ffffff;
        border: 1px dashed #d1d5db;
        border-radius: 6px;
    }
    &__grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 0.75rem;
    }
}

.bm-block-card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 0.5rem;
    padding: 0.85rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;

    &:hover {
        border-color: #cfe0fa;
        box-shadow: 0 2px 6px rgba(15, 85, 196, 0.08);
    }

    &__icon {
        font-size: 1.25rem;
        color: #0f55c4;
        opacity: 0.7;
    }
    &__body { min-width: 0; }
    &__name {
        margin: 0;
        font-size: 0.95rem;
        font-weight: 600;
        color: #111827;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    &__slug {
        margin: 0.1rem 0 0;
        font-family: ui-monospace, SFMono-Regular, monospace;
        font-size: 0.7rem;
        color: #6b7280;
    }
    &__desc {
        margin: 0.35rem 0 0;
        font-size: 0.8rem;
        color: #4b5563;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    &__meta {
        display: flex;
        gap: 0.4rem;
    }
    &__badge {
        display: inline-block;
        padding: 0.1rem 0.5rem;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-radius: 999px;
        background: #f3f4f6;
        color: #6b7280;

        &--shipped {
            background: #ecfdf5;
            color: #047857;
        }
    }
    &__actions {
        display: flex;
        gap: 0.35rem;
        justify-content: flex-end;
        padding-top: 0.25rem;
        border-top: 1px solid #f3f4f6;
    }
}

// Elements tab landing — card grid (mirrors the Blocks list).
// Layout/typography for .bm-designer__picker and the draft/create detail view
// live in the main `.bm-designer` block lower in this file.
.bm-element-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.bm-element-card {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 0.4rem;
    padding: 0.85rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;

    &:hover,
    &:focus-visible {
        border-color: #cfe0fa;
        box-shadow: 0 2px 6px rgba(15, 85, 196, 0.08);
        outline: none;
    }

    &.is-selected {
        border-color: #0f55c4;
        box-shadow: 0 0 0 1px #0f55c4;
    }

    &__icon {
        font-size: 1.35rem;
        color: #0f55c4;
        opacity: 0.75;
    }
    &__body { min-width: 0; }
    &__name {
        margin: 0;
        font-size: 0.95rem;
        font-weight: 600;
        color: #111827;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    &__slug {
        margin: 0.1rem 0 0;
        font-family: ui-monospace, SFMono-Regular, monospace;
        font-size: 0.7rem;
        color: #6b7280;
    }
    &__meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        align-items: flex-end;
    }
    &__badge {
        display: inline-block;
        padding: 0.1rem 0.5rem;
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-radius: 999px;
        background: #f3f4f6;
        color: #6b7280;

        &--layout {
            background: #eef4fe;
            color: #0f55c4;
        }
    }
}

// Elements tab — detail view header (back button + chosen element).
.bm-designer__picker-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;

    .bm-admin__title { margin: 0; }
}

.bm-designer__picker-type {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.7rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    vertical-align: middle;
}

.bm-canvas {
    min-height: 200px;
    &__empty {
        padding: 2rem;
        color: #9ca3af;
        text-align: center;
        border: 1px dashed #d1d5db;
        border-radius: 6px;
    }
}

.bm-instance {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;

    &__type { font-weight: 600; }
    &__variant {
        font-size: 0.75rem;
        color: #6b7280;
        background: #ffffff;
        padding: 0.125rem 0.5rem;
        border-radius: 999px;
        border: 1px solid #e5e7eb;
    }
    &__controls { display: flex; gap: 0.25rem; }
    &__btn {
        padding: 0.25rem 0.5rem;
        background: transparent;
        border: 1px solid #d1d5db;
        border-radius: 3px;
        cursor: pointer;
        font-size: 0.75rem;
        line-height: 1;

        &:hover { background: #e5e7eb; }
        &--danger:hover { background: #fee2e2; border-color: #f87171; color: #991b1b; }
    }
}

.bm-name-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.bm-button-primary {
    padding: 0.5rem 1rem;
    background: #0f55c4;
    color: #ffffff;
    border: 1px solid #0f55c4;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;

    &:hover { background: darken(#0f55c4, 8%); }
    &:disabled { opacity: 0.5; cursor: not-allowed; }

    &--ghost {
        background: transparent;
        color: #0f55c4;

        &:hover { background: #eef4fe; }
    }
}

// ---- Right rail ----

.bm-rail-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.bm-rail-tab {
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.875rem;
    color: #6b7280;

    &.is-active {
        color: #0f55c4;
        border-bottom-color: #0f55c4;
        font-weight: 600;
    }
}

.bm-rail-pane { padding-top: 0.25rem; }

.bm-rail-empty {
    padding: 1.5rem 1rem;
    color: #9ca3af;
    text-align: center;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
}

.bm-rail-subtitle {
    margin: 1rem 0 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.bm-rail-actions { margin-top: 0.75rem; }

.bm-rail-action {
    padding: 0.5rem 0.75rem;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;

    &:hover { background: #e5e7eb; }
}

.bm-rail-field {
    display: block;
    margin-bottom: 0.75rem;

    &__label {
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        font-weight: 600;
        color: #6b7280;
    }
    &__input {
        width: 100%;
        padding: 0.5rem 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        font-size: 0.875rem;
        font-family: inherit;
    }
}

// Structure tab — interactive list (GridManager structure-bar pattern)
.bm-structure {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bm-structure__node {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

// Nested container children — recursive drop zone in the Structure tab.
.bm-structure__children {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 0.5rem;
}

.bm-structure__empty {
    margin: 0;
    font-size: 0.7rem;
    color: #9ca3af;
    font-style: italic;
}

.bm-structure__row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.5rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;

    &:hover {
        border-color: #93b4ec;
        background: #fafbff;
    }

    &.is-selected {
        border-color: #0f55c4;
        background: #eef4fe;
    }
}

.bm-structure__handle {
    color: #9ca3af;
    cursor: grab;
    user-select: none;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0 0.15rem;

    &:active { cursor: grabbing; }
}

.bm-structure__index {
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
}

.bm-structure__type { font-weight: 600; }

.bm-structure__variant {
    font-size: 0.7rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.bm-structure__name {
    font-family: ui-monospace, SFMono-Regular, monospace;
    color: #6b7280;
    font-size: 0.7rem;
}

.bm-structure__delete {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;

    &:hover {
        background: #fee2e2;
        color: #dc2626;
        border-color: #fecaca;
    }
}

// vue-draggable-plus visual feedback inside the Structure list
.bm-structure__ghost {
    opacity: 0.35;
    background: #eef4fe !important;
    border-color: #cfe0fa !important;
}
.bm-structure__chosen { cursor: grabbing; }

// Fields tab
.bm-fields-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bm-fields-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto auto auto;
    gap: 0.4rem;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    background: #ffffff;
    font-size: 0.875rem;

    &__source {
        color: #9ca3af;
        font-weight: 700;
    }
    &__rename {
        padding: 0.25rem 0.4rem;
        border: 1px solid transparent;
        border-radius: 3px;
        font-family: ui-monospace, SFMono-Regular, monospace;
        font-size: 0.75rem;
        background: #f9fafb;

        &:hover, &:focus { border-color: #d1d5db; background: #ffffff; }
    }
    &__name {
        font-family: ui-monospace, SFMono-Regular, monospace;
        font-size: 0.75rem;
    }
    &__type {
        font-size: 0.7rem;
        color: #6b7280;
        background: #f3f4f6;
        padding: 0.125rem 0.4rem;
        border-radius: 999px;
    }
    &__required {
        font-size: 0.7rem;
        color: #6b7280;
        display: flex;
        align-items: center;
        gap: 0.2rem;
    }
    &__btn {
        padding: 0.15rem 0.4rem;
        background: transparent;
        border: 1px solid #d1d5db;
        border-radius: 3px;
        cursor: pointer;
        font-size: 0.7rem;
        line-height: 1;

        &:hover { background: #e5e7eb; }
        &:disabled { opacity: 0.4; cursor: not-allowed; }
        &--danger:hover { background: #fee2e2; border-color: #f87171; color: #991b1b; }
    }
}

.bm-fields-repeaters { margin-top: 1rem; }

.bm-fields-repeater {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.5rem;
    border: 1px solid #fde68a;
    background: #fffbeb;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;

    &__meta {
        flex: 1;
        font-size: 0.75rem;
        color: #6b7280;
    }
}

// Variant picker
.bm-variant-picker {
    position: relative;

    &__current {
        padding: 0.15rem 0.4rem;
        background: #ffffff;
        border: 1px solid #d1d5db;
        border-radius: 999px;
        cursor: pointer;
        font-size: 0.7rem;
        color: #374151;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;

        &:hover { background: #f9fafb; }
        &:disabled { cursor: default; opacity: 0.7; }
    }
    &__chevron { font-size: 0.6rem; color: #6b7280; }

    &__list {
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 0.25rem;
        list-style: none;
        padding: 0.25rem 0;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 4px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        z-index: 10;
        min-width: 8rem;
    }
    &__item {
        padding: 0.4rem 0.75rem;
        cursor: pointer;
        font-size: 0.8rem;

        &:hover { background: #f3f4f6; }
        &.is-active { background: #eef4fe; color: #0f55c4; font-weight: 600; }
    }
}

// ---- Designer skeleton (Phase 8) ----

.bm-designer {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
    background: #f9fafb;

    &__layout {
        display: grid;
        grid-template-columns: 280px 1fr 320px;
        gap: 1rem;
        padding: 1rem;
        flex: 1;
    }

    &__rail,
    &__canvas {
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        padding: 1rem;
        overflow-y: auto;
    }

    &__placeholder {
        margin: 0.5rem 0 0;
        padding: 1rem;
        color: #9ca3af;
        background: #f9fafb;
        border: 1px dashed #d1d5db;
        border-radius: 6px;
        font-size: 0.875rem;
        line-height: 1.5;
    }

    &__preview {
        min-height: 320px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 0.5rem;
    }

    &__draft-id {
        margin-top: 1rem;
        padding: 0.5rem 0.75rem;
        background: #eef4fe;
        border-radius: 4px;
        font-family: ui-monospace, SFMono-Regular, monospace;
        font-size: 0.75rem;
        color: #0f55c4;
    }
}

// Unified admin shell tab bar (Blocks | Elements)
.bm-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;

    &__btn {
        padding: 0.4rem 0.9rem;
        font-size: 0.875rem;
        color: #6b7280;
        text-decoration: none;
        border-radius: 4px;
        border: 1px solid transparent;
        background: transparent;
        cursor: pointer;

        &:hover { background: #f3f4f6; }
        &.is-active {
            background: #eef4fe;
            color: #0f55c4;
            font-weight: 600;
            border-color: #cfe0fa;
        }
    }
}

.bm-designer__draft-meta {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1.5;

    code { font-family: ui-monospace, SFMono-Regular, monospace; }
}

.bm-designer__msg {
    font-size: 0.75rem;
    color: #6b7280;
}

// ---- Property panels (Phase 9) ----

.bm-prop-panel {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;

    &__title {
        margin: 0 0 0.5rem;
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }
}

.bm-prop-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);

    &:last-child { border-bottom: none; }

    &__label {
        font-size: 0.75rem;
        color: #374151;
    }
}

.bm-token-value {
    display: flex;
    gap: 0.25rem;
    align-items: center;

    &__input,
    &__select {
        flex: 1;
        min-width: 0;
        padding: 0.3rem 0.5rem;
        border: 1px solid #d1d5db;
        border-radius: 3px;
        font-size: 0.75rem;
        font-family: inherit;
        background: #ffffff;
    }

    &__token-display {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.25rem;
        padding: 0.3rem 0.5rem;
        background: #eef4fe;
        border: 1px solid #cfe0fa;
        border-radius: 3px;

        code {
            font-family: ui-monospace, SFMono-Regular, monospace;
            font-size: 0.7rem;
            color: #0f55c4;
        }
    }

    &__clear {
        padding: 0 0.3rem;
        background: transparent;
        border: none;
        cursor: pointer;
        color: #6b7280;
        font-size: 0.9rem;
        line-height: 1;

        &:hover { color: #ef4444; }
    }
}

// ---- Preview canvas (Phase 10) ----

.bm-preview-canvas {
    display: flex;
    flex-direction: column;
    height: 100%;

    &__header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }

    &__label {
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }

    &__status {
        font-size: 0.7rem;
        color: #9ca3af;
        font-style: italic;

        &--error {
            color: #b91c1c;
            font-style: normal;
        }
    }

    &__stage {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        background: #ffffff;
        border: 1px dashed #d1d5db;
        border-radius: 6px;
        min-height: 320px;
    }

    &__frame {
        max-width: 100%;
    }

    &__warnings {
        margin-top: 0.75rem;
        padding: 0.5rem 0.75rem;
        background: #fffbeb;
        border: 1px solid #fde68a;
        border-radius: 4px;
        list-style: disc inside;
        font-size: 0.75rem;
        color: #92400e;
    }
}

.bm-token-picker {
    position: relative;

    &__btn {
        padding: 0.25rem 0.5rem;
        background: #ffffff;
        border: 1px solid #d1d5db;
        border-radius: 3px;
        cursor: pointer;
        font-size: 0.7rem;
        color: #374151;

        &:hover { background: #f3f4f6; }
    }

    &__list {
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 0.25rem;
        max-height: 320px;
        overflow-y: auto;
        list-style: none;
        padding: 0.25rem 0;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 4px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        z-index: 20;
        min-width: 18rem;
    }

    &__item {
        display: grid;
        grid-template-columns: auto 16px 1fr;
        gap: 0.5rem;
        align-items: center;
        padding: 0.35rem 0.75rem;
        cursor: pointer;
        font-size: 0.75rem;

        &:hover { background: #f3f4f6; }
    }

    &__name {
        font-family: ui-monospace, SFMono-Regular, monospace;
        color: #0f55c4;
    }

    &__swatch {
        width: 16px;
        height: 16px;
        border-radius: 3px;
        border: 1px solid #e5e7eb;
    }

    &__value {
        color: #6b7280;
        font-size: 0.7rem;
        font-family: ui-monospace, SFMono-Regular, monospace;
        text-align: right;
    }

    &__empty {
        padding: 0.5rem 0.75rem;
        color: #9ca3af;
        font-size: 0.75rem;
        font-style: italic;
    }
}

// Phase 17 — Designer SPA completion
.bm-designer {
    &__landing {
        padding: 2rem;
        // The landing sits inside the 3-column editor grid; span every column
        // so the element card grid can use the full width. Escaped so LESS
        // doesn't evaluate the slash as division (1 / -1 → -1).
        grid-column: ~"1 / -1";
    }

    &__picker {
        // No width cap: the card grid fills the landing. The detail view caps
        // its own form/list below so it stays readable.
    }

    &__field {
        display: block;
        margin-bottom: 1rem;

        &-label {
            display: block;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
            color: #6b7280;
            margin-bottom: 0.25rem;
        }
    }

    &__input {
        display: block;
        width: 100%;
        padding: 0.5rem 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        font-size: 0.875rem;
        background: #fff;
    }

    &__picker-tabs {
        display: flex;
        gap: 0.5rem;
        margin: 1rem 0;
    }

    &__picker-list {
        margin-top: 1rem;
        max-width: 560px;
    }

    &__draft-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    &__draft-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        margin-bottom: 0.5rem;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 4px;
        cursor: pointer;

        &:hover {
            border-color: #6b7280;
        }
    }

    &__draft-slug {
        font-size: 0.75rem;
        color: #6b7280;
        font-family: ui-monospace, SFMono-Regular, monospace;
    }

    &__picker-form {
        margin-top: 1rem;
        max-width: 420px;
    }

    &__rail-heading {
        margin: 1.25rem 0 0.5rem;
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #9ca3af;
    }

    &__tabbar {
        display: flex;
        gap: 0.25rem;
        flex-wrap: wrap;

        &--bp .bm-rail-tab {
            text-transform: capitalize;
        }
    }

    &__banner {
        margin-top: 1rem;
        padding: 0.75rem;
        border-radius: 4px;
        font-size: 0.8rem;

        &--warning {
            background: #fef3c7;
            border: 1px solid #fbbf24;
            color: #92400e;
        }

        &-body {
            margin-top: 0.25rem;
            font-weight: 400;
        }
    }

    &__badge {
        display: inline-flex;
        align-items: center;
        padding: 0.25rem 0.5rem;
        margin-left: 0.5rem;
        border-radius: 999px;
        font-size: 0.7rem;
        font-weight: 600;

        &--raw {
            background: #fef3c7;
            color: #92400e;
        }
    }

    &__cell-hint {
        margin: 0.5rem 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        color: #6b7280;
        background: #f9fafb;
        border-radius: 4px;
    }

    &__draft-meta {
        font-size: 0.75rem;
        color: #4b5563;

        > div {
            padding: 0.125rem 0;
        }
    }
}

// Composer live preview canvas — inline rendering + vue-draggable-plus
.bm-admin__pane--canvas {
    padding: 0;
    overflow: hidden;
}

.bm-pv-canvas {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 480px;

    &__bar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.4rem 0.75rem;
        border-bottom: 1px solid #e5e7eb;
        background: #f9fafb;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }

    &__status {
        font-size: 0.7rem;
        color: #9ca3af;
        text-transform: none;
        letter-spacing: 0;

        &--error { color: #b02a37; }
    }
}

// The inline drop target — site CSS leaks intentionally into here so the
// previewed elements look like the real site. Site rules can't reach outside
// because admin chrome carries its own shell-guard resets below.
.bm-pv-stage {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    background: #fff;
    min-height: 300px;
}

.bm-pv-row {
    position: relative;
    margin: 0 0 0.5rem;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.12s ease;

    &:hover {
        border-color: #93b4ec;

        .bm-pv-row__delete { opacity: 1; }
    }

    &.is-selected {
        border-color: #0f55c4;
        box-shadow: 0 0 0 1px #0f55c4;
    }

    &__body { padding: 4px; }

    &__pending {
        padding: 1rem;
        color: #9ca3af;
        font-style: italic;
        font-size: 0.85rem;
        border: 1px dashed #d1d5db;
        border-radius: 4px;
    }

    &__delete {
        position: absolute;
        top: -10px;
        right: -10px;
        width: 22px;
        height: 22px;
        padding: 0;
        border: 2px solid #fff;
        border-radius: 50%;
        background: #dc2626;
        color: #fff;
        font-size: 14px;
        line-height: 1;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.12s ease;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
        z-index: 2;

        &:hover { background: #b91c1c; }
    }
}

.bm-pv-empty {
    padding: 3rem 1rem;
    color: #9ca3af;
    font-size: 0.875rem;
    text-align: center;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
}

// vue-draggable-plus / Sortable visual feedback classes
.bm-pv-ghost {
    opacity: 0.35;
    background: #eef4fe;
    border-color: #cfe0fa !important;
}
.bm-pv-chosen { cursor: grabbing; }
.bm-pv-drag { box-shadow: 0 6px 16px rgba(15, 85, 196, 0.25); }

// Picker draggable container
.bm-picker__draggable {
    display: flex;
    flex-direction: column;
}

// ---- Shell guard: undo any site CSS leak into the admin chrome ----
// Site app.css is loaded into this document so the preview can use it. The
// rules below re-assert the admin shell's typography and colour AFTER site
// CSS (this stylesheet is loaded LATER in source order, so equal-specificity
// rules win the tiebreak). Preview content lives inside `.bm-pv-stage` and
// deliberately inherits site CSS — these guards do not penetrate there.
.bm-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;
    background: #fff;
    line-height: 1.5;
}
.bm-app *,
.bm-app *::before,
.bm-app *::after { box-sizing: border-box; }
.bm-app a:not(.bm-pv-stage a) { color: inherit; text-decoration: none; }

// Legacy admin chrome lives OUTSIDE `.bm-app` (`#header`, `#wrapper`, etc.).
// Site app.css has its own `#header { background: transparent }` rule (for
// the public site's translucent header design) which would otherwise blank
// out the admin top bar. Reassert the chrome's colour here.
#header {
    background: var(--mtc_blue, #0f55c4);
    color: #fff;
}

// Right-rail selected-element panel
.bm-element-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;

    &__row {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        font-size: 0.75rem;
        color: #6b7280;
    }

    &__actions {
        display: flex;
        gap: 0.4rem;
        flex-wrap: wrap;
    }
}

.bm-rail-empty {
    color: #9ca3af;
    font-size: 0.8rem;
    padding: 1rem 0;
}

// "← All elements" back control inside the Designer editor's left rail.
.bm-designer__back {
    align-self: flex-start;
    margin: 0 0 0.75rem;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 0;
    border-radius: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    cursor: pointer;

    &:hover {
        background: #f3f4f6;
        color: #1f2937;
    }
}

// Designer "Sample content" rail panel — per-input editor + image picker
.bm-sample-content {
    margin-top: 1rem;

    &__row {
        margin-bottom: 0.5rem;
    }

    &__label {
        display: flex;
        gap: 0.4rem;
        align-items: baseline;
        font-size: 0.75rem;
        color: #4b5563;
        margin-bottom: 0.2rem;
    }

    &__hint {
        font-size: 0.65rem;
        color: #9ca3af;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    &__input {
        width: 100%;
        padding: 0.3rem 0.5rem;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        font-size: 0.8rem;
        background: #fff;

        &--textarea {
            font-family: inherit;
            resize: vertical;
        }
    }

    &__image {
        display: flex;
        gap: 0.35rem;
    }

    &__browse {
        flex-shrink: 0;
        padding: 0.3rem 0.65rem;
        font-size: 0.75rem;
        background: #f3f4f6;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        cursor: pointer;

        &:hover:not(:disabled) { background: #e5e7eb; }
        &:disabled { opacity: 0.6; cursor: progress; }
    }
}

// ---- Container element: palette tile variant ----

.bm-picker__tile--container {
    border: 1px dashed #93b4ec;
    background: #f0f5ff;

    &:hover { background: #e8effe; border-color: #6691d8; }
}

.bm-picker__tile-badge {
    margin-left: auto;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    pointer-events: none;
}

// ---- Container element: canvas row ----

.bm-pv-row--container {
    border: 1px dashed #93b4ec;
    background: #f8faff;
    padding: 0.5rem;

    &:hover { border-color: #4d7dd9; }
    &.is-selected { border-color: #0f55c4; border-style: dashed; }
}

.bm-pv-container {
    &__header {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        margin-bottom: 0.4rem;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    &__label {
        font-weight: 600;
        color: #374151;
    }

    &__variant {
        padding: 0.1rem 0.3rem;
        border-radius: 3px;
        background: #e0e7ff;
        color: #3730a3;
        font-size: 0.65rem;
        font-weight: 600;
    }

    &__drop-zone {
        min-height: 56px;
        border: 1px dashed #d1d5db;
        border-radius: 4px;
        padding: 0.25rem;
        background: #fff;
        transition: border-color 0.12s ease, background 0.12s ease;

        // Sortable drag-over class injected by vue-draggable-plus
        &.sortable-drag-over,
        &:focus-within {
            border-color: #0f55c4;
            background: #f0f5ff;
        }
    }

    &__empty {
        padding: 0.75rem 1rem;
        color: #9ca3af;
        font-size: 0.78rem;
        text-align: center;
        font-style: italic;
        pointer-events: none;
    }
}

// ---- Container hint in the element panel right rail ----

.bm-element-panel__container-hint {
    margin: 0;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    background: #f0f5ff;
    border: 1px solid #c7d9f8;
    font-size: 0.78rem;
    color: #374151;
    line-height: 1.4;
}

// ---- Container style panel (composer right rail) ----

.bm-container-style {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.bm-cs-segmented {
    display: flex;
    gap: 0.25rem;

    .bm-rail-tab { flex: 1 1 0; text-align: center; }
}
