* { box-sizing: border-box; }
body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; font-family: 'Inter', sans-serif;
    background-color: #1a1a1a; color: #eee;
}

/* 1. Стили для Chrome, Edge, Safari */
.nodes-list::-webkit-scrollbar {
    width: 8px; /* Ширина полосы */
}
.nodes-list::-webkit-scrollbar-track {
    background: #1a1a1a; /* Цвет дорожки (фон) */
    border-radius: 0;
}
.nodes-list::-webkit-scrollbar-thumb {
    background: #444; /* Цвет самой "палки" */
    border-radius: 10px;
    border: 2px solid #1a1a1a; /* Отступ от краев дорожки */
}
.nodes-list::-webkit-scrollbar-thumb:hover {
    background: #4a90e2; /* Синий цвет при наведении (акцент) */
}
/* 2. Стили для Firefox */
.nodes-list {
    scrollbar-width: thin;
    scrollbar-color: #444 #1a1a1a; /* Цвет бегунка и дорожки */
}

.row{
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-content: center;
    align-items: center;
    justify-content: center;
    gap: 10px;
}



.app-container { display: flex; width: 100vw; height: 100vh; }

.main-path{
    z-index: 1;
}

#storage{
    background-color: rgb(89, 89, 255);
    color: #b2b2b2; 
    border-radius: 3px; 
    padding: 2px 5px; 
    font-weight: bold;
    text-align: center;
}

/* Сайтбар */
.app-container {
    display: flex; /* Сайдбар и контент в ряд */
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #252525;
    border-right: 1px solid #444;
}
.sidebar-header { 
    padding: 20px; 
    border-bottom: 
    1px solid #333; 
}
/* Правая часть: вкладки сверху, холст под ними */
.main-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative; /* Для позиционирования миникарты */
    background: #1a1a1a;
}

.nodes-list {
    flex: 1;
    overflow-y: auto; /* Прокрутка обязательна */
    padding: 15px;
}
.nodes-list small {
    display: block;
    color: #666;
    font-size: 10px;
    font-weight: bold;
    margin: 20px 0 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}



/* Общий контейнер, где все вкладки наложены друг на друга */
.drawflow-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 100px); /* Убедись, что высота задана! */
    overflow: hidden;
}
.drawflow-tab .drawflow {
    position: absolute !important;
    inset: 0 !important; /* Растягивает блок на 100% высоты и ширины родителя */
    width: auto !important;
    height: auto !important;
}
/* Базовые свойства для абсолютно всех вкладок */
.drawflow-tab {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    /* Скрываем вкладку полностью */
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important; /* Чтобы по скрытым нодам нельзя было кликнуть */
    z-index: 1 !important;
    transition: opacity 0.15s ease;
}
/* АКТИВНАЯ ВКЛАДКА (Перебивает скрытие) */
.drawflow-tab.active {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* Возвращаем кликабельность */
    z-index: 5 !important; /* Поднимаем слой выше всех остальных */
}



/* Перебиваем дефолтный синий цвет Drawflow */
.drawflow .connection path {
    stroke-width: 3px;
}

/* Контейнер для вкладок */
.tabs-container {
    display: flex;
    flex-direction: row;
    padding: 10px 15px 0 15px;
    background: #252525;
    gap: 4px;
    border-bottom: 1px solid #444;
    height: 60px;
}

.tab-edit-input {
    background: #fff;
    border: 1px solid #4facfe;
    border-radius: 4px;
    color: #333;
    font-size: inherit;
    padding: 2px 5px;
    width: 100px;
    outline: none;
}

.tab-btn {
padding: 10px 20px;
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: right;
    gap: 10px;
    position: relative;
    flex-direction: row-reverse;
    flex-wrap: nowrap;
    align-content: flex-start;
    justify-content: right;
}

