<div class="row g-3">
    <div class="col-lg-4">
        <div class="card border-0 shadow-sm">
            <div class="card-body">
                <h2 class="h6 mb-3">Nuevo proveedor</h2>
                <form action="<?= e(url('proveedores')) ?>" method="post">
                    <?= csrf_field() ?>
                    <div class="mb-2">
                        <label class="form-label">Nombre</label>
                        <input class="form-control" name="nombre" value="<?= e(old('nombre', '')) ?>" required>
                    </div>
                    <div class="mb-2">
                        <label class="form-label">Documento</label>
                        <input class="form-control" name="documento" value="<?= e(old('documento', '')) ?>">
                    </div>
                    <div class="mb-2">
                        <label class="form-label">Correo</label>
                        <input type="email" class="form-control" name="email" value="<?= e(old('email', '')) ?>">
                    </div>
                    <div class="mb-2">
                        <label class="form-label">Telefono</label>
                        <input class="form-control" name="telefono" value="<?= e(old('telefono', '')) ?>">
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Direccion</label>
                        <textarea class="form-control" name="direccion"><?= e(old('direccion', '')) ?></textarea>
                    </div>
                    <button class="btn btn-primary w-100" type="submit">Guardar proveedor</button>
                </form>
            </div>
        </div>
    </div>

    <div class="col-lg-8">
        <div class="card border-0 shadow-sm">
            <div class="card-body">
                <h1 class="h5 mb-3">Proveedores</h1>
                <div class="table-responsive">
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>Nombre</th>
                            <th>Documento</th>
                            <th>Contacto</th>
                            <th>Estado</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($suppliers as $supplier): ?>
                            <tr>
                                <td><?= e((string) $supplier['id']) ?></td>
                                <td><?= e($supplier['nombre']) ?></td>
                                <td><?= e($supplier['documento'] ?? '') ?></td>
                                <td>
                                    <div><?= e($supplier['email'] ?? 'Sin correo') ?></div>
                                    <small class="text-muted"><?= e($supplier['telefono'] ?? 'Sin telefono') ?></small>
                                </td>
                                <td>
                                    <span class="badge <?= (int) ($supplier['activo'] ?? 0) === 1 ? 'text-bg-success' : 'text-bg-secondary' ?>">
                                        <?= (int) ($supplier['activo'] ?? 0) === 1 ? 'Activo' : 'Inactivo' ?>
                                    </span>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

