/* ============================================================================
   Document editor
   A three-pane authoring workspace: structure tree, live canvas and inspector.
   Colours reference the Radzen theme variables so the editor blends with the
   active (dark) theme and stays consistent with the rest of the app.
   ========================================================================== */

.doc-editor {
    --editor-surface: var(--rz-panel-background-color, #191922);
    --editor-surface-2: var(--rz-base-background-color, #12121a);
    --editor-elevated: color-mix(in srgb, var(--editor-surface) 82%, #ffffff 6%);
    --editor-border: var(--rz-border-color, rgba(255, 255, 255, .09));
    --editor-text: var(--rz-text-color, #eef1f6);
    --editor-muted: var(--rz-text-secondary-color, rgba(255, 255, 255, .55));
    --editor-primary: var(--rz-primary, #4b6cff);
    --editor-radius: 12px;

    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--editor-surface-2);
    color: var(--editor-text);
}

/* ---- Toolbar ------------------------------------------------------------ */

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 1rem;
    background: var(--editor-surface);
    border-bottom: 1px solid var(--editor-border);
    flex: 0 0 auto;
    z-index: 5;
}

.editor-toolbar-left,
.editor-toolbar-right {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.editor-toolbar-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-weight: 600;
    font-size: 1rem;
    padding-left: .5rem;
    border-left: 1px solid var(--editor-border);
    min-width: 0;
}

.editor-toolbar-title span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22rem;
}

.editor-toolbar-title .rz-icon {
    color: var(--editor-muted);
}

.editor-status {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    padding: .22rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.editor-status .rz-icon {
    font-size: 1rem;
}

.editor-status.is-dirty {
    color: #f5b93b;
    background: rgba(245, 185, 59, .12);
}

.editor-status.is-saved {
    color: #46c48a;
    background: rgba(70, 196, 138, .1);
}

.editor-status.is-readonly {
    color: var(--editor-muted);
    background: rgba(255, 255, 255, .06);
}

.editor-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 3px rgba(245, 185, 59, .18);
}

/* ---- Main 3-column layout ---------------------------------------------- */

.editor-main {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
}

.editor-tree,
.editor-inspector {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--editor-surface);
    flex: 0 0 auto;
}

.editor-tree {
    width: 300px;
    border-right: 1px solid var(--editor-border);
}

.editor-inspector {
    width: 340px;
    border-left: 1px solid var(--editor-border);
}

.editor-panel-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--editor-muted);
    border-bottom: 1px solid var(--editor-border);
    flex: 0 0 auto;
}

.editor-panel-head .rz-icon {
    font-size: 1.05rem;
}

/* ---- Structure tree ---------------------------------------------------- */

.editor-tree-body {
    padding: .4rem;
}

.editor-tree-foot {
    padding: .6rem;
    border-top: 1px solid var(--editor-border);
    flex: 0 0 auto;
}

.editor-tree-add {
    width: 100%;
}

.editor-node {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .38rem .5rem;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background .12s ease;
}

.editor-node:hover {
    background: rgba(255, 255, 255, .05);
}

.editor-node.is-selected {
    background: color-mix(in srgb, var(--editor-primary) 26%, transparent);
    box-shadow: inset 2px 0 0 var(--editor-primary);
}

.editor-node-doc {
    font-weight: 600;
}

.editor-node-icon {
    font-size: 1.15rem;
    color: var(--editor-muted);
    flex: 0 0 auto;
}

.editor-node.is-selected .editor-node-icon {
    color: var(--editor-text);
}

.editor-node-label {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .88rem;
}

.editor-node-actions {
    display: flex;
    align-items: center;
    gap: .05rem;
    opacity: 0;
    transition: opacity .12s ease;
    flex: 0 0 auto;
}

.editor-node:hover .editor-node-actions,
.editor-node.is-selected .editor-node-actions {
    opacity: 1;
}