.tab-btn.active {
    background: #4a90e2; /* Твой синий цвет */
    color: white;
    border-color: #4a90e2;
}

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    position: absolute;
    font-size: 16px;
    line-height: 1;
    top:-4px;
    right:-4px;
    color: rgba(255,255,255,0.4);
    transition: all 0.2s;
}

.tab-close:hover {
    background: rgba(255,255,255,0.2);
    color: #ff4d4d;
}

/* Скрываем крестик на главной, если нужно */
.tab-btn:first-child .tab-close {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
}




.drag-item {
    background: #333; padding: 12px; margin-bottom: 8px;
    border-radius: 6px; cursor: grab; font-size: 13px; border: 1px solid transparent;
}
.drag-item:hover { border-color: #555; background: #3d3d3d; }
.search-input { width: 100%; padding: 8px; background: #111; border: 1px solid #444; color: #fff; border-radius: 4px; }

/* Холст */
#drawflow {
    flex-grow: 1; 
    background-size: 25px 25px;
    background-image: 
    radial-gradient(#333 1px, transparent 1px);
    width: 100%;
    height: 100%;
    background: #121212;
}
.drawflow .drawflow-node {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 360px !important;
}

/* Блоки внутри */
.node-custom {
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); /* Добавим тени вместо рамок */
}

/* Подсветка активного блока */
.drawflow .drawflow-node.selected .node-custom {
    border-color: #4a90e2;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.4);
    transform: scale(1.02);
}





/* Наш заголовок с новым именем */






/* Стилизация самих точек выходов (портов) */
.drawflow-node .outputs .output:nth-child(1) { background: #4caf50; }
.drawflow-node .outputs .output:nth-child(2) { background: #f44336; }
.drawflow-node .outputs .output:nth-child(3) { background: #3498db; }










/* Поле для подробных заметок */




/* Кнопки и модалка */
.sidebar-footer { padding: 15px; gap: 10px; display: flex; flex-direction: column; }
.btn-primary { background: #27ae60; color: white; border: none; padding: 12px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-clear {
    background: #c0392b;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    z-index: 20; /* Чтобы была поверх холста */
}
.modal { 
    display: none; 
    position: fixed; 
    top:0; 
    left:0; 
    width:100%; 
    height:100%; 
    background: rgba(0,0,0,0.8); 
    z-index: 1000; 
}
.modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 600px; background: #252525; padding: 25px; border-radius: 12px; }
.modal-content textarea { width: 100%; height: 300px; background: #111; color: #ccc; border: 1px solid #333; padding: 15px; border-radius: 6px; resize: none; margin-top: 10px; }


/* Кнопка возврата */
.btn-back {
    position: absolute;
    top: 20px;
    left: 300px;
    z-index: 100;
    padding: 10px 20px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Стикер */
.node-sticky {
    background: #f1c40f;
    padding: 10px;
    border-radius: 4px;
}
.node-sticky textarea {
    background: transparent;
    border: none;
    width: 100%;
    color: #333;
    resize: none;
}



.node-group-frame {
    /*width: 300px;
    height: 200px;*/
    border: 2px dashed #666;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    position: relative;
    min-width: 150px;
    min-height: 100px;
    pointer-events: all;
    display: block;
    overflow: visible;
    z-index: 1;
}
.resizer-corner {
    width: 20px; /* Увеличим для удобства */
    height: 20px;
    background: #4a90e2;
    position: absolute;
    border-radius: 20px 0 6px 0;
    /* Сдвигаем строго в угол, можно даже на -2px, чтобы выйти за рамки контейнера */
    right: 0px; 
    bottom: 0px;
    
    cursor: nwse-resize !important;
    z-index: 2; /* Максимальный приоритет */
    
    /* Отключаем любые стандартные события на этом элементе для библиотеки */
    pointer-events: all !important;
}
/* Отключаем стандартные ограничения библиотеки для группы */
.drawflow-node.group {
    width: auto !important;
    height: auto !important;
}
/* Гарантируем, что родитель не обрезает наш уголок */
.drawflow-node.group-node {
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
    min-width: 50px;
    min-height: 50px;
    z-index:-100;
}
/* Сделаем уголок ресайза заметным */
.node-group-frame::-webkit-resizer {
    background-image: linear-gradient(135deg, transparent 50%, #4a90e2 50%);
    width: 15px;
    height: 15px;
}
.group-label {
    background: #444;
    color: #fff;
    border: none;
    padding: 2px 10px;
    font-size: 11px;
    position: absolute;
    top: 2px;
    left: 2px;
}
/* Чтобы рамка была всегда ПОД блоками */
.drawflow-node.node-group {
    z-index: 1 !important;
    width: auto !important;
    height: auto !important;
    min-width: 100px;
    min-height: 100px;
}



.node-coords-display {
    font-size: 9px;
    color: #00ff00; /* Яркий цвет для контроля */
    font-family: monospace;
    margin-left: 10px;
    background: rgba(0,0,0,0.3);
    padding: 1px 4px;
    border-radius: 3px;
}


/* Контейнер рамки */
.node-group-frame {
    width: 300px;
    height: 200px;
    border: 2px dashed #666;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    position: relative;
    
    /* ВКЛЮЧАЕМ РЕСАЙЗ */
    overflow: auto; /* Обязательно для работы resize */
    min-width: 100px;
    min-height: 100px;
}

/* Настройка самого уголка (ресайзера) */
.node-group-frame::-webkit-resizer {
    background-color: #4a90e2;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Фикс для Drawflow: чтобы линии пересчитывались при изменении размера */
.drawflow-node.node-group {
    width: auto !important;
    height: auto !important;
}








/* Мини-карта */
#minimap-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: #eaeaea; /* Сделаем чуть серее, чтобы видеть границы карты */
    border: 1px solid #aaa;
    border-radius: 4px;
    z-index: 100;
    overflow: hidden; /* <--- ОБЯЗАТЕЛЬНО: обрезает всё, что вылазит */
}

.minimap-viewport {
    position: absolute;
    border: 2px solid #007bff;
    background: rgba(0, 123, 255, 0.15);
    pointer-events: none;
    box-sizing: border-box; /* <--- ОБЯЗАТЕЛЬНО: чтобы бордеры не увеличивали размер */
}

.minimap-node {
    position: absolute;
    background: #333;
    opacity: 0.8;
    border-radius: 2px;
}

/* Кнопки в сайдбаре */
.sidebar-footer {
    padding: 10px;
    gap: 8px;
    display: flex;
    flex-direction: column;
}

/* Групповое выделение (Пункт 2.2) */
.drawflow .drawflow-node.selected {
    box-shadow: 0 0 0 2px #4a90e2;
}







.debug-box {
    position: fixed;
    pointer-events: none; /* Чтобы не мешал кликам */
    background: rgba(0, 0, 0, 0.7);
    color: #00ff00; /* Зеленый "хакерский" цвет */
    padding: 8px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    z-index: 10000;
    white-space: nowrap;
    border: 1px solid #00ff00;
}




























.modal-overlay {
    display: none; /* Скрыто по умолчанию */
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999; /* Поверх всего */
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1e1e1e; /* Темная тема для кода */
    color: #d4d4d4;
    width: 90%; height: 90%;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.modal-actions { display: flex; gap: 10px; }

#codeOutput {
    padding: 20px;
    margin: 0;
    overflow: auto;
    flex-grow: 1;
    font-family: 'Consolas', 'Monaco', monospace;
    line-height: 1.5;
    white-space: pre-wrap;
}

.btn-copy, .btn-close {
    cursor: pointer;
    border: none; padding: 8px 15px; border-radius: 4px;
    font-weight: bold; transition: 0.3s;
}

.btn-copy { background: #27ae60; color: white; }
.btn-copy:hover { background: #2ecc71; }

.btn-close { background: #e74c3c; color: white; }
.btn-close:hover { background: #c0392b; }
