/*
 * =========================================================
 * РЕДАКТОР СХЕМЫ ТТ (вкладка между "Документы" и "Проект")
 * =========================================================
 */

.schema-editor {
    display: flex;

    gap: 16px;

    align-items: flex-start;
}


/*
 * =========================================================
 * ЛЕВАЯ ПАНЕЛЬ: палитра, инструменты, свойства
 * =========================================================
 */

.schema-sidebar {
    width: 240px;
    flex-shrink: 0;

    display: flex;
    flex-direction: column;

    gap: 14px;
}


.schema-panel {
    background: #fff;

    border: 1px solid #ccc;
    border-radius: 4px;

    padding: 10px;
}


.schema-panel-title {
    font-size: 12px;
    font-weight: bold;

    letter-spacing: .03em;
    text-transform: uppercase;

    color: #555;

    margin-bottom: 8px;
}


.schema-hint {
    font-size: 12px;
    color: #888;

    margin-bottom: 8px;

    line-height: 1.4;
}


/* подсказка под кнопками */
.schema-hint.schema-hint-after {
    margin-top: 8px;
    margin-bottom: 0;
}


/* состояние обмена схемой с хостингом */
.schema-hint.is-ok {
    color: #2e7d32;
}

.schema-hint.is-error {
    color: #b71c1c;
}


.schema-zoom-label {
    font-variant-numeric: tabular-nums;
    color: #222;
}


/*
 * Элементы палитры (перетаскиваемые)
 */

.schema-palette-item {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 6px 8px;
    margin-bottom: 6px;

    border: 1px solid #ddd;
    border-radius: 4px;

    background: #fff;

    cursor: grab;

    user-select: none;
    touch-action: none;
}


.schema-palette-item:last-child {
    margin-bottom: 0;
}


.schema-palette-item:hover {
    background: #f0f6ff;
    border-color: #2f7bd6;
}


.schema-palette-item:active {
    cursor: grabbing;
}


.schema-palette-icon {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
}


.schema-palette-label {
    font-size: 13px;
    color: #333;
}


/*
 * Настройки холста
 */

.schema-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    margin-bottom: 8px;
}


.schema-field-row:last-child {
    margin-bottom: 0;
}


.schema-field-row label,
.schema-field-row > span {
    font-size: 12px;
    color: #444;
}


.schema-field-row input[type="number"] {
    width: 64px;

    padding: 3px 5px;

    border: 1px solid #ccc;
    border-radius: 3px;

    font-size: 12px;
}


/*
 * Свойства выбранного элемента
 */

.schema-props-empty {
    font-size: 12px;
    color: #999;
}


.schema-props-type {
    font-size: 13px;
    font-weight: bold;

    color: #222;

    margin-bottom: 8px;
}


.schema-props-field {
    margin-bottom: 8px;
}


.schema-props-field:last-of-type {
    margin-bottom: 0;
}


.schema-props-field label {
    display: block;

    font-size: 11px;
    color: #666;

    margin-bottom: 3px;
}


.schema-props-field input[type="text"],
.schema-props-field input[type="number"] {
    width: 100%;

    box-sizing: border-box;

    padding: 5px 6px;

    border: 1px solid #ccc;
    border-radius: 3px;

    font-size: 13px;
}


.schema-props-row {
    display: flex;

    gap: 6px;
}


.schema-props-row button {
    flex: 1;

    padding: 5px 4px;

    border: 1px solid #ccc;
    border-radius: 3px;

    background: #f5f5f5;

    font-size: 12px;

    cursor: pointer;
}


.schema-props-row button:hover {
    background: #e9e9e9;
}


.schema-props-row button.active {
    background: #2f7bd6;
    border-color: #2f7bd6;

    color: #fff;
}


.schema-props-actions {
    display: flex;

    gap: 6px;

    margin-top: 12px;
}


.schema-props-actions button {
    flex: 1;

    padding: 6px 4px;

    border: 1px solid #ccc;
    border-radius: 3px;

    font-size: 12px;

    cursor: pointer;

    background: #f5f5f5;
}


.schema-props-actions button:hover {
    background: #e9e9e9;
}


#propDelete {
    color: #b71c1c;

    border-color: #e3a0a0;
    background: #fdf1f1;
}


