{{-- resources/views/accounting/partials/account-tree-row.blade.php --}}
@php
    $account = $node['account'];
    $children = $node['children'];
    $level = $node['level'] ?? 0;
@endphp

<tr style="background-color: {{ $level === 0 ? '#f8f9fa' : 'white' }}">
    <td>
        <span style="margin-left: {{ $level * 20 }}px;">
            @if($level > 0)
                <i class="fas fa-level-down-alt fa-rotate-90 text-muted me-2" style="font-size: 0.8rem;"></i>
            @endif
            <strong>{{ $account->code }}</strong>
        </span>
    </td>
    <td>{{ $account->name }}</td>
    <td>
        <span class="badge bg-{{ $account->account_type === 'P' ? 'primary' : 'secondary' }}">
            {{ $account->account_type === 'P' ? 'Posting' : 'Header' }}
        </span>
    </td>
    <td>{{ $account->category ?? 'N/A' }}</td>
    <td class="fw-bold">{{ number_format($account->balance) }}</td>
    <td>
        <span class="badge bg-{{ $account->is_active ? 'success' : 'secondary' }}">
            {{ $account->is_active ? 'Active' : 'Inactive' }}
        </span>
    </td>
    <td>
        <button class="btn btn-sm btn-outline-info" onclick="viewAccount({{ $account->id }})" title="View">
            <i class="fas fa-eye"></i>
        </button>
        <button class="btn btn-sm btn-outline-primary" onclick="openAccountModal({{ $account->id }})" title="Edit">
            <i class="fas fa-edit"></i>
        </button>
        <button class="btn btn-sm btn-outline-danger" onclick="deleteAccount({{ $account->id }})" title="Delete">
            <i class="fas fa-trash"></i>
        </button>
    </td>
</tr>

@foreach($children as $child)
    @include('accounting.partials.account-tree-row', ['node' => $child, 'level' => $level + 1])
@endforeach