body {
    overflow: hidden;
    height: 100vh;
}

.split-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

.left-panel, .right-panel{
    width: 15%;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    min-width: 100px;
}

.viewport {
    flex: 1;
    background: #e9ecef;
    min-width: 150px;
}

.gutter-h {
    cursor: row-resize;
    height: 10px;
    flex-shrink: 0;
}

.gutter-w {
    cursor: col-resize;
    width: 10px;
    flex-shrink: 0;
}

.gutter-w:hover, .gutter-h:hover {
    background-color: #0d6efd;
}

/* стили для левой панели */
.left-panel .top-block,
.left-panel .bottom-block {
    display: flex;
    background: #ced4da;
    padding: 12px;
    border-radius: 6px;
}

.bottom-block {
    flex: 1;
    min-height: 60px;
}

.top-block {
    height: 90%;
}

.left-panel .top-block {
    background: #adb5bd;
}

.left-panel .bottom-block {
    background: #6c757d;
    color: white;
}

/* Защита панелей от схлопывания при нехватке высоты */
.left-panel > .top-block,
.left-panel > .bottom-block,
.right-panel > .top-block,
.right-panel > .bottom-block {
    min-height: 60px;
}

/* правая панель */
.catalog {
    background: #adb5bd;
    padding: 12px;
    border-radius: 6px;
}

.properties {
    background: #6c757d;
    color: white;
    padding: 12px;
    border-radius: 6px;
}

/* стили элементов каталога */
.catalog-item {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.15s;
    border-radius: 4px;
}

.catalog-item:active {
    cursor: grabbing;
}

.catalog-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.catalog-item.active {
    background-color: #0d6efd;
}

.catalog-item.is-selected, .tree-label.is-selected {
    background-color: #0d6efd;
    /*color: #fff;*/
}

.catalog-item__thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Перетаскивание элементов каталога */
.catalog-item.dragging {
    opacity: 0.5;
    border: 1px dashed #0d6efd;
}
.catalog-item.drag-over {
    border-top: 2px solid #0d6efd;
    background: rgba(13, 110, 253, 0.15);
}
.catalog-item[draggable="true"] {
    cursor: grab;
}


/* стили механики дерева */
.tree-children :is(ul, li) {
    list-style: none;
    padding-left: 0;
}

.tree-children {
    margin-left: 25px;
    display: none;
    list-style: none;
    padding-left: 20px;
}

.tree-children.open {
    display: block;
}

.tree-checkbox {
    display: none;
}

.tree-label {
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
    margin: 2px 0;
}

.tree-label:hover {
    background-color: #f8f9fa;
}

.tree-checkbox:checked ~ .tree-children {
    display: block;
}

.toggle-icon {
    margin-right: 8px;
}

.tree-checkbox:checked + .tree-label .toggle-icon .icon-caret-right {
    display: none;
}

.tree-checkbox:checked + .tree-label .toggle-icon .icon-caret-down {
    display: inline;
}

.tree-label .toggle-icon .icon-caret-down {
    display: none;
}

#help-content {
    font-size: 12px;
    line-height: 1.5;
}

#help-content ul {
    padding-left: 18px;
    margin-bottom: 6px;
}

#help-content h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 8px 0 4px;
}

#help-content li {
    margin-bottom: 2px;
}

#next-content {
    font-size: 12px;
    line-height: 1.5;
}

#next-content h5 {
    font-size: 13px;
    font-weight: 600;
    margin: 8px 0 4px;
}

.next-item {
    padding: 1px 0;
}

/* ========== КНОПКИ ПОВЕРХ СЦЕНЫ ========== */
.viewport {
    position: relative;
}
.viewport-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.viewport-btn {
    white-space: nowrap;
    font-size: 0.75rem;
}
.viewport-btn.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}
.viewport-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Активное состояние кнопки "Размеры труб" в левой панели */
#pipe-dim-btn.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

/* Компактные кнопки undo/redo поверх сцены */
.undo-redo-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
}
.undo-redo-btn:disabled {
    opacity: 0.35;
}
.undo-redo-btn:not(:disabled):hover {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
.undo-redo-btn:not(:disabled):active {
    transform: scale(0.94);
}

/* ========== ПОДАВЛЕНИЕ СКРОЛЛА ПРИ ПЕРЕТАСКИВАНИИ ИЗ КАТАЛОГА ========== */
body.catalog-drag-active {
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}
.catalog__list.catalog__list {
    overflow: auto !important;
}
body.catalog-drag-active .catalog__list,
body.catalog-drag-active .catalog__list.catalog__list {
    overflow: hidden !important;
    pointer-events: none;
}
body.catalog-drag-active * {
    cursor: grabbing !important;
}

/* ========== МОБИЛЬНАЯ ВЕРСИЯ ========== */
@media (max-width: 900px) {
    .right-panel {
        display: none !important;
    }

    .left-panel {
        width: 27%;
    }
    .left-panel .bottom-block {
        display: none !important;
    }
    .left-panel .top-block {
        height: 100% !important;
    }
}

/* ========== ПОДСВЕТКА СЛОЯ МОДЕЛИ (редактор каталога) ========== */
.layer-item {
    cursor: pointer;
    border-radius: 4px;
    padding-left: 4px;
    padding-right: 4px;
    transition: background-color .15s;
}
.layer-item:hover {
    background: rgba(0, 0, 0, 0.04);
}
.layer-item.layer-highlighted {
    background: rgba(251, 191, 36, 0.25);
    box-shadow: inset 3px 0 0 #fbbf24;
}

/* ========== РАМКА ВЫДЕЛЕНИЯ (Shift+ЛКМ по пустому месту) ========== */
#selection-box {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    background: rgba(13, 110, 253, 0.12);
    border: 1px solid #0d6efd;
    display: none;
}

/* ========== ПАНЕЛЬ СВОЙСТВ ФИТИНГА (нижний блок левой панели) ========== */
.properties-panel {
    padding: 8px 10px;
    font-size: 0.8rem;
}
.properties-panel__title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
    word-break: break-word;
}
.properties-panel__kind {
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 2px;
}
.properties-panel__subtitle {
    font-weight: 600;
    margin-top: 6px;
    margin-bottom: 4px;
}
.properties-panel__label {
    font-size: 0.7rem;
    margin-bottom: 1px;
    line-height: 1.2;
}
.properties-panel__port {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.02);
}
.properties-panel__port-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0;
    margin-bottom: 6px;
    width: 100%;
}
.properties-panel__table {
    font-size: 0.7rem;
    margin-bottom: 4px;
}
.properties-panel__placeholder {
    color: var(--bs-secondary-color, #6c757d);
    font-style: italic;
    text-align: center;
    font-size: 0.8rem;
    padding: 8px;
    margin: 0;
}