#propDelete:hover {
    background: #fbe1e1;
}


/*
 * Кнопки экспорта / очистки
 */

.schema-panel button.schema-btn {
    display: block;
    width: 100%;

    padding: 8px 6px;
    margin-bottom: 6px;

    border: 1px solid #2f7bd6;
    border-radius: 4px;

    background: #2f7bd6;
    color: #fff;

    font-size: 13px;

    cursor: pointer;
}


.schema-panel button.schema-btn:last-child {
    margin-bottom: 0;
}


.schema-panel button.schema-btn:hover {
    background: #2566bd;
}


.schema-panel button.schema-btn-outline {
    background: #fff;
    color: #2f7bd6;
}


.schema-panel button.schema-btn-outline:hover {
    background: #f0f6ff;
}


.schema-panel button.schema-btn-secondary {
    background: #fff;
    color: #b71c1c;

    border-color: #e3a0a0;
}


.schema-panel button.schema-btn-secondary:hover {
    background: #fdf1f1;
}


/*
 * =========================================================
 * ХОЛСТ
 * =========================================================
 */

/*
 * Окно редактора: бесконечный холст двигается под ним, а границей
 * итоговой картинки PNG/JPEG служит само окно. Высоту окончательно
 * задаёт скрипт (до низа страницы); здесь — запасное значение.
 */

.schema-canvas-wrap {
    position: relative;

    flex: 0 1 auto;

    width: 900px;
    height: 600px;

    min-width: 300px;
    min-height: 300px;

    max-width: none;
    max-height: none;

    box-sizing: border-box;

    overflow: hidden;

    border: 1px solid #ccc;
    border-radius: 4px;

    background: #ffffff;
}
.schema-svg {
    display: block;

    width: 100%;
    height: 100%;

    background: #ffffff;

    cursor: grab;

    user-select: none;
    -webkit-user-select: none;

    /* жесты (сдвиг/масштаб) обрабатывает скрипт, а не браузер */
    touch-action: none;
}
/* =====================================================
   ИЗМЕНЕНИЕ РАЗМЕРА ОКНА СХЕМЫ
   ===================================================== */

/* =====================================================
   РУЧКИ ИЗМЕНЕНИЯ РАЗМЕРА ОКНА СХЕМЫ
   ===================================================== */

.schema-resize-right {
    position: absolute;
    top: 50%;
    right: 0;

    width: 6px;
    height: 50%;

    transform: translateY(-50%);

    background: #2196f3;
    border-radius: 5px 0 0 5px;

    cursor: ew-resize;
    z-index: 20;

    opacity: 0.9;
}

.schema-resize-right:hover {
    width: 11px;
    background: #1976d2;
}


/* Нижняя ручка */

.schema-resize-bottom {
    position: absolute;
    left: 50%;
    bottom: 0;

    width: 50%;
    height: 6px;

    transform: translateX(-50%);

    background: #2196f3;
    border-radius: 5px 5px 0 0;

    cursor: ns-resize;
    z-index: 20;

    opacity: 0.9;
}

.schema-resize-bottom:hover {
    height: 11px;
    background: #1976d2;
}


/* Нижний правый угол */

.schema-resize-corner {
    position: absolute;
    right: 0;
    bottom: 0;

    width: 27px;
    height: 27px;

    background: #2196f3;

    clip-path: polygon(
        100% 0,
        100% 100%,
        0 100%
    );

    cursor: nwse-resize;
    z-index: 21;

    opacity: 0.95;
}

.schema-resize-corner:hover {
    background: #1976d2;
}
.schema-svg.is-panning {
    cursor: grabbing;
}


.schema-el {
    cursor: move;
}


.schema-el text {
    cursor: text;
}


/*
 * Поле ввода текста, которое открывается поверх элемента
 * "Текст" по двойному клику (позиция и размер — из JS).
 */
.schema-text-editor {
    position: absolute;
    z-index: 5;

    box-sizing: content-box;

    margin: 0;
    padding: 0 3px;

    border: 1px solid #2f7bd6;
    border-radius: 0;

    background: #ffffff;
    color: #000000;

    font-family: Arial, sans-serif;

    outline: none;
}


