/* Token-aware text editor — Components/Shared/WorkflowTokenTextEditor.razor
   The value is a Liquid string; this only changes how it is presented while authoring. */

.wf-token-editor {
    position: relative;
    display: block;
}

.wf-token-field {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 14px;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--mud-palette-text-primary, #1f1f1f);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--mud-palette-background, #fff);
    border: 1px solid var(--mud-palette-lines-inputs, rgba(0, 0, 0, 0.23));
    border-radius: 4px;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.wf-token-field:focus {
    border-color: var(--mud-palette-primary, #594ae2);
    box-shadow: 0 0 0 1px var(--mud-palette-primary, #594ae2);
}

.wf-token-field[contenteditable="false"] {
    background: var(--mud-palette-action-disabled-background, rgba(0, 0, 0, 0.04));
    cursor: default;
}

.wf-token-field.is-empty::before {
    color: var(--mud-palette-text-secondary, rgba(0, 0, 0, 0.6));
    pointer-events: none;
    content: attr(data-placeholder);
}

/* --- pills --- */

.wf-token-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 4px 1px 8px;
    margin: 0 2px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--mud-palette-primary-text, #fff);
    cursor: default;
    user-select: none;
    background: var(--mud-palette-primary, #594ae2);
    border-radius: 999px;
    vertical-align: baseline;
}

.wf-token-pill-label {
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-token-pill-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1;
    color: inherit;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.18);
    border: 0;
    border-radius: 50%;
    opacity: 0.9;
}

.wf-token-pill-x:hover {
    background: rgba(255, 255, 255, 0.4);
    opacity: 1;
}

.wf-token-field[contenteditable="false"] .wf-token-pill-x {
    display: none;
}

/* --- the data picker floats inside the field's top-right corner --- */

.wf-msg-editor {
    position: relative;
}

/* Room for the floating action, so a long line never runs underneath it. */
.wf-msg-editor .wf-token-field {
    padding-right: 46px;
}

.wf-msg-editor-action {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--mud-palette-surface, #fff);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--mud-palette-text-primary, #000) 18%, transparent);
}


/* --- rich text field (Quill) with data pills --- */

/* The toolbar is part of the field: compact, wrapping, and attached to the editor surface so the
   pair reads as one control inside the narrow inspector. */
.wf-rt-surface .ql-toolbar.ql-snow {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    padding: 3px 4px;
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary, #000) 18%, transparent);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
}

.wf-rt-surface .ql-toolbar.ql-snow .ql-formats {
    margin-right: 2px;
}

.wf-rt-surface .ql-toolbar.ql-snow button {
    width: 22px;
    height: 20px;
    padding: 2px;
}

.wf-rt-surface .ql-toolbar.ql-snow .ql-picker {
    height: 20px;
    font-size: 0.72rem;
}

.wf-rt-surface .ql-container.ql-snow {
    font-family: inherit;
    font-size: 0.82rem;
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary, #000) 18%, transparent);
    border-radius: 0 0 6px 6px;
}

.wf-rt-surface .ql-editor {
    min-height: inherit;
    padding: 8px 10px;
    line-height: 1.55;
}

.wf-rt-host {
    display: block;
}

.wf-rt-pill {
    display: inline-block;
    padding: 0 6px;
    margin: 0 1px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--mud-palette-primary-text, #fff);
    white-space: nowrap;
    vertical-align: baseline;
    background: var(--mud-palette-primary, #594ae2);
    border-radius: 999px;
    user-select: all;
}


/* --- rich-text field: the inspector is an abbreviated card, the dialog edits and previews --- */

/* Same card as the other settings. The card deliberately does not render the document: the body is
   written and previewed in the full-size editor, so the inspector only names what is stored. */
.wf-rt {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 9px 11px 10px;
    background: color-mix(in srgb, var(--mud-palette-surface, #fff) 94%, var(--mud-palette-text-primary, #000));
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary, #000) 12%, transparent);
    border-radius: 8px;
}

/* --- rich-text dialog: the editing surface --- */

.wf-rt-dialog-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    width: 100%;
    /* The dialog's close button sits in the title bar; keep the data picker clear of it. */
    padding-right: 36px;
}

.wf-rt-dialog-head .mud-typography-h6 {
    margin-right: auto;
}

/* The view switch: three plain buttons whose active state is the same field the body renders from. */
.wf-rt-views-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

/* The insert control shares the row with the views and sits at its far end. */
.wf-rt-views-insert {
    margin-left: auto;
}

.wf-rt-views-hint {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.wf-rt-views {
    display: inline-flex;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    overflow: hidden;
}

.wf-rt-view {
    padding: 5px 14px;
    border: 0;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

    .wf-rt-view + .wf-rt-view {
        border-left: 1px solid var(--mud-palette-lines-default);
    }

    .wf-rt-view:hover:not(.is-active) {
        background: var(--mud-palette-action-default-hover);
    }

    .wf-rt-view.is-active {
        background: var(--mud-palette-primary);
        color: var(--mud-palette-primary-text);
        font-weight: 600;
    }

    .wf-rt-view:focus-visible {
        outline: 2px solid var(--mud-palette-primary);
        outline-offset: -2px;
    }

.wf-rt-dialog-surface {
    display: flex;
    flex-direction: column;
}

.wf-rt-dialog-surface[hidden] {
    display: none;
}

/* The editor dialog is full screen, so the composing surface takes the window (minus the header,
   the helper line and the action row) instead of a fixed slice of it. */
.wf-rt-dialog-host {
    display: block;
    height: calc(100vh - 250px);
    min-height: 260px;
    overflow: auto;
}

.wf-rt-dialog-host .ql-editor {
    min-height: calc(100vh - 300px);
    font-size: 0.95rem;
    line-height: 1.6;
}

.wf-rt-html-source textarea {
    min-height: calc(100vh - 320px);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
}

/* A pill inside the composer is a token in running prose: it must sit on the same baseline as the
   0.95rem body text rather than shrink away from it. */
.wf-rt-dialog-host .wf-rt-pill {
    padding: 1px 8px;
    font-size: 0.78rem;
    line-height: 1.45;
}
