/*
 * Text editing of a rendered document
 * Правка текста отрисованного документа
 *
 * AiInstruction-DocTextEdit. Общий для страницы разметки (правка
 * администратора, этап 3) и страницы заполнения (правка пользователя,
 * этап 5): редактор один и тот же, и выглядеть он обязан одинаково.
 * Цвета — значения токенов constructor-form.css: страница заполнения
 * токенов страницы разметки не видит.
 */
:is(.docx-markup-document, .docx-fill-document) [data-te-editable] {
    outline: none;
    cursor: text;
    border-radius: 2px;
}

    :is(.docx-markup-document, .docx-fill-document) [data-te-editable]:hover {
        box-shadow: 0 0 0 2px #e7f1fb;
    }

    :is(.docx-markup-document, .docx-fill-document) [data-te-editable]:focus {
        box-shadow: 0 0 0 2px #b6d4fe;
        background: #fbfdff;
    }

/* Место разметки в правке: видно, что оно не текст документа, а поле формы. */
:is(.docx-markup-document, .docx-fill-document) .te-place {
    background: #e7f1fb;
    border-bottom: 1px dashed #1391e5;
    cursor: default;
}

:is(.docx-markup-document, .docx-fill-document) .te-locked {
    cursor: not-allowed;
}

:is(.docx-markup-document, .docx-fill-document) .te-changed {
    box-shadow: inset 3px 0 0 #f0ad4e;
}

:is(.docx-markup-document, .docx-fill-document) .te-inserted {
    min-height: 1.2em;
    box-shadow: inset 3px 0 0 #198754;
}

:is(.docx-markup-document, .docx-fill-document) .te-deleted {
    text-decoration: line-through;
    color: #b02a37;
    opacity: .7;
    box-shadow: inset 3px 0 0 #dc3545;
}

/* Удалённый текст: только показ, в документ и в правку он не входит. */
:is(.docx-markup-document, .docx-fill-document) .te-del {
    text-decoration: line-through;
    color: #b02a37;
    background: #fbe3e5;
    user-select: none;
}

/* Вставленный текст — подсветкой CSS Custom Highlight API, без новых элементов. */
::highlight(te-ins) {
    background-color: #d1f0dc;
    color: #0f5132;
}

:is(.docx-markup-document, .docx-fill-document) .te-flash {
    animation: te-flash 1.2s ease-out;
}

@keyframes te-flash {
    from {
        background: #fff3cd;
    }
    to {
        background: transparent;
    }
}

/* Кнопки абзаца: слева от него, на поле страницы. */
:is(.docx-markup-document, .docx-fill-document) .te-tools {
    position: absolute;
    z-index: 5;
    display: flex;
    gap: 2px;
}

:is(.docx-markup-document, .docx-fill-document) .te-tool {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #dfe3e8;
    border-radius: 4px;
    background: #fff;
    color: #5d6977;
    font-size: 12px;
    line-height: 22px;
}

    :is(.docx-markup-document, .docx-fill-document) .te-tool:hover:not(:disabled) {
        color: #0b6aae;
        border-color: #1391e5;
    }

    :is(.docx-markup-document, .docx-fill-document) .te-tool:disabled {
        opacity: .4;
        cursor: not-allowed;
    }

    :is(.docx-markup-document, .docx-fill-document) .te-tool[hidden] {
        display: none;
    }

/* Панель правок справа. */
.docx-text-edit-panel {
    padding: .5rem;
}

.docx-text-edit-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docx-text-edit-item {
    display: flex;
    align-items: flex-start;
    gap: .25rem;
    padding: .375rem 0;
    border-bottom: 1px solid #dfe3e8;
}

.docx-text-edit-go {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    color: #1e2833;
    font-size: .875rem;
}

    .docx-text-edit-go:hover .docx-text-edit-kind {
        color: #0b6aae;
    }

.docx-text-edit-kind {
    display: block;
    color: #5d6977;
    font-size: .75rem;
}

.docx-text-edit-text {
    display: block;
    font-family: "Times New Roman", "Liberation Serif", "PT Serif", Georgia, serif;
    overflow-wrap: anywhere;
}

.docx-text-edit-undo {
    flex: 0 0 auto;
    padding: 0 .25rem;
    font-size: .8125rem;
}

.te-panel-del {
    color: #b02a37;
    background: #fbe3e5;
}

.te-panel-ins {
    color: #0f5132;
    background: #d1f0dc;
    text-decoration: none;
}

/* У пользователя место показывает значение из формы (Р2): видно, что это не текст договора. */
:is(.docx-markup-document, .docx-fill-document) .te-place-value {
    background: #fff3cd;
    border-bottom: 1px dashed #b8860b;
}