.schema-selection-outline {
    fill: none;

    stroke: #2f7bd6;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;

    pointer-events: none;
}


/*
 * Подсказки зон взаимодействия у выделенного элемента.
 * Сами не кликабельны (pointer-events: none) — клик всегда
 * обрабатывает сам элемент под ними, в зависимости от того,
 * в какую зону (центр / поворот / кончик) попал курсор.
 */

.schema-hint-resize {
    fill: #2f7bd6;
    stroke: #fff;
    stroke-width: 1;

    pointer-events: none;
}


.schema-hint-move {
    fill: #ff9800;
    stroke: #fff;
    stroke-width: 1;

    pointer-events: none;
}


.schema-hint-move-ring {
    fill: none;
    stroke: #ff9800;
    stroke-width: 1.2;
    stroke-dasharray: 3 3;

    pointer-events: none;
}


/*
 * "Призрак" перетаскиваемого из палитры элемента
 */

.schema-drag-ghost {
    position: fixed;

    z-index: 9999;

    transform: translate(-50%, -50%);

    background: #2f7bd6;
    color: #fff;

    padding: 4px 10px;

    border-radius: 4px;

    font-size: 12px;

    pointer-events: none;

    opacity: .92;

    white-space: nowrap;
}


/*
 * Выделенные элементы окрашиваются (исходные цвета заданы
 * атрибутами, CSS их перекрывает; при снятии выделения
 * класс убирается и цвет возвращается).
 */
.schema-el.is-selected [stroke]:not([stroke="none"]) {
    stroke: #e8590c;
}

.schema-el.is-selected [fill="#000"],
.schema-el.is-selected [fill="#000000"] {
    fill: #e8590c;
}

/* рамка выделения мышью */
.schema-marquee {
    fill: rgba(47, 123, 214, 0.12);
    stroke: #2f7bd6;
    stroke-width: 1;
    stroke-dasharray: 4 3;

    pointer-events: none;
}


/*
 * Свойства элемента — отдельное плавающее окно: появляется при
 * выделении, скрывается, когда выделения нет; таскается за заголовок.
 */
.schema-props-window {
    display: none;

    position: fixed;
    z-index: 1000;

    width: 240px;
    max-height: 85vh;
    overflow: auto;
    box-sizing: border-box;

    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
}

.schema-props-window.is-visible {
    display: block;
}

.schema-props-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    cursor: move;
    user-select: none;
    touch-action: none;
}

.schema-panel button.schema-props-close {
    width: 22px;
    height: 22px;
    padding: 0;

    line-height: 1;
    font-size: 16px;

    border: none;
    background: transparent;
    color: #777;
    cursor: pointer;
}

.schema-panel button.schema-props-close:hover {
    color: #c62828;
}


/* кнопки «Отмена» / «Вперёд» в блоке «Элементы» */
.schema-history-row {
    display: flex;
    gap: 6px;

    margin-bottom: 8px;
}

.schema-history-row button {
    padding: 2px 8px;

    border: 1px solid #ccc;
    border-radius: 3px;

    background: #f5f5f5;

    font-size: 12px;
    line-height: 1.5;

    cursor: pointer;
}

.schema-history-row button:hover:not(:disabled) {
    background: #e9e9e9;
}

.schema-history-row button:disabled {
    opacity: 0.4;
    cursor: default;
}


/*
 * =========================================================
 * Панель «Устройство» (конструктор устройств)
 * =========================================================
 */

.schema-field-col {
    display: flex;
    flex-direction: column;
    gap: 3px;

    margin-bottom: 8px;
}

.schema-field-col label {
    font-size: 12px;
    color: #444;
}

.schema-text-input {
    width: 100%;
    box-sizing: border-box;

    padding: 5px 7px;

    border: 1px solid #ccc;
    border-radius: 3px;

    font-size: 12px;
    font-family: inherit;

    background: #fff;
}

.schema-text-input:focus {
    outline: none;
    border-color: #4a7bd1;
}

textarea.schema-text-input {
    resize: vertical;
    margin-bottom: 8px;
}

select.schema-text-input {
    margin-bottom: 8px;
}

.schema-panel-subtitle {
    margin: 12px 0 6px;

    font-size: 12px;
    font-weight: bold;
    color: #555;
}
