* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebars */
.sidebar {
    width: 300px;
    background: white;
    padding: 1rem;
    border-right: 1px solid #ddd;
    overflow-y: auto;
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid #ddd;
}

.sidebar h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

/* Block Templates */
.block-templates {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.block-template {
    padding: 0.75rem;
    background: #ecf0f1;
    border: 2px dashed #bdc3c7;
    border-radius: 6px;
    cursor: grab;
    text-align: center;
    transition: all 0.3s ease;
}

.block-template:hover {
    background: #d5dbdb;
    border-color: #95a5a6;
}

/* Canvas */
.canvas-container {
    flex: 1;
    background: #f8f9fa;
    position: relative;
}

#network {
    width: 100%;
    height: 100%;
    border: 1px solid #ddd;
}

/* Stats Panel */
.stats-panel {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-top: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

.stat-item:not(:last-child) {
    border-bottom: 1px solid #e9ecef;
}

/* Properties Panel */
.properties-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.no-selection {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
}

.form-control {
    padding: 0.5rem;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
}

.slider {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Inputs/Outputs */
.io-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.io-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.io-item input {
    flex: 1;
}

.remove-io {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tables Panel */
.tables-panel {
    height: 300px;
    background: white;
    border-top: 1px solid #ddd;
}

.tabs {
    display: flex;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-button.active {
    background: white;
    border-bottom-color: #3498db;
    font-weight: 600;
}

.tab-content {
    padding: 1rem;
    height: calc(100% - 50px);
    overflow-y: auto;
}

.tab-pane {
    display: none;
    height: 100%;
}

.tab-pane.active {
    display: block;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Problems List */
.problem-item {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
    background: #fdf2f2;
}

.problem-item.high-risk {
    border-left-color: #e74c3c;
    background: #fdf2f2;
}

.problem-item.high-labor {
    border-left-color: #f39c12;
    background: #fef9f3;
}

.problem-item.low-auto {
    border-left-color: #3498db;
    background: #f0f8ff;
}

/* Network node styling */
.vis-network {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Custom node styles based on metrics */
.node-high-risk {
    border: 3px solid #e74c3c !important;
}

.node-high-labor {
    background-color: #fef9f3 !important;
}

.node-low-auto {
    opacity: 0.8;
}

/* Connection controls */
.connection-controls {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.connection-status {
    display: none;
    background: #991b1b;
    border: 1px solid #ea580c;
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    text-align: center;
    font-weight: 600;
}

.btn.active {
    background: #27ae60;
    color: white;
}

.connection-info {
    background: #ecf0f1;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.connection-label {
    font-weight: 600;
    color: #2c3e50;
}

/* Edge styling */
.vis-edge .vis-label {
    background: white;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #bdc3c7;
}

.selected-row {
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3;
}

.selected-row td {
    font-weight: 600;
}

.data-table tr:hover {
    background-color: #f5f5f5;
    cursor: pointer;
}

.data-table tr.selected-row:hover {
    background-color: #e3f2fd;
}

/* Resizable panels */
/* Resize handles */
.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.resize-handle-x {
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
}

.resize-handle-y {
    left: 0;
    right: 0;
    height: 8px;
    cursor: row-resize;
}

.resize-handle-right {
    right: -4px;
}

.resize-handle-left {
    left: -4px;
}

.resize-handle-top {
    top: -4px;
}

/* Hover effects */
.resize-handle-x:hover,
.resizing .resize-handle-x {
    background: rgba(52, 152, 219, 0.5);
}

.resize-handle-y:hover,
.resizing .resize-handle-y {
    background: rgba(52, 152, 219, 0.5);
}

/* Disable text selection during resize */
.resizing {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Prevent network flickering during resize */
.resizing #network,
.resizing-vertical #network {
    pointer-events: none;
}

/* Update existing styles */
.right-sidebar {
    border-right: none;
    border-left: 1px solid #ddd;
    position: relative;
    min-width: 50px; /* Уменьшаем минимальную ширину */
    max-width: calc(100vw - 100px); /* Увеличиваем максимальную ширину */
    width: 300px; /* Начальная ширина */
}

.tables-panel {
    height: 300px;
    background: white;
    border-top: 1px solid #ddd;
    position: relative;
    min-height: 50px; /* Уменьшаем минимальную высоту */
    max-height: calc(100vh - 60px); /* Увеличиваем максимальную высоту */
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: 300px;
    background: white;
    padding: 1rem;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    position: relative;
    min-width: 50px; /* Уменьшаем минимальную ширину */
    max-width: calc(100vw - 100px); /* Увеличиваем максимальную ширину */
}

/* Добавляем стиль для отключения взаимодействия во время ресайза */
body.resizing {
    cursor: col-resize !important;
}

body.resizing-vertical {
    cursor: row-resize !important;
}

#takeScreenshot:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#takeScreenshot:disabled:hover {
    background: #95a5a6;
}
