<div class="subtask-item <?php echo e($sub->is_completed ? 'is-completed' : ''); ?>" data-id="<?php echo e($sub->id); ?>" style="--depth: <?php echo e($level); ?>;" x-data="{ editing: false, collapsed: false }">
    <div class="subtask-drag-handle" title="Drag to reorder">
        <svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14"><circle cx="9" cy="5" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="9" cy="19" r="1.5"/><circle cx="15" cy="5" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="15" cy="19" r="1.5"/></svg>
    </div>

    
    <button type="button" class="subtask-check <?php echo e($sub->is_completed ? 'checked' : ''); ?>" @click="toggleComplete(<?php echo e($sub->id); ?>, $el)" aria-label="Toggle complete">
        <svg viewBox="0 0 24 24" class="subtask-check-svg">
            <circle cx="12" cy="12" r="10" class="subtask-check-circle" />
            <polyline points="8 12 11 15 16 9" class="subtask-check-mark" />
        </svg>
    </button>

    
    <div class="subtask-body">
        <div class="subtask-title-row">
            <input type="text" class="subtask-title <?php echo e($sub->is_completed ? 'done' : ''); ?>"
                   value="<?php echo e($sub->title); ?>"
                   @change="updateSubtask(<?php echo e($sub->id); ?>, 'title', $event.target.value)"
                   @focus="editing = true"
                   @blur="editing = false"
                   @keydown.enter="$el.blur()">
            
            <a href="<?php echo e(route('tasks.show', $sub->id)); ?>" class="subtask-open-btn" title="Open subtask details" @click.stop>
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
            </a>
        </div>

        <div class="subtask-details">
            
            <div class="subtask-priority-badge" data-priority="<?php echo e($sub->priority); ?>">
                <span class="subtask-priority-dot" style="background: <?php echo e($sub->priority_color); ?>;"></span>
                <select @change="updateSubtask(<?php echo e($sub->id); ?>, 'priority', $event.target.value); $el.parentElement.dataset.priority = $event.target.value" class="subtask-detail-select">
                    <?php $__currentLoopData = ['low','medium','high','urgent']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($p); ?>" <?php echo e($sub->priority == $p ? 'selected' : ''); ?>><?php echo e(ucfirst($p)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            
            <div class="subtask-assignee-wrap">
                <?php if($sub->assignee): ?>
                    <div class="subtask-assignee-avatar" title="<?php echo e($sub->assignee->name); ?>"><?php echo e($sub->assignee->initials); ?></div>
                <?php else: ?>
                    <div class="subtask-assignee-avatar unassigned" title="Unassigned">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="12" height="12"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
                    </div>
                <?php endif; ?>
                <select @change="updateSubtask(<?php echo e($sub->id); ?>, 'assignee_id', $event.target.value)" class="subtask-detail-select subtask-assignee-select">
                    <option value="">Unassigned</option>
                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($u->id); ?>" <?php echo e($sub->assignee_id == $u->id ? 'selected' : ''); ?>><?php echo e($u->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            
            <div class="subtask-due-wrap <?php echo e($sub->due_date && $sub->due_date->isPast() && !$sub->is_completed ? 'overdue' : ''); ?>">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="12" height="12"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
                <?php if($sub->due_date): ?>
                    <span class="subtask-due-text"><?php echo e($sub->due_date->format('M j')); ?></span>
                <?php endif; ?>
                <input type="date" value="<?php echo e($sub->due_date?->format('Y-m-d')); ?>" @change="updateSubtask(<?php echo e($sub->id); ?>, 'due_date', $event.target.value)" class="subtask-date-input">
            </div>

            
            <?php if(($sub->comments_count ?? 0) > 0): ?>
                <a href="<?php echo e(route('tasks.show', $sub->id)); ?>" class="subtask-indicator" title="<?php echo e($sub->comments_count); ?> comment(s)">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="12" height="12"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>
                    <span><?php echo e($sub->comments_count); ?></span>
                </a>
            <?php endif; ?>

            
            <?php if(($sub->attachments_count ?? 0) > 0): ?>
                <a href="<?php echo e(route('tasks.show', $sub->id)); ?>" class="subtask-indicator" title="<?php echo e($sub->attachments_count); ?> attachment(s)">
                    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="12" height="12"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>
                    <span><?php echo e($sub->attachments_count); ?></span>
                </a>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="subtask-actions-group">
        <?php if($sub->subtasksRecursive->count()): ?>
            <button type="button" class="subtask-action-btn" @click="collapsed = !collapsed" :title="collapsed ? 'Expand' : 'Collapse'">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14" :class="{ 'rotated': !collapsed }"><polyline points="6 9 12 15 18 9"/></svg>
            </button>
        <?php endif; ?>
        <?php if($level < 2): ?>
        <button type="button" class="subtask-action-btn" title="Add nested subtask" @click="showNestedForm(<?php echo e($sub->id); ?>)">
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
        </button>
        <?php endif; ?>
        <button type="button" class="subtask-action-btn danger" title="Delete subtask" @click="deleteSubtask(<?php echo e($sub->id); ?>, $el)">
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>
        </button>
    </div>
</div>


<?php if($sub->subtasksRecursive->count()): ?>
    <div class="subtask-children" data-parent="<?php echo e($sub->id); ?>" x-show="!collapsed" x-transition.opacity.duration.200ms>
        <?php $__currentLoopData = $sub->subtasksRecursive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $nestedSub): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php echo $__env->make('tasks.partials.subtask-item', ['sub' => $nestedSub, 'users' => $users, 'level' => $level + 1], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
<?php endif; ?>


<?php if($level < 2): ?>
<div class="subtask-nested-form" id="nested-form-<?php echo e($sub->id); ?>" style="display:none; --depth: <?php echo e($level + 1); ?>;">
    <div class="subtask-nested-form-inner">
        <input type="text" class="subtask-nested-input" placeholder="What needs to be done?" data-project="<?php echo e($sub->project_id); ?>" data-parent="<?php echo e($sub->id); ?>">
        <div class="subtask-nested-form-actions">
            <button type="button" class="btn btn-primary btn-sm" onclick="submitNestedSubtask(this)">Add</button>
            <button type="button" class="btn btn-ghost btn-sm" onclick="this.closest('.subtask-nested-form').style.display='none'">Cancel</button>
        </div>
    </div>
</div>
<?php endif; ?>
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/asana/resources/views/tasks/partials/subtask-item.blade.php ENDPATH**/ ?>