/* Улучшенные стили для портов и соединений */

/* Точки (порты) */
.port,
.input-port,
.output-port {
    width: 16px;
    height: 16px;
    border: 2px solid #444;
    border-radius: 50%;
    position: absolute;
    transition: all 0.2s ease;
    z-index: 100 !important;
    cursor: pointer;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.input-port {
    background-color: #4477ff;
    /* Синий для входа */
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.output-port {
    background-color: #888888;
    /* Серый для выхода */
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.port.connected,
.input-port.connected,
.output-port.connected {
    background-color: #44dd44 !important;
    /* Зелёный, если подключён */
}

/* Контейнеры портов */
.ports-container,
.audio-ports-container,
.video-ports-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 10 !important;
    pointer-events: none;
    display: block !important;
    visibility: visible !important;
}

/* SVG для стрелок */
.connection-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.connection-line {
    stroke-dasharray: 10 10;
    animation: dash 1s linear infinite;
    stroke: #666;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
}

@keyframes dash {
    to {
        stroke-dashoffset: -20;
    }
}

/* Подписи (лейблы) */
.connection-control {
    position: absolute;
    background: white;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 8px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    pointer-events: auto;
}

.connection-control .direction-text {
    color: #666;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.connection-control .delete-btn {
    color: #ff4444;
    font-weight: bold;
    padding: 0 4px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    background: none;
    font-size: 14px;
}

.connection-control .delete-btn:hover {
    background: #ffeeee;
}

/* Состояния портов при взаимодействии */
.port:hover,
.input-port:hover,
.output-port:hover {
    box-shadow: 0 0 8px rgba(0, 0, 255, 0.8);
    transform: translateY(-50%) scale(1.2);
}

.port.active,
.input-port.active,
.output-port.active {
    background-color: #ff0000 !important;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
}

/* Временное соединение при перетаскивании */
.temp-connection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Ошибки при соединении */
.error-popup {
    position: absolute;
    background: white;
    border: 1px solid #ff4444;
    border-radius: 4px;
    padding: 8px 32px 8px 12px;
    font-size: 12px;
    color: #ff4444;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    max-width: 250px;
}

.error-popup .close-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: #ff4444;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}