@extends('layouts.app')

@section('title', 'Bancadas do Mercado - ' . $mercado->name)

@section('content')
<div class="sinagem-main">
    <div class="s-card">
        <div class="s-card-header">
            <h4 class="s-card-title">
                <i class="fas fa-grid-3x3-gap"></i>
                Bancadas do Mercado: {{ $mercado->name }}
            </h4>
            <a href="{{ route('mercado.mercados.show', $mercado) }}" class="btn btn-outline-secondary btn-sm">
                <i class="fas fa-arrow-left"></i>
                Voltar
            </a>
        </div>

        <div class="s-card-body">
            <div class="table-responsive">
                <table class="s-table">
                    <thead>
                        <tr>
                            <th>Código</th>
                            <th>Comerciante</th>
                            <th>Status</th>
                            <th>Taxa Mensal</th>
                            <th class="text-center">Ações</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($stalls as $stall)
                            <tr>
                                <td>{{ $stall->code }}</td>
                                <td>{{ $stall->merchant->full_name ?? '-' }}</td>
                                <td>
                                    @php
                                        $statusClass = $stall->status === 'occupied' ? 'badge-warning' : ($stall->status === 'available' ? 'badge-success' : 'badge-danger');
                                        $statusText = $stall->status === 'occupied' ? 'Ocupada' : ($stall->status === 'available' ? 'Disponível' : 'Manutenção');
                                    @endphp
                                    <span class="badge {{ $statusClass }}">
                                        {{ $statusText }}
                                    </span>
                                </td>
                                <td>KZ {{ number_format($stall->monthly_fee, 2, ',', '.') }}</td>
                                <td class="text-center">
                                    <a href="{{ route('mercado.bancadas.show', $stall) }}" class="btn-action btn-view" title="Ver Detalhes">
                                        <i class="fas fa-eye"></i>
                                    </a>
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="5" class="text-center py-4">
                                    <div class="sinagem-datatable-empty">
                                        <i class="fas fa-grid-3x3-gap"></i>
                                        <h4>Nenhuma bancada cadastrada</h4>
                                        <p>Este mercado ainda não possui bancadas cadastradas.</p>
                                    </div>
                                </td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>

            @if(method_exists($stalls, 'links'))
                <div class="pagination mt-3">
                    {{ $stalls->links() }}
                </div>
            @endif
        </div>
    </div>
</div>
@endsection