.editor-node-actions .rz-button {
    min-width: 1.6rem;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
}

.editor-node-actions .rz-button .rz-button-icon {
    font-size: 1rem;
    margin: 0;
}

.editor-node-empty {
    font-size: .78rem;
    color: var(--editor-muted);
    font-style: italic;
    padding: .3rem .5rem .5rem 2.35rem;
}

.editor-node-empty-page {
    padding-left: 3.2rem;
}

/* ---- Canvas ------------------------------------------------------------ */

.editor-canvas {
    flex: 1 1 auto;
    min-width: 0;
    background:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) 1px, transparent 0) 0 0 / 22px 22px,
        var(--editor-surface-2);
    padding: 2rem;
}

.editor-canvas-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.editor-canvas-page {
    position: relative;
    border-radius: 4px;
    cursor: pointer;
    transition: box-shadow .15s ease, transform .15s ease;
}

.editor-canvas-page:hover {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--editor-primary) 45%, transparent);
}

.editor-canvas-page.is-selected {
    box-shadow: 0 0 0 3px var(--editor-primary);
}

.editor-canvas-page-label {
    position: absolute;
    top: -1.65rem;
    left: 0;
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .75rem;
    color: var(--editor-muted);
}

.editor-canvas-page-label .rz-icon {
    font-size: 1rem;
}

.editor-canvas-empty {
    height: 100%;
}

/* ---- Inspector --------------------------------------------------------- */

.editor-inspector-selection {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--editor-border);
    background: var(--editor-elevated);
    flex: 0 0 auto;
}

.editor-inspector-selection .rz-icon {
    color: var(--editor-primary);
}

.editor-inspector-body {
    padding: .5rem .5rem 2rem;
}

.editor-section {
    border: 1px solid var(--editor-border);
    border-radius: var(--editor-radius);
    margin: .6rem .5rem;
    overflow: hidden;
    background: var(--editor-surface-2);
}

.editor-section-head {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem .8rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--editor-muted);
    background: var(--editor-elevated);
    border-bottom: 1px solid var(--editor-border);
}

.editor-section-head .rz-icon {
    font-size: 1rem;
}

.editor-section-body {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: .85rem .8rem;
}

.editor-field {
    width: 100%;
}

.editor-toggle-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.editor-toggle-field > label {
    font-size: .85rem;
    color: var(--editor-muted);
}

/* Colour field */

.editor-color-label {
    display: block;
    font-size: .72rem;
    color: var(--editor-muted);
    margin-bottom: .3rem;
}

.editor-color-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.editor-color-row .editor-color-input {
    flex: 1 1 auto;
}

/* Image field */

.editor-image-preview {
    width: 100%;
    height: 120px;
    border: 1px dashed var(--editor-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        linear-gradient(45deg, rgba(255, 255, 255, .04) 25%, transparent 25%) -8px 0 / 16px 16px,
        linear-gradient(-45deg, rgba(255, 255, 255, .04) 25%, transparent 25%) -8px 0 / 16px 16px,
        var(--editor-surface);
}

.editor-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.editor-image-empty .rz-icon {
    font-size: 2.4rem;
    color: var(--editor-muted);
}

.editor-image-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.editor-upload {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: 6px;
    background: var(--editor-primary);
    color: #fff;
    font-size: .85rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.editor-upload .rz-icon {
    font-size: 1.1rem;
}

.editor-upload input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

/* ---- Empty states ------------------------------------------------------ */

.editor-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--editor-muted);
    height: 100%;
}

.editor-empty .rz-icon {
    font-size: 2.6rem;
    opacity: .7;
}

.editor-empty span {
    font-size: .85rem;
    max-width: 16rem;
    line-height: 1.4;
}

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 1100px) {
    .editor-tree {
        width: 240px;
    }

    .editor-inspector {
        width: 280px;
    }

    .editor-canvas {
        padding: 1.25rem;
    }
}
